feat: implement compilation.hooks.assetPath#13653
feat: implement compilation.hooks.assetPath#13653yashwanth195 wants to merge 3 commits intoweb-infra-dev:mainfrom
Conversation
dc2dcad to
d0f2d82
Compare
There was a problem hiding this comment.
Pull request overview
Implements a new compilation.hooks.assetPath hook intended to let plugins transform resolved asset output paths during filename/path rendering (webpack SyncWaterfallHook-style), wiring it through the Rust core compilation path rendering and the JS hooks adapter layer.
Changes:
- Add
Compilation.hooks.assetPath(SyncWaterfallHook) on the JSCompilationwrapper and register it through the JS tap bridge. - Call the new
asset_pathhook from Rust compilation path rendering helpers (get_path*/get_asset_path*). - Add JS and Rust tests covering basic invocation/return-value behavior and some PathData rendering cases.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/compilerCases/hooks-asset-path.js | Adds compiler case tests for compilation.hooks.assetPath. |
| packages/rspack/src/taps/compilation.ts | Registers JS tap bridge for the new compilation assetPath hook. |
| packages/rspack/src/Compilation.ts | Exposes compilation.hooks.assetPath as a JS SyncWaterfallHook. |
| crates/rspack_core/src/options/filename.rs | Adds Rust unit tests around template rendering / placeholder detection (related to path data). |
| crates/rspack_core/src/compilation/mod.rs | Calls the new asset_path hook after filename rendering in multiple helpers. |
| crates/rspack_binding_api/src/plugins/js_hooks_plugin.rs | Wires the new hook into the JS hooks adapter plugin intercept pipeline. |
| crates/rspack_binding_api/src/plugins/interceptor.rs | Adds the binding-layer hook kind/register and the JsAssetPathData object passed to JS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc2dcad08b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Merging this PR will degrade performance by 8.29%
Performance Changes
Comparing Footnotes
|
|
@yashwanth195 thanks for contribution, but this hook will cause deadlock issue in Rspack, related to #3642, you can try to call compilation.getPath in your test case and see whether it will cause deadlock |
Summary
Implements
compilation.hooks.assetPath— a waterfall hook that allows plugins to intercept and transform output asset paths at resolution time, matching webpack'sSyncWaterfallHookAPI.Related links
Closes #13637
https://webpack.js.org/api/compilation-hooks/#assetpath
Checklist