-
Notifications
You must be signed in to change notification settings - Fork 955
Ensure that Node.js polyfills are pre-optimized before the first request #8688
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
Ensure that Node.js polyfills are pre-optimized before the first request #8688
Conversation
🦋 Changeset detectedLatest commit: 6613be0 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/14177000445/npm-package-wrangler-8688 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8688/npm-package-wrangler-8688 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-wrangler-8688 dev path/to/script.js Additional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-workers-bindings-extension-8688 -O ./cloudflare-workers-bindings-extension.0.0.0-v328c0d2a7.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v328c0d2a7.vsix create-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-create-cloudflare-8688 --no-auto-update @cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-kv-asset-handler-8688 miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-miniflare-8688 @cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-pages-shared-8688 @cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-unenv-preset-8688 @cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-vite-plugin-8688 @cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-vitest-pool-workers-8688 @cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-workers-editor-shared-8688 @cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-workers-shared-8688 @cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14177000445/npm-package-cloudflare-workflows-shared-8688 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
a8ccf9c
to
321861f
Compare
7324c2f
to
6d1c924
Compare
c0a7faa
to
2223f7d
Compare
b28a9ab
to
4954054
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! Thanks for figuring this out.
This comment is no longer valid now that you've removed the
|
Yep - good spot. I updated the comment: it is now the resolveId hook that sets this element. The assertion is still valid. |
c0c4d96
to
e673463
Compare
Previously, these polyfills were only optimized on demand when Vite became aware of them. This was either because Vite was able to find an import to a polyfill when statically analysing the import tree of the entry-point, or when a polyfilled module was dynamically imported as part of a executing code to handle a request. In the second case, the optimizing of the dynamically imported dependency causes a reload of the Vite server, which can break applications that are holding state in modules during the request. This is the case of most React type frameworks, in particular React Router. Now, we pre-optimize all the possible Node.js polyfills when the server starts before the first request is handled.
e673463
to
6613be0
Compare
Fixes DEVX-1769
Previously, these polyfills were only optimized on demand when Vite became aware of them.
This was either because Vite was able to find an import to a polyfill when statically analysing the import tree of the entry-point,
or when a polyfilled module was dynamically imported as part of a executing code to handle a request.
In the second case, the optimizing of the dynamically imported dependency causes a reload of the Vite server, which can break applications that are holding state in modules during the request.
This is the case of most React type frameworks, in particular React Router.
Now, we pre-optimize all the possible Node.js polyfills when the server starts before the first request is handled.