Repository navigation
Conversation
…bals Two apps in one process shared the single process-wide engine state. Gather the persistent state into values that can be exchanged with the live globals: - css::engine_state::CssState holds the prefix, debug flag, atom hoist threshold and plan, slot reservation, class map, file map, canonical map, file routes, custom shorthands, theme tokens and Tailwind definitions. css::test_state::TestStateGuard is now built on it. - extractor::ExtractorCaches holds the vanilla-extract imported runs and stripped TypeScript of the calling thread. - devup_ui_binding_core::session keeps session 0 live from the start and parks every other session's EngineState (CSS state + stylesheet). select_session swaps a parked state with the live globals, with_session runs a closure under the session lock and swaps back, also on unwind. Extractor caches are parked per thread and aligned on every switch, since they hold Rc values and session file numbers. - PerSession<T> keys host values by the live session; the WASM and native module resolvers use it. Existing call sites read the globals unchanged; until a host creates a session the engine behaves as before. Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the engine session calls to the WASM and native engines: - createSession() returns the id of a new session with a clean state - selectSession(id) makes it live; every later call works on its state - dropSession(id) drops it with its module resolver, returning whether it existed; dropping the live session makes session 0 live The shared argument boundary checks the id as an unsigned 32-bit integer before engine entry. The ABI grows from 29 to 32 names: the WASM glue check, the native adapter and typings, the e2e ABI list, the validation positions (47 in 20 functions, 283 invalid-input cases) and a parity corpus scenario follow it. Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hape Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
openCompilerSession(compiler) creates an engine session on a shared
compiler and returns { id, compiler, close }. Every function read from
the scoped compiler selects the session before it runs; the calls are
synchronous and JavaScript is single-threaded, so no other session's
call can run between the selection and the call. close() drops the
session, after which calls through the scoped compiler throw.
Refs #686
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Turbopack coordinator was a module-level singleton: starting a second app in the same process closed the first app's listener, and both apps shared one engine state. Coordinators are now kept in a registry keyed by the resolved distDir: - openCoordinatorCompiler(distDir, compiler) opens the app's own engine session (with the module resolver) on first use; the plugin runs its setup through it and hands it to the coordinator - startCoordinator replaces only the previous coordinator of the same app and takes a reference; each coordinator keeps its extraction tracking in a state of its own - close() is idempotent and releases the reference; the last close drops the app's session and its registry entry - moving an app to another engine opens a new session there Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 tasks done
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This was referenced Nov 15, 2026
Keep main's check_resolved_path/resolved_module re-exports beside the session re-exports in libs/binding. removeFile (#951) only touches the file map, canonical map, class map and global sheet, which CssState and EngineState already swap per session; a new session test pins that forgetting a file in one session leaves another session's styles alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in main through #963, including removeFile (#951). The ABI now holds 33 names: main's 30 plus createSession, selectSession and dropSession. Updated script.js, the native typings and README, the e2e ABI list and consumer, and compiler-types (32 without Output). Validation covers 48 positions in 21 functions (288 cases), and the summary reports 21 functions. The corpus keeps both new scenarios and adds remove-file-stays-in-its-session, which checks that removeFile only forgets the file in the live session (28 scenarios). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No conflicts. openCompilerSession wraps every compiler function in a Proxy that selects the session first, so removeFile from main (#951) runs on the scoped session like every other call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's coordinator (#951) tracked deleted sources in a module-level extractedSources map, while this branch moved all extraction tracking into each app's CoordinatorState. extractedSources now lives in that state too, so each app forgets only its own deleted files. removeFile is read from the session-scoped compiler the plugin hands over, so it runs on the app's own engine session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
extractor/lib.rs keeps both this branch's ExtractorCaches export and main's vanilla_extract_theme_import_tests module. Main added no binding exports since the last merge, so the counts stay: 33 ABI names, 21 validated functions with 48 positions and 288 cases, and 28 parity scenarios. #967's serialization cache needs no session state: a session switch swaps the sheet through a tracked mutable borrow, which forgets the cached serializations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coordinator.ts: main's Turbopack theme reload (#944) kept its watch in module globals; it now lives in each app's CoordinatorState, created from options.theme, and refreshTheme(state) runs before each /css and /extract of that app. The reload registers the theme through the app's session compiler, so one app's devup.json never reaches another's engine. close() writes the pending files synchronously (#917) before releasing the app, and resetCoordinator keeps clearing the registry instead of the removed globals. extractor/lib.rs keeps both the ExtractorCaches export and vanilla_extract_theme_import_tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict with #946 in packages/next-plugin/src/coordinator.ts. The transform cache becomes per app: it lives in each app's CoordinatorState next to extractedSources, a theme refresh clears only that app's cache, and a removed source drops only the owning app's entry. themeStamp is replaced by #946's fileStamp. Adds a test that two apps never share cached extractions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
NXT-07 step 4: turns the Next plugin's Turbopack coordinator into a per-app registry.
Previous problem
startCoordinator, the first app's listener was closed.Changes
distDir(absolute path, lowercased on Windows).openCoordinatorCompiler(distDir, compiler): on the first call, opens an engine session for that app alone. The session isopenCompilerSessionfrom feat(plugin-utils): add openCompilerSession for per-app engine state #965 with a module resolver attached.engineoption changed), the previous session is dropped and a session is opened on the new engine.startCoordinator({ distDir, ... })extractedFiles, bucket maps, wait timing) is kept per coordinator.close()is safe to call more than once. Each call drops one reference, and the last close drops the app's session and removes its registry entry.safeWrite) is keyed by path, so it stays global.Expected conflicts
css-loader.ts,loader.ts,coordinator-client.ts. No files overlap with this PR, but both deal with the coordinator lifecycle, so behavior must be rechecked after rebasing.plugin.ts,plugin.test.ts,coordinator-port.ts. Text conflicts are expected in the setup section and thestartCoordinatorcall site ofplugin.ts, and in thestartCoordinatorexpectations (distDir,wasm) inplugin.test.ts.distDir, and fix(next-plugin): keep coordinator state per process on a shared distDir #941 introduces a per-process state directory. When merging both, keepingdistDiras the registry key is recommended.Test plan
bun test packages/next-plugin/src/__tests__/*.test.ts: 18 files, 213 passcoordinator.ts,plugin.ts(rancoordinator.test.tsandplugin.test.tswith--coverage)distDirvalues normalize to the same key. Prefixes do not mix between the two apps.bunx tsc --noEmit(next-plugin),bunx prettier --check(code files). The README already has prettier warnings on main too.요약
NXT-07 4단계: Next 플러그인의 Turbopack coordinator를 앱별 registry로 바꿉니다.
기존 문제
startCoordinator를 부르면 첫 번째 앱의 listener가 닫혔습니다.변경 내용
distDir(절대 경로, Windows에서는 소문자)를 키로 registry를 둡니다.openCoordinatorCompiler(distDir, compiler): 처음 호출될 때 그 앱만의 엔진 세션을 엽니다. 세션은 #965의openCompilerSession위에 모듈 resolver를 함께 붙입니다.engine옵션 변경) 이전 세션을 버리고 새 엔진에서 세션을 엽니다.startCoordinator({ distDir, ... })extractedFiles, bucket 맵, 대기 타이밍)를 coordinator마다 따로 둡니다.close()는 여러 번 불러도 안전합니다. 호출할 때마다 참조를 하나 줄이고, 마지막 close에서 앱의 세션을 버리고 registry 항목을 지웁니다.safeWrite)는 경로를 키로 하므로 계속 전역에 둡니다.충돌 예상
css-loader.ts,loader.ts,coordinator-client.ts를 고칩니다. 이 PR과 같은 파일은 없지만 둘 다 coordinator 수명 주기를 다루므로, 리베이스한 뒤 동작을 다시 확인해야 합니다.plugin.ts,plugin.test.ts,coordinator-port.ts를 고칩니다.plugin.ts의 setup 구간과startCoordinator호출부, 그리고plugin.test.ts의startCoordinator기대값(distDir,wasm)에서 텍스트 충돌이 예상됩니다.distDir이고, #941은 프로세스별 상태 디렉터리를 도입합니다. 함께 머지할 때는 registry 키를distDir로 유지하는 것을 권합니다.테스트 계획
bun test packages/next-plugin/src/__tests__/*.test.ts: 18개 파일, 213개 통과coordinator.ts,plugin.ts커버리지 100% (coordinator.test.ts와plugin.test.ts를--coverage로 실행)distDir을 다르게 써도 같은 키로 정규화됩니다. prefix가 두 앱 사이에 섞이지 않습니다.bunx tsc --noEmit(next-plugin),bunx prettier --check(코드 파일). README는 main에서도 이미 prettier 경고가 있는 파일입니다.Refs #686
🤖 Generated with Claude Code