fix(app-router): isolate parallel slot page CSS#2095
Open
NathanDrake2406 wants to merge 2 commits into
Open
Conversation
commit: |
Parallel route slot pages were still emitted as eager manifest imports, so a slot page that imported route-level global CSS could be bundled into the shared RSC manifest chunk and leak styles into unrelated production routes. The manifest now emits non-intercepting slot pages as lazy loaders, and the App Router route-module hydrator resolves those loaders onto slot.page before segment config or rendering reads the route tree. Regression coverage adds a production fixture for a non-intercepting @panel/page.tsx with global CSS and verifies unrelated routes do not link that CSS while the slot route still does.
7b25e3a to
f46b3c7
Compare
…n requests The generated handleServerActionRequest wrapper is invoked for every App Router request, not only real server actions. It now returns early when no action id is present, and entry-loads only the matched route (page + route handler) for actual action requests, leaving parallel slot page hydration to the page render path. This closes the remaining path where a plain GET to a route handler with inherited parallel slots could evaluate slot page modules before dispatch.
Contributor
Author
|
Fixed the server-action preflight path in the generated RSC entry. Changes (pushed to
Verification:
|
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.
Overview
slot.pagePathmodules as lazy manifest loaders and hydrate them ontoslot.pageonly when the request takes the page-render pathapp-rsc-manifest.ts,app-route-module-loader.ts,app-rsc-handler.ts,app-router-production-server.test.tsCloses #1817.
Why
Parallel slot page modules are page modules in the active route tree. They should be loaded when the matched page route needs them, not when the generated RSC manifest module is evaluated for every route. PR #1738 fixed this for ordinary matched pages and intercepting pages, but
slot.pagePathstill used the eager import path.import()loaders instead of eagerimport * asmanifest importsslot.pagemodulesResponsehandleAppRscRequestcallsensureRouteLoaded(route, { includeParallelSlotPages: false })before the route-handler branch and performs full slot hydration only after the handler branch declinesWhat changed
@slot/page.tsximports route-global CSSpage: nullplus__loadPage, then hydrated only for matched page renderingslot.pagebefore downstream readsMaintainer review path
packages/vinext/src/entries/app-rsc-manifest.ts: verifyslot.pagePathnow usesgetLazyLoaderVarand emits__loadPage.packages/vinext/src/server/app-route-module-loader.ts: verify entry hydration and full page-route hydration are distinct, withincludeParallelSlotPages: falseskipping slot page loaders.packages/vinext/src/server/app-rsc-handler.ts: verify route handlers dispatch after entry-only hydration and before full slot page hydration.tests/app-rsc-handler.test.ts: verify a route handler with an inherited slot does not call the slot page loader.tests/app-router-production-server.test.tsplus theparallel-slot-css-isolationfixture: verify the CSS regression is covered at the production stylesheet boundary.Validation
vp test run tests/app-route-module-loader.test.ts tests/app-rsc-handler.test.ts -t "ensureAppRouteModulesLoaded|parallel slot pages before route handler"vp test run tests/app-route-module-loader.test.ts tests/app-rsc-handler.test.ts tests/entry-templates.test.ts tests/app-router-production-server.test.ts -t "ensureAppRouteModulesLoaded|parallel slot pages before route handler|route module imports|non-intercepting parallel slot pages"vp test run tests/app-rsc-handler.test.tsvp test run tests/app-router-production-server.test.tsvp check --fixvp checkgit diff --checkRisk / compatibility
Non-goals
References
slot.pagePathgap from #1738