Skip to content

perf(core): optimize asset filename enumeration - #1980

Merged
Timeless0911 merged 1 commit into
mainfrom
david/perf-asset-enumeration
Oct 29, 2026
Merged

Timeless0911 merged 1 commit into
mainfrom
david/perf-asset-enumeration

Conversation

@Timeless0911

Copy link
Copy Markdown
Contributor

Motivation

Enumerating compilation.assets with Object.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).

Copilot AI balanced review requested due to automatic review settings October 29, 2026 07:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T07:16:53.801738Z 8aa84aa PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

🟢 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

@Timeless0911
Timeless0911 merged commit 4486901 into main Oct 29, 2026
12 checks passed
@Timeless0911
Timeless0911 deleted the david/perf-asset-enumeration branch October 29, 2026 07:23
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.

2 participants