Repository navigation
Compare React Compiler output, not Vite's import analysis, in cache tests - #8420
Merged
ymichael merged 1 commit intoNov 30, 2026
Conversation
…ests Vite resolves a module's imports in parallel and prepends each CJS interop assignment as its resolution finishes, so the final transformRequest code can order those lines differently between two servers. The cross-server cache tests now capture the compiler plugin's own output with a pre-transform probe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/fix-react-compiler-cache-test-flake-on-windows-thr_e7adxibbz9
branch
November 30, 2026 23:32
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
…ests (get-bb#8420) ## Human comments ## What was wrong The two cross-server React Compiler cache tests (from get-bb#8227) compared the full `server.transformRequest` result, which includes the rewrites from Vite's import analysis. That step resolves a module's imports in parallel inside `Promise.all` (`vite/dist/node/chunks/node.js`, `interopNamedImports`). For each CJS-interop dependency it calls `str.appendLeft(fileStart, hoistedAssignments)` when that dependency's resolution finishes. On Windows the `react/compiler-runtime` and `react/jsx-dev-runtime` resolutions sometimes finish in a different order, so the prepended lines come out swapped. The cached compiler output is the same in both runs. From the failed Windows (app-4) job: ``` - ...component.tsx");const _jsxDEV = __vite__cjsImport1_react_jsxDevRuntime["jsxDEV"];const _c = __vite__cjsImport0_react_compilerRuntime["c"];import ... + ...component.tsx");const _c = __vite__cjsImport0_react_compilerRuntime["c"];const _jsxDEV = __vite__cjsImport1_react_jsxDevRuntime["jsxDEV"];import ... ``` The two lines just swap places. Their import indices stay the same, so this is ordering in Vite, not a cache or path-separator problem. ## What changed `apps/app/src/test/react-compiler-cache.test.ts`: the cross-server tests add a `pre` probe plugin right after the compiler plugin. The probe records the code the compiler (or the cache) returned for the input module, and the tests compare that code instead of Vite's final output. The probe matches on `normalizePath(input)` so it also works with Windows ids. Production code is unchanged. ## How you verified - `pnpm exec turbo run test --filter=@bb/app -- src/test/react-compiler-cache.test.ts`: 6/6 pass. - To check the probe still catches cache bugs, I temporarily made cache hits return `code + ';'`. Both cross-server tests failed, and passed again once the change was reverted. - `pnpm exec turbo run typecheck --filter=@bb/app` passes. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
The two cross-server React Compiler cache tests (from #8227) compared the full
server.transformRequestresult, which includes the rewrites from Vite's import analysis. That step resolves a module's imports in parallel insidePromise.all(vite/dist/node/chunks/node.js,interopNamedImports). For each CJS-interop dependency it callsstr.appendLeft(fileStart, hoistedAssignments)when that dependency's resolution finishes. On Windows thereact/compiler-runtimeandreact/jsx-dev-runtimeresolutions sometimes finish in a different order, so the prepended lines come out swapped. The cached compiler output is the same in both runs. From the failed Windows (app-4) job:The two lines just swap places. Their import indices stay the same, so this is ordering in Vite, not a cache or path-separator problem.
What changed
apps/app/src/test/react-compiler-cache.test.ts: the cross-server tests add apreprobe plugin right after the compiler plugin. The probe records the code the compiler (or the cache) returned for the input module, and the tests compare that code instead of Vite's final output. The probe matches onnormalizePath(input)so it also works with Windows ids. Production code is unchanged.How you verified
pnpm exec turbo run test --filter=@bb/app -- src/test/react-compiler-cache.test.ts: 6/6 pass.code + ';'. Both cross-server tests failed, and passed again once the change was reverted.pnpm exec turbo run typecheck --filter=@bb/apppasses.🤖 Generated with Claude Code