Skip to content

fix(next-plugin): warn instead of failing on a prewarm file it cannot extract - #1031

Merged
owjs3901 merged 2 commits into
mainfrom
fix/next-prewarm-warn-unreachable
Nov 19, 2026
Merged

owjs3901 merged 2 commits into
mainfrom
fix/next-prewarm-warn-unreachable

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Refs #686 (NXT-12)

Summary

Implements the owner's decision for NXT-12. The production prewarm still extracts every source file. Turbopack singleCss has to know every style before the CSS is emitted, so the scope stays the same. What changes is that an extraction error during the prewarm no longer fails the build:

  • Next.js + Turbopack (packages/next-plugin/src/plugin.ts): a file the prewarm cannot extract is skipped, with a warning that names the file and the error:
    [devup-ui] Turbopack prewarm of <file> failed: <message>. The file is skipped; if Next.js compiles it, the build fails with this error.
    The file is left out of prewarmedFiles and prewarmedOutputs. If a route imports it, its loader extracts it through the coordinator and fails the build with the real error. If it is in the route closure (expectedBaseFiles), the base CSS also still waits for it, so no styles are silently lost.
  • Next.js + webpack / webpack plugin (packages/webpack-plugin/src/plugin.ts): Next passes the same whole-graph set as productionPrewarmFiles, and the webpack warm-up used to fail on any extraction error in it. It now warns per file ([devup-ui] webpack stylesheet warm-up of <file> failed: ...) and goes on. Read failures of the complete set still fail the build, as before. The generic warm-up (no complete set) also skips a file it cannot extract, instead of stopping the whole warm-up.

Output for valid projects is byte-identical: the new branch runs only when extraction throws (#694).

Left alone

  • Reservation pre-passes (Vite, Rsbuild, webpack, Bun, Next dev reserveSharedSlots): reserve_class_slots_internal already drops per-input extraction errors, so they never failed the build.
  • Rsbuild prewarm: it only covers files reachable from the entries, and its empty catch is handled in fix(plugins): plan webpack and Rsbuild hoisting over the bundler's real entries #1028 (PLG-27), so it is not duplicated here.
  • Vite / Bun: no extraction prewarm besides the reservation.

Tests

  • next-plugin/plugin.test.ts: an unreachable file that throws in prewarm leads to a warning, the build does not throw, files after it still prewarm, and the file is excluded from prewarmedFiles and prewarmedOutputs.
  • next-plugin/prewarm-error.wasm.test.ts (real WASM + real coordinator + loader): the broken file throws Cannot parse source in prewarm extraction and leaves the sheet byte-identical. When the loader compiles the same file, it fails with that real error.
  • webpack-plugin/plugin.test.ts: the complete set skips the broken file with a warning and continues. Read/canonical/numbering errors still propagate. A generic read failure still warns and stops.
  • webpack-plugin/production-prewarm.mjs (real engine): bad.tsx in the complete set warns and later files are still extracted. The loader's codeExtract of bad.tsx still throws Cannot parse source.
  • Docs: build-errors explains the warning. Changepack: next-plugin and webpack-plugin patch.

Conflicts

git merge-tree against perf/prepass-skip-runtime-package (#1029), perf/reservation-skip-dependency-imports and fix/webpack-rsbuild-graph (#1028) adds no new conflicts. #1029 and #1028 already conflict with main in the same places, and this PR does not touch prewarm.ts.


요약

NXT-12에 대한 오너 결정을 구현합니다. 프로덕션 prewarm은 그대로 모든 소스 파일을 추출합니다. Turbopack singleCss는 CSS를 내보내기 전에 모든 스타일을 알아야 하므로 범위는 바꾸지 않았습니다. 바뀌는 점은 prewarm 단계의 추출 오류가 더 이상 빌드를 실패시키지 않는다는 것입니다.

  • Next.js + Turbopack: 추출할 수 없는 파일은 파일명과 오류를 담은 경고를 남기고 건너뜁니다. 그 파일은 prewarmedFiles/prewarmedOutputs에서 빠집니다. 실제로 import되면 로더가 코디네이터를 통해 다시 추출하고, 실제 오류로 빌드가 실패합니다. 라우트 클로저(expectedBaseFiles)에 있는 파일이면 base CSS도 계속 그 파일을 기다리므로 스타일이 조용히 빠지지 않습니다.
  • Next.js + webpack / webpack 플러그인: Next가 같은 전체 그래프 집합을 productionPrewarmFiles로 넘기며, 기존에는 추출 오류 하나로 빌드가 실패했습니다. 이제 파일 단위로 경고하고 계속 진행합니다. 완전 집합의 읽기 실패는 이전처럼 빌드를 실패시킵니다. 일반 warm-up(완전 집합 없음)도 추출 실패 파일만 건너뜁니다.

정상 프로젝트의 출력은 바이트 단위로 동일합니다. 새 분기는 추출이 throw할 때만 실행됩니다(#694).

그대로 둔 것

  • reservation 프리패스(Vite, Rsbuild, webpack, Bun, Next dev): reserve_class_slots_internal이 이미 입력별 오류를 버리므로 빌드를 실패시킨 적이 없습니다.
  • Rsbuild prewarm: 엔트리에서 도달 가능한 파일만 다루며, 빈 catch는 fix(plugins): plan webpack and Rsbuild hoisting over the bundler's real entries #1028(PLG-27)에서 처리하므로 중복하지 않았습니다.
  • Vite / Bun: reservation 외에 추출 prewarm이 없습니다.

테스트

  • Next 단위 테스트: 도달 불가 파일이 prewarm에서 throw하면 경고를 남기고, 빌드는 계속되며, 해당 파일은 prewarm 결과에서 빠집니다.
  • 실제 WASM 테스트: 깨진 파일은 prewarm 추출에서 Cannot parse source로 실패하고 시트를 바꾸지 않습니다. 같은 파일을 로더가 컴파일하면 실제 오류로 실패합니다.
  • webpack 단위 테스트와 실제 엔진 하네스: 완전 집합에서 깨진 파일은 경고하고 건너뛰며 이후 파일은 계속 추출됩니다. 로더의 추출은 여전히 실제 오류로 실패합니다.
  • 문서(build-errors)와 changepack을 추가했습니다.

충돌

#1029, perf/reservation-skip-dependency-imports, #1028과의 git merge-tree에서 새 충돌은 없습니다. #1029와 #1028은 이미 같은 위치에서 main과 충돌하며, 이 PR은 prewarm.ts를 건드리지 않습니다.

🤖 Generated with Claude Code

owjs3901 and others added 2 commits November 19, 2026 11:31
… extract

The production prewarm keeps extracting every source file, but a file it
cannot extract (dead source no route imports) is now skipped with a warning
naming the file and the error. If Next.js or webpack compiles the file, its
loader still fails the build with the same error.

Refs #686 (NXT-12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the loader still fails

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

codecov Bot commented Nov 19, 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%> (ø)
packages/webpack-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 4ad245f into main Nov 19, 2026
37 checks passed
@owjs3901
owjs3901 deleted the fix/next-prewarm-warn-unreachable branch November 19, 2026 04:59
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