refactor: switch asset module support from hard-code to builtin plugin#8546
Conversation
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
aeb89e3 to
2202297
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors rolldown’s handling of ModuleType::Asset by removing hardcoded core support and replacing it with a built-in Rust plugin (rolldown_plugin_asset_module), aligning asset behavior with existing built-in plugin patterns (e.g. copy-module) and routing asset emission/path resolution through the plugin + FileEmitter.
Changes:
- Add
rolldown_plugin_asset_moduleimplementingload+renderChunkto emit assets and rewrite__ROLLDOWN_ASSET__#<ref_id>placeholders to relative output paths. - Remove legacy core asset pipeline (
AssetView,AssetGenerator, per-chunk asset preliminary filename tables) and add aFileEmitterbridge fornew URL(..., import.meta.url)finalization. - Extend plugin load args with
asserted_module_typeand wire it through the loader, plus update relevant snapshots.
Reviewed changes
Copilot reviewed 41 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| meta/design/plugin-asset-module.md | Design notes for the new built-in asset module plugin and behavior changes. |
| crates/rolldown_plugin_asset_module/src/lib.rs | New built-in plugin that loads asset modules, emits files, and rewrites placeholders in renderChunk. |
| crates/rolldown_plugin_asset_module/Cargo.toml | Declares the new plugin crate and dependencies. |
| crates/rolldown_plugin/src/types/hook_load_args.rs | Adds asserted_module_type to load hook args. |
| crates/rolldown_plugin/src/plugin_context/plugin_context.rs | Exposes associate_module_with_emitted_file on PluginContext. |
| crates/rolldown_plugin/src/plugin_context/native_plugin_context.rs | Plumbs associate_module_with_emitted_file into the native context implementation. |
| crates/rolldown_common/src/module/normal_module.rs | Removes asset_view from NormalModule. |
| crates/rolldown_common/src/lib.rs | Stops re-exporting removed asset-related types/mutations. |
| crates/rolldown_common/src/file_emitter.rs | Adds module_to_emitted_file mapping + accessors for new URL() finalization. |
| crates/rolldown_common/src/ecmascript/ecma_view.rs | Removes the old ImportMetaRolldownAssetReplacer mutation. |
| crates/rolldown_common/src/chunk/mod.rs | Removes per-chunk asset preliminary filename maps. |
| crates/rolldown_common/src/asset/mod.rs | Empties the old asset module (asset view removed). |
| crates/rolldown_common/src/asset/asset_view.rs | Deletes AssetView. |
| crates/rolldown_binding/src/options/plugin/binding_callable_builtin_plugin.rs | Updates load hook invocation to pass asserted_module_type: None. |
| crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap | Updates expected output filenames/hashes due to new asset pipeline. |
| crates/rolldown/tests/rolldown/topics/new_url/should_prefer_relative/artifacts.snap | Snapshot updates for new URL asset path rewriting. |
| crates/rolldown/tests/rolldown/topics/new_url/nested_dirs/artifacts.snap | Snapshot updates for new URL + chunk layout changes. |
| crates/rolldown/tests/rolldown/topics/new_url/binary_asset/artifacts.snap | Snapshot updates for binary asset emission via plugin. |
| crates/rolldown/tests/rolldown/function/module_types/issue-6345/artifacts.snap | Snapshot updates reflecting new CJS interop wrapping for assets. |
| crates/rolldown/tests/rolldown/function/module_types/asset/artifacts.snap | Snapshot updates for ./-prefixed relative paths and placeholder rewriting. |
| crates/rolldown/tests/esbuild/loader/loader_file_relative_path_js/artifacts.snap | Snapshot updates for relative path computation. |
| crates/rolldown/tests/esbuild/loader/loader_file_relative_path_asset_names_js/artifacts.snap | Snapshot updates for relative path computation with assetNames. |
| crates/rolldown/tests/esbuild/loader/loader_file_public_path_js/artifacts.snap | Snapshot updates for asset URL outputs. |
| crates/rolldown/tests/esbuild/loader/loader_file_public_path_asset_names_js/artifacts.snap | Snapshot updates for asset URL outputs with assetNames. |
| crates/rolldown/tests/esbuild/loader/loader_file_one_source_two_different_output_paths_js/artifacts.snap | Snapshot updates for shared asset emission naming/hash changes. |
| crates/rolldown/tests/esbuild/loader/loader_file_multiple_no_collision/artifacts.snap | Snapshot updates reflecting new emission/wrapping behavior. |
| crates/rolldown/tests/esbuild/loader/loader_file_ext_path_asset_names_js/artifacts.snap | Snapshot updates for path rewriting in nested output paths. |
| crates/rolldown/tests/esbuild/loader/loader_file_common_js_and_es6/artifacts.snap | Snapshot updates for mixed ESM/CJS interop behavior. |
| crates/rolldown/tests/esbuild/loader/loader_file/artifacts.snap | Snapshot updates for basic asset loader output. |
| crates/rolldown/src/utils/parse_to_ecma_ast.rs | Removes ModuleType::Asset preprocessing; errors if asset reaches AST parsing. |
| crates/rolldown/src/utils/load_source.rs | Passes asserted_module_type into load hook and errors when asset type isn’t handled by plugin. |
| crates/rolldown/src/utils/apply_inner_plugins.rs | Registers the new built-in asset module plugin. |
| crates/rolldown/src/stages/generate_stage/render_chunk_to_assets.rs | Removes asset chunk generation path. |
| crates/rolldown/src/stages/generate_stage/mod.rs | Removes asset filename patching pipeline and related imports. |
| crates/rolldown/src/module_loader/runtime_module_task.rs | Drops asset_view initialization. |
| crates/rolldown/src/module_loader/module_task.rs | Removes ModuleType::Asset → AssetView conversion; CSS error path remains. |
| crates/rolldown/src/module_finalizers/mod.rs | Switches new URL() finalization to use FileEmitter module→refId bridge. |
| crates/rolldown/src/asset/mod.rs | Removes now-unused asset module helpers. |
| crates/rolldown/src/asset/asset_generator.rs | Deletes old asset generator implementation. |
| crates/rolldown/Cargo.toml | Adds dependency on rolldown_plugin_asset_module. |
| Cargo.toml | Adds the new plugin crate to the workspace dependencies. |
| Cargo.lock | Locks the new crate into the dependency graph. |
Benchmarks Rust |
crates/rolldown/tests/esbuild/loader/loader_file_ext_path_asset_names_js/artifacts.snap
Outdated
Show resolved
Hide resolved
2202297 to
0c41e9c
Compare
|
I noticed the |
I'm updating design to cover this part, but it's expected. The plugin version so far can't use the The bottom line is that no runtime behavior change |
Yeah, |
0c41e9c to
8648d12
Compare
rolldown/meta/design/plugin-asset-module.md Lines 29 to 56 in 8648d12 |
Merge activity
|
8648d12 to
290a715
Compare
## [1.0.0-rc.8] - 2026-03-09 ### 🚀 Features - watch: enable full functional fs watcher in wasm (#8575) by @hyf0 - watch: expose debounce related options (#8572) by @hyf0 ### 🐛 Bug Fixes - detect new URL(…, import.meta.url) with no-sub template literal (#8565) by @char - devtools: trace dynamic imports in devtools (#8581) by @cal-gooo - watch: rebuild when a previously missing file is created (#8562) by @hyf0-agent - watch: filter out Access events to prevent infinite rebuild loop on Linux (#8557) by @hyf0-agent ### 🚜 Refactor - watch: remove auto watch for fail imports (#8585) by @hyf0 - fs_watcher: unify the way of constructing watcher (#8571) by @hyf0 - cli: migrate CLI to CAC (#8551) by @h-a-n-a - switch asset module support from hard-code to builtin plugin (#8546) by @hyf0 ### 📚 Documentation - fix subject-verb agreement in why-bundlers.md (#8591) by @brandonzylstra - maintenance: align release and canary workflow guide (#8538) by @minsoo-web - add `format` option to directives example config (#8590) by @shulaoda - fix: change twitter to x logo in team (#8552) by @mdong1909 - correct composable filter support explanation (#8550) by @sapphi-red ### ⚡ Performance - testing: share tokio runtime across fixture tests (#8567) by @Boshen ### 🧪 Testing - hmr: fix infinite loop in dev server test retry logic (#8576) by @hyf0-agent - cli: add more cli-e2e test cases (#8548) by @h-a-n-a ### ⚙️ Miscellaneous Tasks - docs: update in-depth/directives for `output.strict` option (#8535) by @minsoo-web - add PNPM_HOME Dev Drive mapping to Windows CI workflows (#8589) by @Boshen - deps: update github-actions (#8588) by @renovate[bot] - move Windows cargo target dir to Dev Drive (#8586) by @Boshen - optimize cache keys to fix race conditions and reduce usage (#8578) by @Boshen - remove WASI build & test pipeline (#8580) by @Boshen - remove unnecessary submodule checkouts (#8577) by @Boshen - use Dev Drive for Windows CI jobs (#8574) by @Boshen - skip redundant native binding build for browser and remove standalone job (#8573) by @Boshen - parallelize Node tests on ubuntu, single Node 24 on macOS/windows (#8570) by @Boshen - docs: bump @voidzero-dev/vitepress-theme to 4.8.0 (#8558) by @crusty-voidzero - dedupe type-check from dev server workflow (#8554) by @Boshen ### ❤️ New Contributors * @brandonzylstra made their first contribution in [#8591](#8591) * @char made their first contribution in [#8565](#8565) * @cal-gooo made their first contribution in [#8581](#8581) * @hyf0-agent made their first contribution in [#8562](#8562) * @h-a-n-a made their first contribution in [#8551](#8551) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>

No description provided.