Repository navigation
fix(router-plugin): compute shared bindings when the reference module was not compiled in this process - #9023
schiller-manuel wants to merge 3 commits into
Conversation
… was not compiled in this process The split and shared transforms read a route file's shared bindings from a map that only the reference transform filled. A tool with a persistent transform cache (Vitest 5's fsModuleCache) can restore the compiled reference module from disk without running that transform, so the map had no entry: the split chunk declared its own copy of a shared binding instead of importing it from `?tsr-shared=1`, and the shared transform returned null. The map is now a memo. One function resolves the split groupings (in the file, else `splitBehavior` for the route id, else the default behavior), computes the shared bindings and stores them, an empty set when there are none. The reference transform always calls it; the split and shared transforms call it when the map has no entry for the file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ot compiled Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 4c04102 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
View your CI Pipeline Execution ↗ for commit 4c04102
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview1 package(s) bumped directly, 6 bumped as dependents. 🟩 Patch bumps
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Bundle Size BenchmarksThis pull request does not affect bundle size in any measured scenario. |
Merging this PR will improve performance by 3.94%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
…s asked `resolveSharedBindings` reads the route of a file itself, so its callers no longer pass a route id that may be missing. The reference compile gets the set as it is, as the split compile does. The tests are one table. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…uleCache and renders through the route's lazy component No private split query: the second run loads the chunk as an app's test does. Fails on main without #9023 ({ html: '<p>0</p>', stores: 2 }). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🎯 Changes
A split route chunk could get its own copy of a binding it shares with the route module.
sharedBindingsMapwas filled only by the reference transform. Thetsr-splitandtsr-sharedtransforms only read it. Vitest 5 restores a compiled module from its module cache (fsModuleCache, on by default) without running the transform, so in that process the map has no entry. A chunk compiled then (an earlier run imported the route file, a later one renders the route) came out asinstead of importing
visitsfromposts.tsx?tsr-shared=1, and thetsr-sharedtransform returnednull.splitBehaviorfor the route id, else the default) and computes the shared bindings. The reference transform always calls it. The other two call it when the map has no entry for the file.Tests in
code-splitter-plugin-pipeline.test.tsrun thetsr-splitandtsr-sharedtransforms on a fresh splitter without the reference transform, for each source of groupings, and compare the result with what the same splitter emits after it. The cases with a shared binding fail without the fix.Not tested against a real Vitest run with a warm cache; the tests drive the plugin's transform hooks. Found while reviewing #8965, which changes the same file, so the second of the two to merge needs a rebase.
Tested locally:
test:unit,test:typesandtest:eslintof router-plugin,test:unitof start-plugin-core.✅ Checklist
🚀 Release Impact
🤖 Generated with Claude Code
Summary by CodeRabbit