Repository navigation
fix(next-plugin): reserve shared class slots before next dev extracts - #939
Merged
Merged
Conversation
File numbers are seeded in path order, but a class that several files share still took the next free slot of whichever file Turbopack extracted first. next dev skips the sorted production prewarm and the coordinator extracts in request order, so the same project could get different class names on each start. Under next dev the Turbopack setup now reserves every shared slot with createSharedSlotReservation before the coordinator starts, scanning src, app and pages plus included packages with the coordinator's own filenames and CSS directories, as the webpack, Rsbuild and Vite plugins already do. One-shot builds keep relying on the prewarm, which extracts in path order. A failing reservation falls back to arrival order like the file-number seed. Refs #694 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
8 of 17 tasks
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve the conflict with #938 in packages/next-plugin/src/coordinator.ts. #938 adds no new module state: its error-returning waitForBase and waitForBucket, missingFiles and incompleteCssError now read the app's own CoordinatorState, so one app's extractions never complete another app's CSS. A test covers two apps expecting the same base files. #939's shared-slot reservation runs on the app's own engine session; its test now expects that session instead of the shared engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes audit item NXT-01 (P1, NONDET). On main, file numbers are already seeded in path order (
seedFileNumbers), but a class slot shared by several files still gets the next free slot of the file that extracted that class first.next devskips the sorted production prewarm and the coordinator extracts in the order Turbopack requests arrive, so class names could differ on every start, even for the same project.next dev(Turbopack), shared slots are reserved in path order withcreateSharedSlotReservation(wasm).reserve(...)before the coordinator starts. This is the same engine API the webpack / Rsbuild / Vite plugins already use.src,app,pages, andincludepackages (the same roots as the file number seed)./<relative>form as the coordinator, andimportMainCssInCode=false,importMainCssInCss=truematch the coordinator's extraction options.next build) still extract in path order via the prewarm, so no reservation is added there (to avoid one more extraction pass).atomHoistwarning text, which is no longer true.Overlap with other PRs
fix/next-turbo-setup), fix(plugins): fail production builds on theme errors instead of an empty theme #924, and fix(plugins): compile modern modules, resolve bundler conditions and hoist over every source root #934 modify the Turbopack setup area ofplugin.ts. This PR adds one block right afterseedFileNumbersplus one helper, so textual conflicts with those PRs may occur nearby. In particular, if fix(next-plugin): honor debug, restore session state whole and warn on setup fallbacks #918 adds a warning to the setup fallback, this reservation'scatchshould be aligned the same way.source-roots), this reservation'srootscan be aligned to use its result.Test plan
bun test --coverage src/__tests__/plugin.test.ts:plugin.ts100% lines / functionsbunx tsc --noEmit -p packages/next-pluginbunx prettier --single-quote --no-semi --check(changed files)plugin.test.ts(native engine /seedFileMap) fail the same way on main too, because of stale WASM / native builds.요약
감사 항목 NXT-01 (P1, NONDET) 수정입니다. main에서 파일 번호는 이미 경로 순서로 seed되지만 (
seedFileNumbers), 여러 파일이 공유하는 class slot은 여전히 그 클래스를 먼저 추출한 파일의 다음 빈 slot을 받습니다.next dev는 정렬된 프로덕션 prewarm을 건너뛰고 코디네이터가 Turbopack 요청 도착 순서대로 추출하므로, 같은 프로젝트라도 시작할 때마다 클래스 이름이 달라질 수 있었습니다.next dev(Turbopack)에서 코디네이터를 시작하기 전에createSharedSlotReservation(wasm).reserve(...)로 공유 slot을 경로 순서대로 미리 예약합니다. webpack / Rsbuild / Vite 플러그인이 이미 쓰는 것과 같은 엔진 API입니다.src,app,pages와include패키지 (파일 번호 seed와 같은 루트)./<relative>형식이고,importMainCssInCode=false,importMainCssInCss=true로 코디네이터 추출 옵션과 일치시켰습니다.next build)는 기존처럼 prewarm이 경로 순서로 추출하므로 예약을 추가하지 않았습니다 (추출이 한 번 더 늘어나는 것을 피하기 위해).atomHoist경고 문구에서 더 이상 사실이 아닌 "existing shared slots remain arrival-ordered" 부분을 지웠습니다.다른 PR과의 겹침
fix/next-turbo-setup), fix(plugins): fail production builds on theme errors instead of an empty theme #924, #934가plugin.ts의 Turbopack setup 영역을 수정합니다. 이 PR은seedFileNumbers바로 뒤에 블록 하나와 helper 하나를 추가하므로 해당 PR들과 근접한 위치에서 텍스트 충돌이 날 수 있습니다. 특히 #918이 setup fallback에 경고를 추가한다면, 이 예약의catch도 같은 방식으로 맞추는 것이 좋습니다.source-roots)을 공통화하면 이 예약의roots도 그 결과를 쓰도록 맞출 수 있습니다.테스트 계획
bun test --coverage src/__tests__/plugin.test.ts:plugin.ts100% lines / functionsbunx tsc --noEmit -p packages/next-pluginbunx prettier --single-quote --no-semi --check(변경 파일)plugin.test.ts의 3개 테스트(native 엔진 /seedFileMap)는 오래된 WASM / native 빌드 때문에 main에서도 동일하게 실패합니다.Refs #694
🤖 Generated with Claude Code