-
Notifications
You must be signed in to change notification settings - Fork 774
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
🐛 BUG: Wrangler is injecting development code in production builds #4269
Labels
bug
Something that isn't working
Comments
It appears this code is only added if esbuild is having to deal with a Common JS import. If all the code in a Worker is ESM then this virtual module gets stripped from the output. |
petebacondarwin
added a commit
that referenced
this issue
Jun 3, 2024
When we added the ability to include additional modules in the deployed bundle of a Worker, we inadvertently also included some boiler plate code that is only needed at development time. This fix ensures that this code is only injected if we are running esbuild in watch mode (e.g. `wrangler dev`) and not when building for deployment. It is interesting to note that this boilerplate only gets included in the production code if there is an import of CommonJS code in the Worker, which esbuild needs to convert to an ESM import. Fixes [#4269](#4269)
12 tasks
petebacondarwin
added a commit
that referenced
this issue
Jun 4, 2024
…5960) When we added the ability to include additional modules in the deployed bundle of a Worker, we inadvertently also included some boiler plate code that is only needed at development time. This fix ensures that this code is only injected if we are running esbuild in watch mode (e.g. `wrangler dev`) and not when building for deployment. It is interesting to note that this boilerplate only gets included in the production code if there is an import of CommonJS code in the Worker, which esbuild needs to convert to an ESM import. Fixes [#4269](#4269)
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which Cloudflare product(s) does this pertain to?
Wrangler core
What version(s) of the tool(s) are you using?
3.14.0
What version of Node are you using?
v18.17.0
What operating system are you using?
Mac
Describe the Bug
Wrangler has started injecting some sort of "modules watch" code into production builds, when it shouldn't be. These functions are getting called for every import that is made in your worker script, which has an increase in both script size of ~5kb, and script startup time.
This behaviour started occurring in 3.11.0, and didn't occur in 3.10.0, so I'm almost certain it's the result of #3726, cc @petebacondarwin
Please provide a link to a minimal reproduction
Any worker that imports anything ->
npx wrangler deploy --outdir dist
, look at the outputted code to see these files which shouldn't be presentPlease provide any relevant error logs
No response
The text was updated successfully, but these errors were encountered: