Skip to content

fix(plugin-utils): count every Next route file in the compiled set - #943

Merged
owjs3901 merged 1 commit into
mainfrom
fix/next-route-entries
Nov 15, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/next-route-entries

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

감사 항목 NXT-03 (P1, NONDET) 수정입니다. Next 플러그인이 base CSS 완료 신호(expectedBaseFiles)로 쓰는 computeCompiledFiles는 App Router의 page.*에서만 출발했습니다. layout 같은 segment 파일은 그 아래에 page가 있을 때만 조상 shell로 들어갔습니다. 그래서 다음 문제가 있었습니다.

  • Pages Router 프로젝트(pages/index.tsx, pages/about.tsx, _app, _document …)는 집합이 비어(expectedBaseFiles=[]), 코디네이터가 트래픽 타이밍에 의존하는 idle 휴리스틱으로 base CSS를 응답했습니다.
  • App Router에서도 route handler(route.ts), 아래에 page가 없는 parallel route @slot/default.tsx, page 없는 root not-found.tsx 등이 빠졌습니다.

변경:

  • 완료 집합의 출발점을 다음으로 넓혔습니다.
    • 모든 App Router route 파일: page, route, layout, template, default, loading, error, not-found, forbidden, unauthorized, global-error, global-not-found
    • pages/ 아래의 모든 Pages Router 모듈 (_app, _document, _error, api/* 포함, Next 기본 pageExtensions인 tsx/ts/jsx/js)
  • 각 entry의 static + dynamic import closure를 합칩니다. 모든 segment 파일이 직접 entry가 되므로 조상 shell 탐색은 이 함수에서 필요 없어졌습니다.
  • srcDir가 src인 경우(src/pages)와 프로젝트 루트인 경우(pages, 기존 sourceDir()가 선택) 모두 동작합니다.
  • atom hoisting의 route 수를 정하는 computeFileRoutes / computeFileReach는 그대로 App Router page만 셉니다. 이 PR은 완료 집합만 바꾸며, 이 함수는 Next 플러그인만 사용합니다.
  • 프로덕션에서는 prewarm이 이 집합을 포함한 graph 전체를 먼저 추출하므로, 집합이 비어 있지 않으면 base CSS 응답이 idle 대기 없이 결정적으로 끝납니다. 집합이 조금 넓어져도 prewarm이 모두 seed하므로 대기가 길어지지 않습니다.

다른 PR과의 겹침

  • fix(plugins): compile modern modules, resolve bundler conditions and hoist over every source root #934 (fix/plugin-core-update)가 plugin-utils/src/import-graph.ts의 소스 확장자 / 루트 처리(jsFileRegex 제거 등)를 바꿉니다. 이 PR은 computeCompiledFiles와 route 정규식 근처만 수정해 직접 겹치지는 않지만, 같은 파일이라 텍스트 충돌 가능성이 있습니다. #934가 MDX / .mts 등을 source 확장자로 넣으면 Pages Router 정규식의 확장자도 Next pageExtensions에 맞춰 함께 검토하는 것이 좋습니다.

Test plan

  • bun test --coverage src/import-graph.test.ts (plugin-utils): 80 pass
    • src/pages/** (_app, _document, api, dynamic segment)와 그 import closure 포함, orphan 제외
    • 프로젝트 루트 pages/ (srcDir: cwd)
    • page가 없는 route.ts, @modal/default.tsx, root not-found.tsx, global-error.tsx와 그 closure 포함
    • route가 없으면 여전히 빈 목록 (idle fallback 유지)
  • next-plugin plugin.test.ts, prewarm.test.ts (plugin-utils dist 재빌드 후)
  • bunx tsc --noEmit -p packages/next-plugin
  • bunx prettier --single-quote --no-semi --check (변경 파일)

Refs #694

🤖 Generated with Claude Code

computeCompiledFiles, the Next plugin's base CSS completion set, only
started from App Router page files and added layouts and other segment
files when a page sat below them. A Pages Router project therefore got
an empty set, and the coordinator served its base CSS on the idle
heuristic, which depends on traffic timing. Route handlers, a
parallel-route default and a root not-found without a page were left
out of App Router projects too.

The compiled set now starts from every App Router route file (page,
route, layout, template, default, loading, error, not-found, forbidden,
unauthorized, global-error, global-not-found) and every Pages Router
module under pages/, _app and _document included. computeFileRoutes,
which drives atom hoisting, still counts only App Router pages.

Refs #694

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/plugin-utils/src/import-graph.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 acb13e1 into main Nov 15, 2026
27 checks passed
@owjs3901
owjs3901 deleted the fix/next-route-entries branch November 15, 2026 22:43
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