Skip to content

Commit bb7f385

Browse files
committed
Add --node-compat to Pages publish
1 parent b44e1a7 commit bb7f385

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

.changeset/happy-trees-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Add support for `--node-compat` when running `wrangler pages publish`. Support for CI will be coming in the future.

packages/wrangler/src/__tests__/pages.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ describe("pages", () => {
352352
--commit-dirty Whether or not the workspace should be considered dirty for this deployment [boolean]
353353
--skip-caching Skip asset caching which speeds up builds [boolean]
354354
--no-bundle Whether to run bundling on \`_worker.js\` before deploying [boolean] [default: true]
355+
--node-compat Enable node.js compatibility [boolean] [default: false]
355356
356357
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
357358
`);

packages/wrangler/src/pages/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export function Options(yargs: Argv) {
7979
describe: "Enable node.js compatibility",
8080
default: false,
8181
type: "boolean",
82-
hidden: true,
8382
},
8483
bindings: {
8584
type: "string",

packages/wrangler/src/pages/dev.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export function Options(yargs: Argv) {
143143
describe: "Enable node.js compatibility",
144144
default: false,
145145
type: "boolean",
146-
hidden: true,
147146
},
148147
"experimental-local": {
149148
describe: "Run on my machine using the Cloudflare Workers runtime",

packages/wrangler/src/pages/publish.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ export function Options(yargs: Argv) {
7878
type: "string",
7979
hidden: true,
8080
},
81+
"node-compat": {
82+
describe: "Enable node.js compatibility",
83+
default: false,
84+
type: "boolean",
85+
},
8186
})
8287
.epilogue(pagesBetaWarning);
8388
}
@@ -93,6 +98,7 @@ export const Handler = async ({
9398
bundle,
9499
noBundle,
95100
config: wranglerConfig,
101+
nodeCompat,
96102
}: PublishArgs) => {
97103
if (wranglerConfig) {
98104
throw new FatalError("Pages does not support wrangler.toml", 1);
@@ -300,6 +306,12 @@ export const Handler = async ({
300306
let filepathRoutingConfig: string | undefined;
301307

302308
if (!_workerJS && existsSync(functionsDirectory)) {
309+
if (nodeCompat) {
310+
console.warn(
311+
"Enabling node.js compatibility mode for builtins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
312+
);
313+
}
314+
303315
const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.js`);
304316
const outputConfigPath = join(
305317
tmpdir(),
@@ -319,6 +331,7 @@ export const Handler = async ({
319331
project.deployment_configs[isProduction ? "production" : "preview"]
320332
.d1_databases ?? {}
321333
),
334+
nodeCompat,
322335
});
323336

324337
builtFunctions = readFileSync(outfile, "utf-8");

0 commit comments

Comments
 (0)