Skip to content

fix: de-optimize route chunks with shared exported declarations - #15336

Open
comp615 wants to merge 2 commits into
remix-run:mainfrom
comp615:bug/split-route-export-dependency
Open

fix: de-optimize route chunks with shared exported declarations#15336
comp615 wants to merge 2 commits into
remix-run:mainfrom
comp615:bug/split-route-export-dependency

Conversation

@comp615

@comp615 comp615 commented Jul 20, 2026

Copy link
Copy Markdown

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:

  • default route splitting de-optimizes the affected export and keeps the route module intact;
  • 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 --runInBand
  • pnpm build
  • pnpm test:integration:run split-route-modules --project chromium
  • pnpm typecheck
  • pnpm changes:validate
  • pnpm lint (passes with six existing warnings)

🤖 This pull request and its implementation were prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: split route modules drop exported clientLoader dependencies

2 participants