-
Notifications
You must be signed in to change notification settings - Fork 716
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
nodejs compat functions build #3133
nodejs compat functions build #3133
Conversation
🦋 Changeset detectedLatest commit: dc560d9 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.devprod.cloudflare.dev/workers-sdk/runs/4892376248/npm-package-wrangler-3133 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/3133/npm-package-wrangler-3133 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4892376248/npm-package-wrangler-3133 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4892376248/npm-package-cloudflare-pages-shared-3133 Note that these links will no longer work once the GitHub Actions artifact expires. |
const instructionForUser = `${ | ||
forPages | ||
? 'Add the "nodejs_compat" compatibility flag to your Pages project' | ||
: 'Add "node_compat = true" to your wrangler.toml file' |
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.
Might be misunderstanding the changes, but should this be compatibility_flags = ["nodejs_compat"]
?
node_compat
is the legacy polyfill implementation
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.
@Skye-31 thanks a lot for the comment, I think you're right, I wasn't really really looking into updating that error message but just adding the Pages version (as you can see the non-pages error message is totally untouched)
I can also see that node_compat
is used in a handful of places still so it might just be worth it to change all that in a followup PR instead and keep this one focused only on they Pages related changes?
Also I am not totally sure if here node_compat
is used for a specific reason 🤷
Anyways I am happy to change it or keep it and do the cleanup at some other point 🙂
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 think node_compat
is just used here because the error message was written before the newer nodejs_compat work. Might be worth updating in a future PR!
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 just checked the "handful of places" I mentioned above and it seems like the only place that needs fixing is the error message I changed here 😓 🤦 (sorry should have checked the search result more carefully the first time around)
I'll open a PR to fix that 🙂
@@ -222,6 +222,7 @@ export function buildRawWorker({ | |||
targetConsumer: local ? "dev" : "publish", | |||
local, | |||
experimentalLocal: false, | |||
forPages: true, |
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.
Is this the only place Pages calls bundleWorker
?
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.
no sorry, I missed a couple of places 😓, I've added the option there as well 🙏
Codecov Report
@@ Coverage Diff @@
## main #3133 +/- ##
==========================================
+ Coverage 74.83% 74.87% +0.04%
==========================================
Files 179 179
Lines 10852 10858 +6
Branches 2877 2880 +3
==========================================
+ Hits 8121 8130 +9
+ Misses 2731 2728 -3
|
b5bd7ff
to
b9cb66c
Compare
Can you cut a new issue to track exposing this error properly in dev too, please? |
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.
Would be good to test, but not the end of the world.
Co-authored-by: Greg Brimble <[email protected]>
78d4dfd
to
52f9745
Compare
@GregBrimble I've added a check in |
Perfect, thank you! |
d51d8a4
to
dc560d9
Compare
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.
Approved, after discussion in-person. I'm slightly concerned about the precedent this sets (bundling being aware of the target), but I can't think of a better solution right now.
Longer term, @dario-piotrowicz could you make a ticket to shift our NodeJS module erroring into an esbuild plugin that can be different between Pages and Workers, and injected into the build process without bundling having to be aware of the source?
@penalosa sure thanks! 😄👍 |
Fixes cloudflare/next-on-pages#199
What this PR solves / how to test:
Fixes passing the
nodejs_compat
flag through towrangler pages functions build
Also improve the error message so that for pages it doesn't ask to update wrangler.toml
Reviewer has performed the following, where applicable: