Repository navigation
fix(plugin): include external dynamic imports in chunk metadata - #10557
Conversation
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@codex review |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merge activity
|
External `import()` targets are missing from the `dynamicImports` metadata delivered to plugins.
This PR reports retained external targets in both `renderChunk` and `generateBundle`.
```js
// input
void import('node:path');
// before
chunk.dynamicImports; // []
// after
chunk.dynamicImports; // ['node:path']
```
## Problem
The omission occurs when a dynamic import resolves to an external module and survives tree-shaking. Internal dynamic chunks continue to be reported, and generated import code is unaffected.
The chunk-linking stage, which derives chunk dependencies for plugin metadata, only carried cross-chunk targets. Those targets exist for internal chunks, leaving external dynamic-import targets unavailable when the rendered and final output metadata is built.
## Fix
Record retained external dynamic-import targets per chunk and add them to the metadata used by both hooks.
The result remains a deterministic, de-duplicated dependency list. This intentionally does not make `dynamicImports` a per-call trace: source-call ordering and repeated calls are not part of the compatibility contract.
## Validation
- Added a plugin fixture that failed before the fix with `[]` and now observes `['node:path']` in both `renderChunk` and `generateBundle`.
- `just build-rolldown`
- `RUST_BACKTRACE=1 ROLLDOWN_TEST=1 vp exec --filter rolldown-tests -- vitest run fixtures-concurrent.test.ts --reporter verbose --hideSkippedTests --testNamePattern 'plugin/render-chunk/render-chunk-external|output/dynamic-imports-metadata'`
- `cargo clippy -p rolldown -p rolldown_common --all-targets -- --deny warnings`
- `vp check packages/rolldown/tests/fixtures/plugin/render-chunk/render-chunk-external-dynamic-import/_config.ts`
Full `just test-rust` remains unverified in this worktree because its `test262` submodule is absent.
Fixes #10546
d297528 to
ed4e7cc
Compare
## [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]>
External
import()targets are missing from thedynamicImportsmetadata delivered to plugins.This PR reports retained external targets in both
renderChunkandgenerateBundle.Problem
The omission occurs when a dynamic import resolves to an external module and survives tree-shaking. Internal dynamic chunks continue to be reported, and generated import code is unaffected.
The chunk-linking stage, which derives chunk dependencies for plugin metadata, only carried cross-chunk targets. Those targets exist for internal chunks, leaving external dynamic-import targets unavailable when the rendered and final output metadata is built.
Fix
Record retained external dynamic-import targets per chunk and add them to the metadata used by both hooks.
The result remains a deterministic, de-duplicated dependency list. This intentionally does not make
dynamicImportsa per-call trace: source-call ordering and repeated calls are not part of the compatibility contract.Validation
[]and now observes['node:path']in bothrenderChunkandgenerateBundle.just build-rolldownRUST_BACKTRACE=1 ROLLDOWN_TEST=1 vp exec --filter rolldown-tests -- vitest run fixtures-concurrent.test.ts --reporter verbose --hideSkippedTests --testNamePattern 'plugin/render-chunk/render-chunk-external|output/dynamic-imports-metadata'cargo clippy -p rolldown -p rolldown_common --all-targets -- --deny warningsvp check packages/rolldown/tests/fixtures/plugin/render-chunk/render-chunk-external-dynamic-import/_config.tsFull
just test-rustremains unverified in this worktree because itstest262submodule is absent.Fixes #10546