fix: de-optimize route chunks with shared exported declarations - #15336
Open
comp615 wants to merge 2 commits into
Open
fix: de-optimize route chunks with shared exported declarations#15336comp615 wants to merge 2 commits into
comp615 wants to merge 2 commits into
Conversation
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.
Fixes #15335.
Problem
Route chunk dependency analysis follows references into exported function and class declarations, but previously excluded those declarations from shared-statement detection. Chunk generation then removed a sibling exported declaration whose name did not match the target export, leaving a dangling runtime reference in the emitted chunk.
This affects current main and the v8.2.0 release.
Fix
Treat exported function and class declarations as atomic top-level dependencies. When they are shared by route exports:
splitRouteModules: "enforce"fails the build with the existing guidance to extract shared code into another module.The generation path remains unchanged, avoiding duplicated class identity, static state, and module-local state across chunks. Independent exported declarations remain chunkable.
The first commit contains the failing runtime reproduction. The second moves that coverage into the split-route-module integration suite and applies the fix.
Tests
pnpm test route-chunks-test --runInBandpnpm buildpnpm test:integration:run split-route-modules --project chromiumpnpm typecheckpnpm changes:validatepnpm lint(passes with six existing warnings)🤖 This pull request and its implementation were prepared with AI assistance.