Enable nodejs_compat by default for new projects created by C3#8310
Enable nodejs_compat by default for new projects created by C3#8310petebacondarwin merged 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 7923b0b The changes in this PR will be included in the next version bump. 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/13596487290/npm-package-wrangler-8310You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8310/npm-package-wrangler-8310Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-wrangler-8310 dev path/to/script.jsAdditional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-workers-bindings-extension-8310 -O ./cloudflare-workers-bindings-extension.0.0.0-v60c7bd564.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v60c7bd564.vsixcreate-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-create-cloudflare-8310 --no-auto-update@cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-kv-asset-handler-8310miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-miniflare-8310@cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-pages-shared-8310@cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-unenv-preset-8310@cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-vite-plugin-8310@cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-vitest-pool-workers-8310@cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-workers-editor-shared-8310@cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-workers-shared-8310@cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13596487290/npm-package-cloudflare-workflows-shared-8310Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
|
I would lean towards all docs that require nodejs_compat to avoid errors should include it in the steps, even if nodejs_compat becomes a default, in case for some reason, someone has a cloudflare worker without nodejs compat enabled. So I would lean towards leaving https://developers.cloudflare.com/hyperdrive/get-started/#enable-nodejs-compatibility (maybe switch 'Enable' to 'Ensure') and I think we should still merge cloudflare/cloudflare-docs#19860 |
|
Generally I love to see this.
|
a479da7 to
1539853
Compare
|
Claude finished @irvinebroque's task —— View job Changeset Review
✅ All changesets look good |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
I would rephrase to already tested - because there are trivial ways to tests what the flag enables |
Unnecessary polyfills -> we have removed a lot of them already and will keep removing more. "almost 1000%" is exaggerating, it mostly adds a constant size (a few kB). I don't think versioning should be a concern. It is handled via the compat date. But please let us know if you have a specific (recent) concern. Thanks. |
The versioning concerns were solved with |
penalosa
left a comment
There was a problem hiding this comment.
This should be added to config files by C3, rather than manually added to each one. Blocking so we don't accidentally merge this, but I'll push a commit to fix soon
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
a199451 to
2476967
Compare
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
refs #7388
We've gone back and forth on this in the past — but in practice, have found that:
nodejs_compatis enabled. Hit the ground running, and NPM packages you want to use are more likely to work.nodejs_compatis not enabled by default for new projects, products like Hyperdrive, or tutorials that use any NPM packages, need to explain extra steps and caveats to developers. Steps that are easy to miss, or misunderstand.Getting the ecosystem using shared standards is important. That's why WinterTC exists, why all the awesome work that @jasnell and others do matters. How we get there is by working with WinterTC and the broader community — not by holding back
nodejs_compatto developers getting started building Workers. The whole point is that developers and open-source maintainers shouldn't have to navigate a maze of differences — and enablingnodejs_compatfor new projects furthers that goal.We're going to keep making
nodejs_compatbetter, more native to the Workers Runtime, and more comprehensive. And listen to what the vast majority of people want and expect when starting new projects. Disabling nodejs_compat is just one line of configuration to remove :)Implementation approach
Instead of manually adding
nodejs_compatto each template's wrangler.jsonc file, this change adds the flag automatically in C3'supdateWranglerConfigfunction. This approach:nodejs_compatif any of the following are already present:nodejs_compat(already enabled)nodejs_compat_v2(newer version)no_nodejs_compat(explicitly disabled)nodejs_compatfor Python projects since nodejs_compat is not compatible with Python workersThe Python check (
ctx.args.lang !== "python") is performed inupdateWranglerConfigbefore calling the helper functions, making the control flow clearer.Human review checklist:
addNodejsCompatFlagandaddNodejsCompatFlagToTomlcorrectly handle edge cases (existing flags, nodejs_compat_v2, no_nodejs_compat)ctx.args.lang !== "python") correctly identifies all Python templatesDevin PR requested by @petebacondarwin
Link to Devin run: https://app.devin.ai/sessions/7a606cdbe6d148a48d02975f027bf808