Repository navigation
fix(dev): keep ?rolldown-lazy proxy ids out of user resolveId hooks - #10580
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
?rolldown-lazy proxy ids out of user resolveId hooks
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).
a2a4778 to
ba4d0fe
Compare
|
@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. |
|
Ah, maybe we can have |
I wrote some thoughts at rolldown/backlog#1 Not urgent, but we could use the place to discuss as a start. |
## [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]>
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
Summary
Fixes vitejs/vite#23124 — re-resolving a lazy proxy id (
?rolldown-lazy=1) no longer leaks to userresolveIdhooks, 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=1query. 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_ENTRYon first page load.#10426 covered
load/transform/transform_ast/module_parsedbut notresolve_id; Vite's own workaround (#22778) likewise only wrapstransform.What changed
LazyCompilationPlugin::resolve_id: claim proxy ids present inlazy_entriesfor 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 theshould_skip_plugin_for_lazy_proxyskip toresolve_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'simport($MODULE_ID)(importer = proxy id) still resolves the real module through user plugins normally.packages/rolldown/tests/dev/dev-lazy-compile.test.ts: a virtual module behind a lazy proxy — asserts userresolveIdhooks never see the proxy id, the proxy id re-resolves to itself, and the real module still compiles into the lazy chunk.internal-docs/lazy-compilation/implementation.mdwith the newresolve_idcontract.Validation
pnpm --filter rolldown run build-native:debugpnpm --filter rolldown-tests exec vitest run dev/dev-lazy-compile.test.ts(8/8)this.resolve(proxyId)returnsnull)[UNRESOLVED_ENTRY] Cannot resolve entry module \0virtual:lazy-me?rolldown-lazy=1, page showsERR Failed to fetch dynamically imported modulehello from a virtual module, zero server/console errorsNote: the repro's plugin must also recognize its own
\0-prefixed id inresolveId(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.