Skip to content

fix(dev): keep ?rolldown-lazy proxy ids out of user resolveId hooks - #10580

Merged
h-a-n-a merged 1 commit into
rolldown:mainfrom
btea:fix/lazy-proxy-resolve-id
Aug 3, 2026
Merged

h-a-n-a merged 1 commit into
rolldown:mainfrom
btea:fix/lazy-proxy-resolve-id

Conversation

@btea

@btea btea commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes vitejs/vite#23124 — re-resolving a lazy proxy id (?rolldown-lazy=1) no longer leaks to user resolveId hooks, and known proxy ids are claimed by the lazy compilation plugin itself.

Why

A plugin virtual module reached through a dynamic import becomes a lazy entry whose proxy id carries the internal ?rolldown-lazy=1 query. When that stub id is re-resolved (e.g. entry resolution for a lazy compilation request), virtual-module plugins no longer recognize their own id with the query appended, and nothing else can resolve a virtual id → UNRESOLVED_ENTRY on first page load.

#10426 covered load / transform / transform_ast / module_parsed but not resolve_id; Vite's own workaround (#22778) likewise only wraps transform.

What changed

  • LazyCompilationPlugin::resolve_id: claim proxy ids present in lazy_entries for any import kind. Unknown proxy ids still fall through and stay unresolvable (cf. the test(dev): reject unknown lazy compile modules #9969 gate).
  • PluginDriver: extend the should_skip_plugin_for_lazy_proxy skip to resolve_id, so user plugins never see the internal query; the lazy plugin itself still runs to claim the id. Matching is on the specifier only — the fetched proxy's import($MODULE_ID) (importer = proxy id) still resolves the real module through user plugins normally.
  • Regression test in packages/rolldown/tests/dev/dev-lazy-compile.test.ts: a virtual module behind a lazy proxy — asserts user resolveId hooks never see the proxy id, the proxy id re-resolves to itself, and the real module still compiles into the lazy chunk.
  • Update internal-docs/lazy-compilation/implementation.md with the new resolve_id contract.

Validation

  • pnpm --filter rolldown run build-native:debug
  • pnpm --filter rolldown-tests exec vitest run dev/dev-lazy-compile.test.ts (8/8)
  • Negative control: with the Rust changes stashed and a full rebuild, the new test fails (this.resolve(proxyId) returns null)
  • E2E with the issue's repro (vite-bundleddev-virtual-lazy-repro, local vite + this rolldown via pnpm overrides):
    • Baseline (npm rolldown 1.2.1): server logs [UNRESOLVED_ENTRY] Cannot resolve entry module \0virtual:lazy-me?rolldown-lazy=1, page shows ERR Failed to fetch dynamically imported module
    • This change: first lazy compile succeeds, page renders hello from a virtual module, zero server/console errors

Note: the repro's plugin must also recognize its own \0-prefixed id in resolveId (the canonical virtual-module pattern, which real-world plugins like @embroider/vite follow). Without it, the fetched proxy's import of the real module id can't resolve — a separate behavior difference from classic Vite dev (rolldown re-resolves the real id), better handled as a follow-up.

AI disclosure

This PR was developed with AI assistance. All generated changes were reviewed, tested, and adjusted before submission.

@btea
btea marked this pull request as ready for review August 2, 2026 03:24
@codspeed

codspeed Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing btea:fix/lazy-proxy-resolve-id (ba4d0fe) with main (3a11871)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@h-a-n-a h-a-n-a changed the title fix(dev): keep ?rolldown-lazy proxy ids out of user resolveId hooks fix(dev): keep ?rolldown-lazy proxy ids out of user resolveId hooks Aug 3, 2026
@h-a-n-a
h-a-n-a enabled auto-merge (squash) August 3, 2026 06:52
A plugin virtual module reached through a dynamic import becomes a lazy
proxy whose id carries the internal `?rolldown-lazy=1` query. Re-resolving
that id (e.g. the dev server resolving the stub id to serve a lazy
compilation request) leaked the query to user `resolveId` hooks, where
virtual-module plugins no longer recognize their own id and nothing else
can resolve a virtual id (vitejs/vite#23124).

The lazy compilation plugin now claims proxy ids present in `lazy_entries`
for any import kind, and the plugin driver skips user plugins for proxy id
specifiers in `resolve_id` — the same treatment rolldown#10426 gave the other
build hooks. Unknown proxy ids still fall through and stay unresolvable
(cf. rolldown#9969).
@h-a-n-a
h-a-n-a force-pushed the fix/lazy-proxy-resolve-id branch from a2a4778 to ba4d0fe Compare August 3, 2026 06:53
@hyfdev

hyfdev commented Aug 3, 2026

Copy link
Copy Markdown
Member

@sapphi-red cc

This is not a blocker review comment.

Similar to runtime module. This is adding some privileges to some internal modules. I wonder if there is better way to do this.

One key thing is that I think the current plugin system is only designed for normal users, while we need something that's for internal and can hide from users, so we don't need to expose something internal to outside users.

@h-a-n-a
h-a-n-a merged commit d5b2e1f into rolldown:main Aug 3, 2026
30 checks passed
@sapphi-red

Copy link
Copy Markdown
Member

Ah, maybe we can have isInternal in the ModuleInfo 🤔

@hyfdev

hyfdev commented Aug 3, 2026

Copy link
Copy Markdown
Member

Ah, maybe we can have isInternal in the ModuleInfo 🤔

I wrote some thoughts at rolldown/backlog#1

Not urgent, but we could use the place to discuss as a start.

@btea
btea deleted the fix/lazy-proxy-resolve-id branch August 3, 2026 07:08
@rolldown-guard rolldown-guard Bot mentioned this pull request Aug 3, 2026
shulaoda added a commit that referenced this pull request Aug 3, 2026
## [1.2.2] - 2026-08-03

### 🚀 Features

- code-splitting: support inlining of shared deps in dynamic entries (#10526) by @nicolo-ribaudo
- plugin: time the user callbacks configured on the options (#10509) by @IWANABETHATGUY

### 🐛 Bug Fixes

- dev: force `cleanDir` off in dev mode (#10579) by @shulaoda
- dev: keep `?rolldown-lazy` proxy ids out of user `resolveId` hooks (#10580) by @btea
- initialize re-exported wrapped ESM modules at the entry chunk (#10567) by @hyfdev
- link: resolve circular star reexports as null (#10445) by @Nic-Polumeyv
- transform: transformer gate skips newer syntax that oxc can lower (#10564) by @sekyungk
- code-splitting: materialize consumer-local barrel routing when the order-wrap plan is empty (#10544) by @hyfdev
- plugin: measure plugin hooks in JavaScript, report them from Rust (#10508) by @IWANABETHATGUY
- plugin: include external dynamic imports in chunk metadata (#10557) by @hyfdev
- plugin: report plugin timings after closeBundle has run (#10521) by @IWANABETHATGUY
- browser: avoid using node builtin modules (#10542) by @sapphi-red

### 🚜 Refactor

- plugin: give the build's own clocks their own type (#10520) by @shulaoda

### 📚 Documentation

- correct stale `buildStart` comment in `ScanStageCache::merge` (#10577) by @shulaoda
- update outdated pluginutils references (#10574) by @dogledogle

### ⚡ Performance

- external: drop the runtime import from chunks that never wrap (#10517) by @IWANABETHATGUY
- plugin: clock the build only when it is being measured (#10558) by @IWANABETHATGUY

### 🧪 Testing

- vite-tests: drop the dead `@rolldown/pluginutils` pnpm override (#10575) by @IWANABETHATGUY
- transform: group the transform-target fixtures and say why each exists (#10569) by @IWANABETHATGUY
- dev: fix hmr-hot-update-hook-vite fixture on Windows (#10565) by @h-a-n-a
- dev: match Vite's renamed full-reload log (#10547) by @shulaoda

### ⚙️ Miscellaneous Tasks

- deps: update napi (#10576) by @renovate[bot]
- deps: bump `@napi-rs/wasm-runtime` to 1.2.2 (#10570) by @shulaoda
- deps: update npm packages (#10583) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.28.0 (#10588) by @renovate[bot]
- deps: update taiki-e/install-action action to v2.85.5 (#10587) by @renovate[bot]
- deps: update codspeedhq/action action to v5 (#10584) by @renovate[bot]
- deps: update github actions (#10582) by @renovate[bot]
- deps: update rust crates (#10581) by @renovate[bot]
- deps: update dependency vite-plus to v0.2.7 (#10568) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.27.14 (#10531) by @renovate[bot]
- deps: update pnpm to v11.17.0 (#10571) by @renovate[bot]
- deps: update @napi-rs/wasm-runtime to 1.2.1 (#10545) by @sapphi-red

### ❤️ New Contributors

* @sekyungk made their first contribution in [#10564](#10564)
* @nicolo-ribaudo made their first contribution in [#10526](#10526)

Co-authored-by: shulaoda <[email protected]>
Brooooooklyn added a commit that referenced this pull request Aug 9, 2026
Upstream #10580/#10489 added dev() tests without the skipIf guard all
six sibling dev() tests carry; on this branch's CurrentThread WASI
flavor they fail deterministically at the devSupported capability gate
before any hook runs.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda
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.

experimental.bundledDev: virtual modules fail with UNRESOLVED_ENTRY when their lazy entry is compiled

4 participants