Skip to content

Nodejs compat v2 on pages#6511

Merged
petebacondarwin merged 8 commits intomainfrom
nodejs-compat-v2-on-pages
Aug 21, 2024
Merged

Nodejs compat v2 on pages#6511
petebacondarwin merged 8 commits intomainfrom
nodejs-compat-v2-on-pages

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin commented Aug 16, 2024

What this PR solves / how to test

Fixes #6288

You can try it out yourself by pulling down this repo: https://github.com/petebacondarwin/nodejs-2-demo

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because: experimental feature - although it might be blogged about soon

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 16, 2024

🦋 Changeset detected

Latest commit: 9520b95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 16, 2024

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/10490271832/npm-package-wrangler-6511

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6511/npm-package-wrangler-6511

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-wrangler-6511 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-create-cloudflare-6511 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-cloudflare-kv-asset-handler-6511
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-miniflare-6511
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-cloudflare-pages-shared-6511
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-cloudflare-vitest-pool-workers-6511
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-cloudflare-workers-editor-shared-6511
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10490271832/npm-package-cloudflare-workers-shared-6511

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.72.1 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240806.1
workerd 1.20240806.0 1.20240806.0
workerd --version 1.20240806.0 2024-08-06

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@petebacondarwin petebacondarwin force-pushed the nodejs-compat-v2-on-pages branch from 759e8a3 to 6b4ea80 Compare August 20, 2024 17:39
@irvinebroque
Copy link
Copy Markdown
Contributor

So excited about this one 👏

@petebacondarwin petebacondarwin force-pushed the nodejs-compat-v2-on-pages branch from 6b4ea80 to 4c05bc9 Compare August 21, 2024 08:53
@petebacondarwin petebacondarwin changed the title WIP : Nodejs compat v2 on pages Nodejs compat v2 on pages Aug 21, 2024
@petebacondarwin petebacondarwin added the e2e Run wrangler + vite-plugin e2e tests on a PR label Aug 21, 2024
@petebacondarwin petebacondarwin force-pushed the nodejs-compat-v2-on-pages branch from 4c05bc9 to e61cef9 Compare August 21, 2024 09:03
@petebacondarwin petebacondarwin marked this pull request as ready for review August 21, 2024 09:24
@petebacondarwin petebacondarwin requested review from a team as code owners August 21, 2024 09:24
const minify = props.minify ?? config.minify;

const compatibilityFlags =
props.compatibilityFlags ?? config.compatibility_flags;
Copy link
Copy Markdown
Contributor

@vicb vicb Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there are quite a few const someField = props.someField ??/|| config.someFiled, maybe replace with

const resolvedConfig = {...props, ...config}; // x1
const {someField} = resolvedConfig; // x15

edit: even const resolvedConfig = {...defaultConfig, ...props, ...config}; // x1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather be explicit about which flags can be overridden, rather than hiding them in a general override like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that in props the properties tend to be camelCased while in config they can be snake_cased.

@petebacondarwin petebacondarwin force-pushed the nodejs-compat-v2-on-pages branch from 10eb49e to 5bc168b Compare August 21, 2024 11:57
Copy link
Copy Markdown
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed every single line of this PR, but I reviewed the critical parts, and overall structure and that all looks good to me.

Thanks for adding all the test as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run wrangler + vite-plugin e2e tests on a PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler pages deploy throws misleading error when experimental:nodejs_compat_v2 is enabled

6 participants