-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added --node-compat
to Pages Dev & Functions
#1000
Conversation
🦋 Changeset detectedLatest commit: 3eb04d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2374149528/npm-package-wrangler-1000 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1000/npm-package-wrangler-1000 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2374149528/npm-package-wrangler-1000 dev path/to/script.js |
9201fc0
to
89ef9a5
Compare
Really cool to see this working, but I don't think we can merge until we have a way for people to use this in production. So that'll require either a project-level setting in the dashboard, or a Pages config file. I imagine probably the former, but the Pages team will need to confirm. |
@GregBrimble Awesome let me know what ya'll decide next week. I might need help with this one failing test anyway lol not sure why the plugin import static asset was affected by these changes |
So cool. Looking forward to seeing this in Pages. |
--node-compat
to Pages Dev & Functions--node-compat
to Pages Dev & Functions
89ef9a5
to
b577642
Compare
--node-compat
to Pages Dev & Functions--node-compat
to Pages Dev & Functions
fd601ae
to
8104a17
Compare
a84d615
to
481c444
Compare
`pages dev <dir>` & `wrangler pages functions build` will have a `--node-compat` flag powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills). The only difference in `pages` will be it does not check the `wrangler.toml` so the `node_compat = true` will not enable it for `wrangler pages` functionality. resolves #890
481c444
to
3eb04d4
Compare
@@ -1579,6 +1601,12 @@ export const pages: BuilderCallback<unknown, unknown> = (yargs) => { | |||
type: "string", | |||
description: "The directory to output static assets to", | |||
}, | |||
"node-compat": { | |||
describe: "Enable node.js compaitibility", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe: "Enable node.js compaitibility", | |
describe: "Enable node.js compatibility", |
@@ -1299,6 +1303,12 @@ export const pages: BuilderCallback<unknown, unknown> = (yargs) => { | |||
default: false, | |||
description: "Auto reload HTML pages when change is detected", | |||
}, | |||
"node-compat": { | |||
describe: "Enable node.js compaitibility", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe: "Enable node.js compaitibility", | |
describe: "Enable node.js compatibility", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make another PR, didn't see these comments on my phone.
@@ -1013,7 +1017,7 @@ const createDeployment: CommandModule< | |||
let builtFunctions: string | undefined = undefined; | |||
const functionsDirectory = join(cwd(), "functions"); | |||
if (existsSync(functionsDirectory)) { | |||
const outfile = join(tmpdir(), "./functionsWorker.js"); | |||
const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.js`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GregBrimble - these changes are due to the tmpdir()
function always returning the same folder, which resulted in parallel tests overwriting each other's files.
We should come up with a better solution than actually needing to write these files to disk, ideally.
Also we could consider using fs.mkdtempSync()
in combination with tmpdir()
to really encapsulate separate runs of Pages builds.
But for now I think this is a reasonable way to unblock this PR.
pages dev <dir>
&wrangler pages functions build
will have a--node-compat
flag powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills). The only difference inpages
will be it does not check thewrangler.toml
so thenode_compat = true
will not enable it forwrangler pages
functionality.resolves #890