Repository navigation
perf(core): optimize asset filename enumeration - #1980
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the asset filename enumeration optimization.
No open issues 🎉
What changed in this PR
Optimizes asset filename enumeration in Rslib’s core processing by using Rspack’s internal filename API instead of enumerating the assets Proxy.
Changes:
- Adds a shared
getAssetNames()helper that reads current filenames on each call. - Applies the helper to four CSS, SVGR, and shim processing paths, avoiding Proxy enumeration overhead.
| File | Description |
|---|---|
packages/core/src/utils/compilation.ts |
Adds the shared asset filename helper. |
packages/core/src/plugins/ChunkAssetPlugin.ts |
Uses the helper to select JavaScript assets for shim processing. |
packages/core/src/css/LibCssExtractPlugin.ts |
Uses the helper to select CSS assets for public-path replacement. |
packages/core/src/css/cssConfig.ts |
Uses the helper when removing temporary CSS entry assets. |
packages/core/src/asset/LibSvgrPatchPlugin.ts |
Uses the helper to select JavaScript assets for SVGR patching. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Enumerating
compilation.assetswithObject.keys()adds Proxy key validation and per-asset descriptor lookups when only filenames are needed. Apply the optimization from web-infra-dev/rsbuild#8741 to Rslib's asset processing.Changes
Add a shared
getAssetNames()helper using Rspack's__internal__getAssetFilenames()and use it in four CSS, SVGR, and shim processing paths. The current Rspack dependency already provides this API; filenames are read fresh on each call.A local benchmark on Node.js 25.9.0/macOS with Rspack 2.3.0-beta.0 reduced median enumeration time for 10,000 assets from 1.80 ms to 0.51 ms (72%). This measures enumeration only, not overall build performance. Asset lists also matched before and after emitting/deleting assets.
Validated with the core build (including Publint), 66 related integration tests, and
pnpm run check(lint, type checking, and formatting).