Skip to content

fix(next-plugin): honor debug, restore session state whole and warn on setup fallbacks - #918

Merged
owjs3901 merged 1 commit into
mainfrom
fix/next-turbo-setup
Nov 17, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/next-turbo-setup

Conversation

@owjs3901

@owjs3901 owjs3901 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes NXT-10, NXT-14, and NXT-18 from #686. All are in the Next.js Turbopack setup stage (plugin.ts).

  • NXT-10: the Turbopack path did not read the debug option and did not call setDebug. Unlike the webpack path, debug: true was ignored. It is now set on the engine and also included in the production config cache key.
  • NXT-14: on dev restart, the sheet, class map, and file map were imported one after another inside a single try. If a later file was missing or corrupt, a state with only the earlier files imported was left behind, and new styles could get names that collide with restored names.
    • Now all three files are read and parsed before anything is imported (restoreSessionState).
    • If the import itself fails (state written by a different release), it is discarded with resetBuildState() and starts fresh.
    • prefix and debug are set after the restore, so they are kept even if the state is discarded.
  • NXT-18: if building the import graph or scanning file numbers failed, it moved on silently. The build succeeded, but class merging was missing, CSS completion was judged by idleness, or file numbers followed arrival order. Now the cause and what the build loses are printed as a warning.

Remaining

  • The write side of NXT-14 (generation directories + atomic swap) was not done. A case where all three files are readable but were written at different times still cannot be detected.
  • For NXT-18, failing the production build was not chosen. It would make builds that used to succeed fail, so it is left as a warning.
  • Does not overlap with fix(plugin-core): align bundler resolution, roots and WASM diagnostics #755.

New errors

None. New warnings:

  • [devup-ui] Turbopack import graph failed: <cause>. Classes are not merged across files only one module imports, and the production stylesheet waits for extraction to go quiet instead of for every compiled file.
  • [devup-ui] Turbopack file numbering failed: <cause>. Stylesheet file numbers follow the order Turbopack compiles files in, so they can differ between builds of the same source.

Test plan

  • plugin.test.ts: setDebug calls for the default and debug: true, the warning text for import graph and number scan failures, restoreSessionState (one file missing / one corrupt / import fails → resetBuildState). 100% coverage for plugin.ts
  • @typescript/native tsc passes
  • Full CI and coverage

요약

#686의 NXT-10, NXT-14, NXT-18을 고칩니다. 모두 Next.js Turbopack 설정 단계(plugin.ts)입니다.

  • NXT-10: Turbopack 경로가 debug 옵션을 읽지 않았고 setDebug도 부르지 않았습니다. webpack 경로와 달리 debug: true가 무시됐습니다. 이제 엔진에 설정하고, 프로덕션 설정 캐시 키에도 넣습니다.
  • NXT-14: dev 재시작 때 sheet, class map, file map을 하나의 try 안에서 차례로 import했습니다. 뒤 파일이 없거나 깨지면 앞 파일만 들어간 상태가 남아, 새 스타일이 복원된 이름과 겹치는 이름을 받을 수 있었습니다.
    • 이제 세 파일을 모두 읽고 파싱한 뒤에야 import합니다(restoreSessionState).
    • import 자체가 실패하면(다른 릴리스가 쓴 상태) resetBuildState()로 버리고 새로 시작합니다.
    • prefix와 debug는 복원 뒤에 설정해서, 상태를 버려도 유지됩니다.
  • NXT-18: import graph 구성이나 파일 번호 스캔이 실패하면 아무 말 없이 넘어갔습니다. 빌드는 성공하지만 class 병합이 빠지거나, CSS 완료를 idle로 판단하거나, 파일 번호가 도착 순서가 됐습니다. 이제 원인과 빌드가 잃는 것을 경고로 출력합니다.

남은 것

  • NXT-14의 쓰기 쪽(세대 디렉터리 + 원자적 교체)은 하지 않았습니다. 세 파일이 모두 읽히지만 서로 다른 시점에 쓰인 경우는 아직 알아낼 수 없습니다.
  • NXT-18에서 프로덕션 빌드를 실패시키는 쪽은 택하지 않았습니다. 지금까지 성공하던 빌드가 실패하게 되므로 경고로 두었습니다.
  • #755와 겹치지 않습니다.

새로 생기는 오류

없음. 새 경고:

  • [devup-ui] Turbopack import graph failed: <cause>. Classes are not merged across files only one module imports, and the production stylesheet waits for extraction to go quiet instead of for every compiled file.
  • [devup-ui] Turbopack file numbering failed: <cause>. Stylesheet file numbers follow the order Turbopack compiles files in, so they can differ between builds of the same source.

테스트 계획

  • plugin.test.ts: 기본값·debug: true의 setDebug 호출, import graph·번호 스캔 실패 경고 문구, restoreSessionState(파일 하나 없음 / 하나 깨짐 / import 실패 → resetBuildState). plugin.ts 커버리지 100%
  • @typescript/native tsc 통과
  • CI 전체와 커버리지

Refs #686

🤖 Generated with Claude Code

…n setup fallbacks

Three gaps in the Turbopack setup:

- The `debug` option was ignored: the Turbopack branch never read it or
  called `setDebug`, unlike the webpack path. It is now set on the engine
  and is part of the production setup cache key.
- A dev restart imported the sheet, class map and file map one after another
  in a single `try`. When a later file was missing or corrupt, the earlier
  ones stayed imported, and new styles could get names that clash with the
  restored ones. Every file is now read and parsed first, then all are
  imported; state that does not import is dropped with `resetBuildState`.
  The prefix and debug flag are set after the restore so a drop keeps them.
- A failing import graph or file-numbering scan was swallowed, leaving a
  successful build without class merging, with idle-based CSS completion or
  with arrival-order file numbers. Both now print a warning with the cause
  and what the build loses.

Refs #686 (NXT-10, NXT-14, NXT-18)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
packages/next-plugin/src/plugin.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901
owjs3901 merged commit d890fca into main Nov 17, 2026
27 checks passed
@owjs3901
owjs3901 deleted the fix/next-turbo-setup branch November 17, 2026 04:25
owjs3901 added a commit that referenced this pull request Nov 17, 2026
Keep #918's setupWarning/restoreSessionState next to reserveSharedSlots, and
warn through setupWarning when the reservation fails, like the other setup
fallbacks. #944 dropped the withTailwindCss import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
#918 restores session state through restoreSessionState; keep calling it
with the shared distDir files, so a process with its own state dir still
starts from what the cache was built against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
Thread licenseBanner through the Next options next to #918's debug, and set
it with setDebug after restoreSessionState so a dropped state cannot undo it.
Keep the Bun licenseBanner option beside #925's include.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant