-
Notifications
You must be signed in to change notification settings - Fork 733
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 find_additional_modules
option to support partial bundling with externals
#3726
Conversation
🦋 Changeset detectedLatest commit: cce3d79 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/6418496031/npm-package-wrangler-3726 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6418496031/npm-package-wrangler-3726 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6418496031/npm-package-wrangler-3726 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6418496031/npm-package-cloudflare-pages-shared-3726 Note that these links will no longer work once the GitHub Actions artifact expires.
| Please ensure constraints are pinned, and |
Codecov Report
@@ Coverage Diff @@
## main #3726 +/- ##
==========================================
+ Coverage 75.09% 75.32% +0.23%
==========================================
Files 217 222 +5
Lines 12077 12179 +102
Branches 3128 3149 +21
==========================================
+ Hits 9069 9174 +105
+ Misses 3008 3005 -3
|
packages/wrangler/src/deployment-bundle/find-additional-modules.ts
Outdated
Show resolved
Hide resolved
bbd88b2
to
d2f8f05
Compare
Hey! 👋 I think this PR is ready to go now (minus some docs). You can now add something like... find_additional_modules = true
rules = [
{ type = "ESModule", globs = ["**/*.js"]},
] ...to your This gives us a slightly nicer "no bundle" mode, with the ability to use middleware whilst maintaining lazy loading/dynamic imports of Note, Closes #3074 |
find_additional_modules
option to support partial bundling with externals
d2f8f05
to
d9bccf7
Compare
Blocked by cloudflare/miniflare#631 |
d9bccf7
to
2f5c272
Compare
2f5c272
to
d27eaad
Compare
Confirming that this works and it's making the new lazy loading implementation of the workers nuxt adapter work 😃 🚀 🎉 See https://nuxt-split-workers-test.devdash.workers.dev/ (source) |
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.
Look good to me 😃
I gave the PR a somewhat thorough read and it looks all good to me, but I am very very unfamiliar with the codebase so this for sure still needs to be reviewed by someone much much more familiar with it than me
Note
This requires #3799 in order to work
d27eaad
to
c419f5d
Compare
73f2b7d
to
00a8590
Compare
07919ca
to
d095eff
Compare
The no-bundle-import tests would actually pass if Wrangler actually bundled the code, since it would identify and inline all the dynamic imports that were being tested. This change adds a test that would not pass if we are not capturing the additional modules. It also moves the declaration of no-bundle to the wrangler.toml to ensure that normal use of `wrangler dev` will get this behavior.
This has a few of benefits: - we don't risk creating too many file reads in a single go (using up all the available file handles); previously file reads were all done in parallel - we don't read the files over and over for each rule - the code is a bit easier to follow as we don't have to create `Promise.all()` objects
When using `find_additional_modules` (or `no_bundle`) we find files that will be uploaded to be deployed alongside the Worker. Previously, if an `outDir` was specified, only the Worker code was output to this directory. Now all additional modules are also output there too.
3dfad3f
to
cce3d79
Compare
Is there context on why we added this but didn't put in dev docs? |
An oversight on my part, or at least I got pulled onto other stuff and it fell off my radar; on top of that it was mainly designed for advanced users who kind of know the code already. But I think it is worth documenting this now. |
Disclaimer - WIP and untested!This fairly chunky branch contains code that should allow us to search for rules matching modules when also bundling Workers.Hey! 👋 This should be good to go now, see #3726 (comment) for details.