Repository navigation
Conversation
A production webpack build counted Next's root layout (or template, or pages/_app) as a route of its own, so what only it imports kept a per-file stylesheet that every page loaded anyway. A shell that wraps every route of its router now counts with those routes when atoms are hoisted, so its imports join the shared devup-ui.css with short names. A nested layout stays a route of its own; lazily loaded files and other entries keep theirs. Dev, Turbopack and plain webpack/Rsbuild builds are unchanged. The one-route Turbopack test reads the layout from the coordinator options, as in #1033, since #1036 removed singleCss from the loader options. 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:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
force-pushed
the
perf/shared-reach-every-route
branch
from
November 19, 2026 09:46
cd6b29e to
b28965a
Compare
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
Item 6, step 2: in a multi-route Next production build (webpack), styles that every route loads now go into the shared
devup-ui.css.Next compiles the root
layout(alsotemplateandpages/_app) as an entry of its own. Atom hoisting counted it as one route, so what only the layout imports (a header, a footer) kept per-file class names and a stylesheet of its own. Every page loaded that stylesheet anyway.withRouteShells(plugin-utils) changes only how the routes are counted:page,default,not-found,forbidden,unauthorized,loadinganderror._appwraps every page exceptapi/and_document.The webpack plugin gets an opt-in
routeShellsoption. Next production builds set it, while plain webpack and Rsbuild builds don't.This PR also carries the one-route Turbopack test fix from #1033. That test (#1035) read
singleCssfrom the loader options, which #1036 removed, so it fails on main. The hunk is identical in both PRs.Results
Deployable bytes follow #1034's definition. Code hash is the sha256 of every
.next/staticand.next/serverJS/CSS file, with the build ID normalized.Benchmark Next apps (all single-route): byte-identical
Multi-route test app (root layout with Header and Footer, a nested dashboard layout with a Sidebar, 10 dashboard and 10 marketing pages, shared Card and Chart; webpack)
/CSS loaded (files)/m0CSS loaded (files)/dashboard/d0CSS loaded (files)/dashboard/d0HTMLTests
route-shells.test.ts: root layout counted with its routes; nested layout or template kept as a route;_appwith API routes and_documentexcluded; lazy and other entries untouched; a layout with no route below it kept as a route; no-shell passthrough.route-shells-build.test.ts, a real webpack build with a layout entry and three pages:devup-ui.csswith short names, in cascade order. Base rules come first, then@media(min-width:768px)(responsive), then:hover(selector).@import, and every other per-file sheet is byte-identical and still imports the shared sheet first.computeFileReachgets the shell-aware routes and graph only withrouteShells, and collapse still sees the discovered graph. Next plugin: production passesrouteShells: true, dev passes nothing.요약
6번 항목 2단계입니다. 여러 라우트가 있는 Next 프로덕션 빌드(webpack)에서, 모든 라우트가 불러오는 스타일을 이제 공유
devup-ui.css에 넣습니다.Next는 루트
layout(그리고template,pages/_app)을 별도 엔트리로 컴파일합니다. 아톰 호이스팅은 이를 라우트 하나로 셌습니다. 그래서 레이아웃만 import하는 것(헤더, 푸터)은 per-file 클래스 이름과 자기 스타일시트를 따로 가졌고, 모든 페이지가 어차피 그 스타일시트를 불러왔습니다.withRouteShells(plugin-utils)는 라우트를 세는 방식만 바꿉니다.page,default,not-found,forbidden,unauthorized,loading,error를 감쌉니다._app은api/와_document를 뺀 모든 페이지를 감쌉니다.webpack 플러그인에 opt-in 옵션
routeShells가 생겼습니다. Next 프로덕션 빌드만 켜고, 일반 webpack·Rsbuild 빌드는 켜지 않습니다.이 PR에는 #1033의 one-route Turbopack 테스트 수정도 들어 있습니다. 이 테스트(#1035)는 로더 옵션의
singleCss를 읽었는데 #1036이 그 옵션을 없애서 main에서 실패합니다. 두 PR의 hunk는 동일합니다.결과
배포 바이트는 #1034 정의를 따릅니다. 코드 해시는
.next/static·.next/server의 모든 JS/CSS 파일 sha256이며, 빌드 ID는 정규화했습니다.벤치마크 Next 앱(모두 단일 라우트): 바이트 동일
다중 라우트 테스트 앱 (루트 레이아웃에 Header·Footer, 중첩 dashboard 레이아웃에 Sidebar, 대시보드 10개와 마케팅 10개 페이지, 공유 Card·Chart, webpack)
/로드 CSS(파일 수)/m0로드 CSS(파일 수)/dashboard/d0로드 CSS(파일 수)/dashboard/d0HTML테스트
route-shells.test.ts: 루트 레이아웃은 라우트와 함께 셈, 중첩 레이아웃·template은 자기 라우트로 유지,_app에서 API 라우트와_document제외, lazy·그 밖의 엔트리는 그대로, 아래에 라우트가 없는 레이아웃은 라우트로 유지, 셸이 없으면 그대로 통과.route-shells-build.test.ts, 레이아웃 엔트리와 페이지 3개로 실제 webpack 빌드:devup-ui.css에 들어가고, cascade 순서를 지킵니다. 기본 규칙 →@media(min-width:768px)(반응형) →:hover(선택자) 순입니다.@import만 남고, 다른 per-file 시트는 모두 바이트 동일하며 여전히 공유 시트를 먼저 import합니다.routeShells가 켜졌을 때만computeFileReach가 셸을 반영한 라우트·그래프를 받고, collapse는 발견한 그래프를 그대로 봅니다. Next 플러그인: 프로덕션은routeShells: true를 넘기고, dev는 아무것도 넘기지 않습니다.🤖 Generated with Claude Code