Skip to content

[wrangler] Fix modules-watch-stub injection when bundle:false (fixes … - #15032

Open
Sertug17 wants to merge 5 commits into
cloudflare:mainfrom
Sertug17:fix/modules-watch-stub-no-bundle
Open

[wrangler] Fix modules-watch-stub injection when bundle:false (fixes …#15032
Sertug17 wants to merge 5 commits into
cloudflare:mainfrom
Sertug17:fix/modules-watch-stub-no-bundle

Conversation

@Sertug17

@Sertug17 Sertug17 commented Aug 5, 2026

Copy link
Copy Markdown

Fixes #14845.

When bundle: false (e.g. no_bundle = true in wrangler.toml, or the --no-bundle flag), esbuild does not resolve imports in injected files. Previously modules-watch-stub.js was injected whenever watch: true, which left import "wrangler:modules-watch" unresolved in the output, causing workerd to crash at runtime:

Uncaught Error: No such module "wrangler:modules-watch"
imported from "pages-shim.js"

Reproducible with wrangler pages dev on a Nitro project using the cloudflare-module preset (generates no_bundle = true in wrangler.toml).

Fix: only inject the stub when bundle: true. When bundling is disabled, file watching is already handled by chokidar in use-esbuild.ts, so the esbuild-internal watch stub is not needed.

Checkboxes:

Tests: "Additional testing not necessary because:" → the watch stub injection path is tested via existing bundleWorker unit tests; no bundle mode is already covered by chokidar


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1af6db6

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin 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](https://github.com/Sertug17/workers-sdk/new/fix/modules-watch-stub-no-bundle?filename=.changeset/ripe-chicken-hide.md&value=---%0A%22wrangler%22%3A%20patch%0A---%0A%0A%5Bwrangler%5D%20Fix%20modules-watch-stub%20injection%20when%20bundle%3Afalse%20(fixes%20%E2%80%A6%0A)

@Sertug17

Sertug17 commented Aug 5, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team August 5, 2026 06:58
@workers-devprod

workers-devprod commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/fix-modules-watch-stub-no-bundle.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/api/startDevWorker/BundleController.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/bundle.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15032

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15032

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15032

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15032

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15032

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15032

miniflare

npm i https://pkg.pr.new/miniflare@15032

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15032

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15032

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15032

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15032

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@15032

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15032

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15032

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15032

wrangler

npm i https://pkg.pr.new/wrangler@15032

commit: 1af6db6

@edmundhung edmundhung added the ci:skip-pr-description-validation Skip validation of the required PR description format label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:skip-pr-description-validation Skip validation of the required PR description format

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

Bug Report: Uncaught Error: No such module "wrangler:modules-watch" when running wrangler pages dev on Nitro build

3 participants