Skip to content

fix(bundle): preserve raw imports in watch mode#36040

Merged
nathanwhit merged 1 commit into
denoland:mainfrom
nathanwhit:agent/bundle-watch-raw-imports
Jul 15, 2026
Merged

fix(bundle): preserve raw imports in watch mode#36040
nathanwhit merged 1 commit into
denoland:mainfrom
nathanwhit:agent/bundle-watch-raw-imports

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • avoid reloading raw import assets as ordinary module graph roots in bundle watch mode
  • add regression coverage for rebuilding after CSS and TypeScript changes

Root cause

Raw imports are represented as external assets in the module graph, and their contents are fetched by the bundle loader. Watch invalidation passed a changed CSS asset to ModuleGraph::reload(), which reloaded the URL as an ordinary root without its type: "css" import context. That poisoned the graph and caused every subsequent rebuild to reject the CSS import.

External asset entries do not contain source that needs to be refreshed. Esbuild calls the bundle loader again for the changed input, which fetches the current contents, so watch mode now excludes those entries from graph reload while retaining normal reload behavior for source modules.

Fixes #36036.

Validation

  • cargo build --bin deno
  • cargo test -p integration_tests --test integration -- watcher::bundle_watch (3 passed)
  • ./tools/lint.js
  • ./tools/format.js --check
  • reproduced the reported HTML/--outdir workflow and verified CSS and subsequent TypeScript changes both rebuilt successfully

@nathanwhit
nathanwhit marked this pull request as ready for review July 14, 2026 23:44
@nathanwhit
nathanwhit merged commit dff3cbe into denoland:main Jul 15, 2026
172 checks passed
bartlomieju pushed a commit that referenced this pull request Jul 15, 2026
## Summary

- avoid reloading raw import assets as ordinary module graph roots in
bundle watch mode
- add regression coverage for rebuilding after CSS and TypeScript
changes

## Root cause

Raw imports are represented as external assets in the module graph, and
their contents are fetched by the bundle loader. Watch invalidation
passed a changed CSS asset to `ModuleGraph::reload()`, which reloaded
the URL as an ordinary root without its `type: "css"` import context.
That poisoned the graph and caused every subsequent rebuild to reject
the CSS import.

External asset entries do not contain source that needs to be refreshed.
Esbuild calls the bundle loader again for the changed input, which
fetches the current contents, so watch mode now excludes those entries
from graph reload while retaining normal reload behavior for source
modules.

Fixes #36036.

## Validation

- `cargo build --bin deno`
- `cargo test -p integration_tests --test integration --
watcher::bundle_watch` (3 passed)
- `./tools/lint.js`
- `./tools/format.js --check`
- reproduced the reported HTML/`--outdir` workflow and verified CSS and
subsequent TypeScript changes both rebuilt successfully
bartlomieju added a commit that referenced this pull request Jul 20, 2026
Resolves conflicts:
- cli/tools/bundle/mod.rs: port reload_specifiers (incl. #36040 raw-import
  fix) onto the rolldown DenoPluginHandler and wire watch-mode reload of
  changed specifiers and HTML entrypoints (restores canonical_path)
- Cargo.lock: take main's, upgrade rolldown 1.0.0 -> 1.2.0 to fix
  duplicate oxc_sourcemap resolution

Claude-Session: https://claude.ai/code/session_01QXBexiVeaPBqGPgAxcTLNQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deno bundle does not work with watch mode and CSS imports

1 participant