Skip to content

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

Merged
edmundhung merged 5 commits into
cloudflare:mainfrom
Sertug17:fix/modules-watch-stub-no-bundle
Aug 11, 2026
Merged

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

Conversation

@Sertug17

@Sertug17 Sertug17 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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
Contributor 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

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Aug 10, 2026
@edmundhung
edmundhung merged commit 6e7d37d into cloudflare:main Aug 11, 2026
75 of 79 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Aug 11, 2026
@Sertug17

Copy link
Copy Markdown
Contributor Author

thank you 🎉

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: Done

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