-
Notifications
You must be signed in to change notification settings - Fork 792
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
Add --node-compat to Pages publish #2541
Conversation
🦋 Changeset detectedLatest commit: 2bc6376 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/6711485115/npm-package-wrangler-2541 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6711485115/npm-package-wrangler-2541 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6711485115/npm-package-wrangler-2541 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6711485115/npm-package-cloudflare-pages-shared-2541 Note that these links will no longer work once the GitHub Actions artifact expires.
| Please ensure constraints are pinned, and |
The nodejs compat flag won't have parity for quite a while. In-dash option is also not a blocker, we've done this many times and it takes no time at all to this to the UI. This also means the migration to the new flag is also the same rather than being another thing different. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2541 +/- ##
==========================================
- Coverage 75.34% 72.97% -2.37%
==========================================
Files 223 156 -67
Lines 12341 9748 -2593
Branches 3190 2570 -620
==========================================
- Hits 9298 7114 -2184
+ Misses 3043 2634 -409
|
894c8c0
to
bb7f385
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.
Looks great, would like to see an integration test for this before it goes in, probably should go here: https://github.com/cloudflare/wrangler2/blob/main/packages/wrangler/src/__tests__/pages.test.ts 😃
if (nodeCompat) { | ||
console.warn( | ||
"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." | ||
); | ||
} |
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.
Could you add a test that runs wrangler pages publish --node-compat
I agree with this take on the polyfill |
Any updates on when this might get merged in? |
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.
Blocking until we've had internal product roadmap discussions.
bb7f385
to
2bc6376
Compare
Rather than accepting this as a arg on deploy, should we instead look at the config of the project in the dashboard and use that so it's all kept in one place? Sort of like how we did D1 when it was in beta and needed the shims? |
It's already an arg for Workers, if we did move it we'd also need to change dev behaviour to pull from the project which just diverges us more from Workers. |
But we don't yet have it for many other similar props like compat date and flags. Feels like we should solve syncing config separately to adding this node compat feature (so should stay consistent until we've got that bit figured out in a separate effort). |
I can confirm that using the prerelease version mentioned above indeed let's me deploy a project using
Update: Turned out to be the size limit of the worker (>1MB, I was testing on a free account) that just leads to a failed deployment, instead of the normal output you get with Cloudflare Workers. We would really appreciate if this could be added to the stable version of |
Hi @janpio! |
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.
This feels like a reasonable addition, given that it is already supported by Pages dev
and build
commands.
What's left to get this ready to be merged?
@Hebilicious Yes, this change to the CLI unblocks usage of |
I think a workaround for now is to use Does that work for your use case? |
@WalshyDev it looks like a check failed on a formatting issue. Could you fix that and we should be good to merge? |
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 we still first need to discuss and make a clear decision on how this impacts the source of truth for this currently dash-only config setting. This, although aligns with Workers in some ways by exposing this CLI arg in the deploy
command, misaligns with Pages in others, in that this setting can now be configured completely independently of our source-of-truth: the dashboard.
@GregBrimble Can In my (external) understanding |
* Temproarily disable Worker pages test See cloudflare/workers-sdk#2541 * Fix things * Fix finally * Apply suggestions from code review Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> --------- Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
Since this PR is very unlikely to land as-is (e.g. we actually want to make nodejs compat flag the approach to take in the long run) and this PR has been sitting around for quite some time, we are going to close it for now. If and when we decide to implement the |
What is the recommended workaround in the meantime @petebacondarwin? Right now it seems that |
@janpio - can you try the workaround here? |
Oh sorry, we tried that but seem to have forgotten to report back:
Full setup here: prisma/ecosystem-tests#4504 + https://github.com/prisma/ecosystem-tests/actions/runs/7743032416/job/21113520833?pr=4504#step:8:147 |
OK let me reproduce. The error message seems to imply you are only missing |
Indeed, seems I got lost in the different commands before. Although I now realized that |
Yeah sorry about this. It is all a bit messy right now. Trying to work out if there is a magical combination of commands that we could use. |
Give this a go: prisma/ecosystem-tests#4574 |
Coming here to report that Pete's workaround is working well 🚀. Thanks! |
@petebacondarwin Is there any chance that the workaround could be documented in the Pages docs, or at least here ? This is what I could gather from the Prisma PR : echo "Temporary disabled, because wrangler does not support "--node-compat" flag for pages commands yet. See https://github.com/cloudflare/workers-sdk/pull/2541"
pnpm install
# First build the functions using the `--node-compat` flag into the `_worker.js` directory
# (Note that the functions are in the non-standard `fns` directory so that they are not confused with the output `_worker.js` directory.)
# Make sure build folder does not exist
rm -rf build
# Build pages function to build/_worker.js
pnpm wrangler pages functions build fns --node-compat --outdir build/_worker.js
# Copy index.html to build folder
cp index.html build/index.html
# Now deploy the _worker.js alongside the index.html asset to Pages
pnpm wrangler pages deploy ./build |
Maybe you should consider updating your documentation because as far as I can tell this still isn't working with pg and Pages. The workaround I have found is to use the postgres npm package instead of pg. |
We should update that to make it clear that the tutorial is for Workers not Pages. |
What this PR solves / how to test:
This adds
--node-compat
support to Pages, this is a common feature request and will allow for the usage of Stripe and other such libs within Functions.Associated docs issues/PR:
N/A
Author has included the following, where applicable:
Reviewer has performed the following, where applicable:
Fixes #1074