Skip to content

perf(build): Use deterministic chunk/module IDs in production#109631

Draft
scttcper wants to merge 1 commit intomasterfrom
scttcper/rspack-deterministic-ids
Draft

perf(build): Use deterministic chunk/module IDs in production#109631
scttcper wants to merge 1 commit intomasterfrom
scttcper/rspack-deterministic-ids

Conversation

@scttcper
Copy link
Member

Use deterministic chunk and module IDs for production rspack builds

chunkIds and moduleIds were hardcoded to 'named' unconditionally, which overrides rspack's production defaults. In production, 'named' IDs are derived from file paths — this leaks internal path structure in bundles and, more importantly, causes cache invalidation whenever unrelated modules are added or removed (because insertion order affects IDs).

Switching to 'deterministic' in production gives short, stable numeric hashes that don't change unless the module itself changes, which improves long-term browser cache hit rates. 'named' is kept in development for readable chunk names during debugging.

Previously both chunkIds and moduleIds were hardcoded to 'named',
which overrode rspack's production default. In production, 'named'
embeds file paths in the bundle and generates unstable IDs that
invalidate browser caches when unrelated modules are added or removed.

Switch to 'deterministic' in production (short stable hashes) while
keeping 'named' in development for readable chunk names during debugging.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant