Skip to content

feat: implement compilation.hooks.assetPath#13653

Open
yashwanth195 wants to merge 3 commits intoweb-infra-dev:mainfrom
yashwanth195:user/yashwanth195/asset-path-hook
Open

feat: implement compilation.hooks.assetPath#13653
yashwanth195 wants to merge 3 commits intoweb-infra-dev:mainfrom
yashwanth195:user/yashwanth195/asset-path-hook

Conversation

@yashwanth195
Copy link
Copy Markdown

Summary

Implements compilation.hooks.assetPath — a waterfall hook that allows plugins to intercept and transform output asset paths at resolution time, matching webpack's SyncWaterfallHook API.

Related links

Closes #13637

https://webpack.js.org/api/compilation-hooks/#assetpath

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@yashwanth195 yashwanth195 requested a review from hardfist as a code owner April 8, 2026 18:44
Copilot AI review requested due to automatic review settings April 8, 2026 18:44
@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JS Compilation wrapper and register it through the JS tap bridge.
  • Call the new asset_path hook 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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will degrade performance by 8.29%

⚡ 3 improved benchmarks
❌ 3 regressed benchmarks
✅ 13 untouched benchmarks
⏩ 19 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_module_hashes 21.4 ms 21.9 ms -2.25%
Simulation rust@build_chunk_graph 102.5 ms 111.7 ms -8.29%
Simulation rust@concatenate_module_code_generation 138.6 ms 137 ms +1.22%
Simulation rust@persistent_cache_restore_after_single_file_change@basic-react-development 27.9 ms 27.3 ms +2.14%
Simulation rust@create_concatenate_module 42.1 ms 42.6 ms -1.18%
Simulation rust@persistent_cache_restore@basic-react-development 26.8 ms 25.8 ms +3.75%

Comparing yashwanth195:user/yashwanth195/asset-path-hook (9a85d99) with main (5f6b5b2)2

Open in CodSpeed

Footnotes

  1. 19 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 (c868dd7) during the generation of this report, so 5f6b5b2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@hardfist hardfist self-assigned this Apr 14, 2026
@hardfist
Copy link
Copy Markdown
Contributor

hardfist commented Apr 14, 2026

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold release: feature release: feature related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add compilation.hooks.assetPath

3 participants