Skip to content

fix(plugin): include external dynamic imports in chunk metadata - #10557

Merged
graphite-app[bot] merged 1 commit into
mainfrom
fix-10546-renderchunk-dynamic-imports
Jul 31, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
fix-10546-renderchunk-dynamic-imports

Conversation

@hyfdev

@hyfdev hyfdev commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

External import() targets are missing from the dynamicImports metadata delivered to plugins.
This PR reports retained external targets in both renderChunk and generateBundle.

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

@netlify

netlify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit ed4e7cc
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a6c198b88690c0008d5be3e
😎 Deploy Preview https://deploy-preview-10557--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hyfdev
hyfdev marked this pull request as ready for review July 31, 2026 03:25
Copilot AI review requested due to automatic review settings July 31, 2026 03:25

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shulaoda

Copy link
Copy Markdown
Member

@codex review

@codspeed

codspeed Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix-10546-renderchunk-dynamic-imports (d297528) with main (ff108d6)2

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. ↩

  2. No successful run was found on main (dd4dece) during the generation of this report, so ff108d6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: d297528b12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

hyfdev commented Jul 31, 2026 •

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 31, 3:41 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 31, 3:41 AM UTC: hyfdev added this pull request to the Graphite merge queue.
  • Jul 31, 3:48 AM UTC: Merged by the Graphite merge queue.

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
@graphite-app
graphite-app Bot force-pushed the fix-10546-renderchunk-dynamic-imports branch from d297528 to ed4e7cc Compare July 31, 2026 03:42
@graphite-app
graphite-app Bot merged commit ed4e7cc into main Jul 31, 2026
35 checks passed
@graphite-app
graphite-app Bot deleted the fix-10546-renderchunk-dynamic-imports branch July 31, 2026 03:48
@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]>
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.

[Bug]: RenderChunk.dynamicImports does not contain external imports

3 participants