Skip to content

fix: coerce chunk ids to string before comparison#1035

Open
panbenson wants to merge 1 commit into
gregberge:mainfrom
panbenson:fix-numeric-chunk-ids
Open

fix: coerce chunk ids to string before comparison#1035
panbenson wants to merge 1 commit into
gregberge:mainfrom
panbenson:fix-numeric-chunk-ids

Conversation

@panbenson
Copy link
Copy Markdown

Summary

Upon bumping to Rspack V2, projects using loadable become unresponsive/stuck in loading. Rspack V2 switched to numeric chunk ids in production by default, which is being documented on the migration guide in web-infra-dev/rspack#13839

Numeric chunk ids cause strict equality (===) comparisons in ChunkExtractor and loadableReady to silently fail against string values. This PR proposes fixing it by coercing all chunk IDs to strings with String() before comparison.

Test plan

Added unit tests for changes, I've also verified manually by applying the diff to my project as well.

Webpack can assign numeric chunk ids, which causes strict equality
checks to fail when compared against string values. Coerce all chunk
id values with String() before comparison in ChunkExtractor and
loadableReady.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@panbenson
Copy link
Copy Markdown
Author

@theKashey could you please take a look at this?

@tim-soft
Copy link
Copy Markdown

The workaround is to set the rspack config setting config.optimization.chunkIds: 'named' which bloats bundles, this would be great to support when you get a moment to review @theKashey

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