Skip to content

🐛 BUG: Wrangler is injecting development code in production builds #4269

@Skye-31

Description

@Skye-31

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.

// wrangler-modules-watch:wrangler:modules-watch
var init_wrangler_modules_watch = __esm({
  "wrangler-modules-watch:wrangler:modules-watch"() {
    init_modules_watch_stub();
  }
});

// node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/modules-watch-stub.js
var init_modules_watch_stub = __esm({
  "node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/modules-watch-stub.js"() {
    init_wrangler_modules_watch();
  }
});

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 present

Please provide any relevant error logs

No response

Metadata

Metadata

Labels

bugSomething that isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions