Skip to content

perf(pages-router): load Next.js-like client chunks - #4726

Open
james-elicx wants to merge 71 commits into
mainfrom
perf/pages-router-client-chunks
Open

james-elicx wants to merge 71 commits into
mainfrom
perf/pages-router-client-chunks

Conversation

@james-elicx

@james-elicx james-elicx commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Pages Router production builds load many more client JS files than Next.js does. On examples/pages-router-complex a desk page loaded 22–23 files, against 5–6 for Next.js webpack and 10 for Turbopack. There were two causes.

_app's imports were split into many chunks. A module that _app and some pages both import (next/link's helpers, next/script, next/dynamic, app components) got a shared chunk of its own, even though every page loads _app. That added up to 8 tiny files on every route. vinext:pages-client-chunks now puts _app's static imports, and what Rolldown finds they use, in one pages-app chunk, short of the framework and vinext chunks. Next.js keeps pages/_app unsplit for the same reason. Nothing is over-fetched, since every page loads _app anyway. _app itself keeps its own chunk, because the client entry imports it and the Pages manifests (CSS order, preloads) look it up by source path. The group starts from _app's direct imports and leaves the rest to Rolldown, so a page-only export of a side-effect-free barrel that _app also imports stays out of the chunk every page loads. An import that statically leads back to _app, or to a module the client entry loads beyond vinext's first group (instrumentation-client's imports and their import() targets), stays in _app's chunk. Rolldown would pull that module into the group too, and the entry would then load the whole group before _app. A page that one of _app's imports imports joins the group, as it joins pages/_app in Next.js. _app is also an entry of the client build, as in Next.js. Rolldown orders a chunk's modules (and so its CSS) by visiting the entries before the import() targets, so pages that sort before _app no longer order what they share with it ahead of _app's own imports, such as a CSS module ahead of _app's global stylesheet.

The pages-app chunk holds _app's stylesheets too, in import order. The SSR-manifest backfill now also lists the stylesheets of the chunks a chunk statically imports, ahead of the chunk's own, so a server bundle without the CSS graph (server built before the client) still links _app's CSS.

Small modules shared by different sets of pages each got a tiny common chunk. webpack and Turbopack copy small shared modules into each page instead. With Rolldown 1.2.18+, vinext now turns on codeSplitting.experimentalInlineCommonChunks at 20 kB, Next.js' webpack splitChunks.minSize. Rolldown keeps one instance of each copied module and evaluates it only when an importer needs it, so module evaluation stays the same as in Next.js.

Modules that the same pages share get a chunk once they reach 20 kB, as webpack's splitChunks gives them. collectSharedGroupModules names a pages-shared-N group for each set of pages whose shared modules reach 20 kB together. The group is entries-aware, because vinext decides it from the module graph before tree shaking: Rolldown splits it by the pages that use each part after, and copies a part under 20 kB into them. Rolldown copies a small common chunk into the chunks that import it, not into the pages, so a small module that imports one that no group takes, or a stylesheet, stays out of its set's group and is copied into the pages with what it imports, unless what stays out reaches 20 kB too. A stylesheet that only one group's modules import joins the group.

A page downloads each module once. Inlining copies a small common chunk into each chunk that imports it, so a page that loads two of those would download the module twice, and link a stylesheet's rules twice, where the second copy overrides the first chunk's own stylesheet. webpack and Turbopack give a page one copy of each module. collectDoublyCopiedModules finds the chunks Rolldown would copy into two chunks that load together (both loaded by one page, or one of them with every page through _app), and those keep a file. So do the small modules of a shared group that two of the group's modules import (collectSharedGroupDependencies), since tree shaking could leave them a part of their own that Rolldown would copy into both.

Stylesheets follow webpack too. A copied CSS module joins each importing page's stylesheet, so small CSS that pages share no longer gets a tiny stylesheet of its own. webpack applies minSize to the CSS of each set of pages that share it, but Rolldown's size only counts the JavaScript a stylesheet compiles to. So vinext:pages-client-stylesheet-sizes records each stylesheet's compiled size, and a chunk isn't copied when it holds stylesheets that the same set of pages loads with 20 kB of CSS together. That CSS keeps one stylesheet, as in webpack. Turbopack merges CSS further, into one large stylesheet that most pages load. Nor is a chunk copied when it holds CSS that a page shares with a next/dynamic target. webpack leaves out of a page's dynamic chunk what the page already has, but Rolldown has one chunk per import() target, so a copy there would link the CSS again after the page's own.

Client navigations now switch page stylesheets as Next.js does. With small shared CSS copied into page stylesheets, an earlier page's copy would keep applying after a client navigation, before or after the new page's rules. Next.js's webpack client switches page stylesheets on navigation, and vinext now ports that. The client entry lists each route's own stylesheets: the ones its page loads, without _app's and without those that other dynamic imports load. A navigation loads them into <style> tags turned off with media="x". As the page commits, before its layout effects run, only its tags are on, in its order, after <noscript data-n-css>, and the server's <link>s for page stylesheets go. The links of stylesheets that a next/dynamic import also loads stay, as with Next.js's dynamic CSS manifest. Those stylesheets are linked ahead of the marker, as on a full load. Vite's preload helper then finds the link when a next/dynamic import loads one later, rather than adding another after the page's own CSS. A link it already added on an earlier page moves ahead of the marker. On a later page that doesn't load that stylesheet, the link, or the server's link to it, goes back after the page's own CSS, into the place Vite added it among the dynamic imports' other stylesheets. So a next/dynamic component's CSS still wins there, as with Next.js's webpack client, which loads it from a stylesheet of its own. For a page that lists the stylesheet after a next/dynamic import on an earlier page loaded it, vinext matches Turbopack, where webpack lets that earlier link override the page's own CSS. Turbopack never unloads page CSS and its prefetches link other pages' stylesheets, so in a few navigation orders it lets page CSS beat a dynamic component's CSS where webpack and vinext don't. If a stylesheet fails to load, the navigation becomes a full page load, as in Next.js. Page loaders no longer have Vite preload page stylesheets, so prefetching a page doesn't apply its CSS to the current page; the prefetch loads the stylesheet text instead. With a relative base, the url()s in that text resolve against the stylesheet, as they would from its <link>.

Stylesheets loaded from JavaScript now keep the deployment ID query. Without it, Vite's preload helper didn't recognise the server's link and appended a second copy after the page's CSS, which reordered the cascade on main whenever deploymentId was set. App Router CSS URLs get the query too, as in Next.js, and so do the stylesheets that client references' Flight rows name, so the browser finds them already linked. experimental.inlineCss looks them up without it.

In dev, Vite adopts the server's Pages stylesheet links. The server's <link>s now carry data-vite-dev-id, the id that Vite's CSS transform passes to updateStyle(), taken from the import resolution the dev manifest already does. Vite's client then adopts the link instead of injecting the stylesheet again in module execution order. With @cloudflare/vite-plugin, it injected _app's global CSS and a component's CSS module again, and the global rules ended up overriding the module's.

I tried merging small shared modules into one chunk and rejected it: a page would then evaluate modules it never imports.

Inlining is skipped on older Rolldown and with options Rolldown rejects in combination with it: strictExecutionOrder: false, non-ESM output, preserveModules, strict entry signatures, onDemandWrapping. It's also skipped when the output already configures it. The plugin checks the input options as they stand after every plugin's options hook. It's enforce: "post", so it also sees the output after every normal-order plugin's outputOptions hook. disableNextLikeChunking: true now turns both changes off. Hybrid App + Pages builds and library builds keep their current chunking, and so does the plain Pages SSR build, which inherits the client output options.

Results

JS files each route loads on examples/pages-router-complex (production build: the scripts and module preloads in its HTML). Next.js also loads 3 manifest or polyfill files per route on top of these.

Route Next.js webpack Next.js Turbopack main this PR
/, /journal, /workbench 5 10 14–15 7
roster 5 10 22 7
ledger / dispatch / inventory 5–6 10 22–23 8 / 9 / 10
reports / tools / media 5–6 10–11 16–17 8
search 5–6 10–11 16 10

Against webpack, one extra file per route is _app's own chunk. The other extra files are:

  • on the desk pages, a package's CSS module that a lazy component also loads, kept on purpose;
  • a 0.5 kB chunk that Rolldown declines to inline, because it contains an import() of a module that's also inlined elsewhere;
  • a 3 kB chunk that dispatch and inventory share;
  • on search, the App Router runtime chunks that next/navigation loads.

Each route downloads 2.9–5.9 kB more gzipped JS than on main (2–4%, from 136–159 kB). Inlining makes Rolldown use strict execution order, which wraps each module in a lazy init function, including on routes that inline nothing. Rolldown rejects inlining with strict execution order turned off and with onDemandWrapping.

Fixture

examples/pages-router-complex gains workbench desks that give the client build a varied chunk graph:

  • panels shared by different subsets of pages, and a 36 kB shared table;
  • local vendor packages: a side-effect-free barrel, a CommonJS package, and a package with a CSS module;
  • next/dynamic with and without SSR, React.lazy, and on-demand import();
  • next/image, next/script, next/form and next/navigation.

tests/e2e/pages-router-complex/chunk-scenarios.spec.ts checks each scenario still loads and hydrates. One test checks that a module copied into five page chunks evaluates once across client navigations, and not on a page that doesn't import it.

Tests

  • tests/pages-client-chunks.test.ts builds the new tests/fixtures/pages-client-chunks client and checks several things:

    • _app keeps its own chunk, which imports the one chunk holding a module _app shares with a page, even when a module _app imports imports _app back, and the client entry doesn't load that chunk when _app shares a module with instrumentation-client; an import that uses next/link still joins it;
    • only the barrel export _app uses joins that chunk, and the rest of that barrel is copied into the pages that use it;
    • a small module three pages share is copied into each page chunk;
    • the modules that pages share keep a chunk once together they reach 20 kB; large modules that overlapping sets of pages reach through a side-effect-free barrel load only with the pages that use them, the small module both import isn't copied into each, and what tree shaking leaves of a group under 20 kB is copied into its pages;
    • a small CSS module two pages share is copied into each, and two CSS modules that two pages share stay in one chunk once together they hold 20 kB of CSS, though each holds less;
    • the SSR build that follows leaves _app's imports alone;
    • disableNextLikeChunking leaves all of this to the bundler;
    • a library build keeps its chunks, and a plugin that turns onDemandWrapping on from its options hook gets a working build with no inlining.

    It also unit-tests picking _app's imports (including leaving out imports that lead back to _app or to a module the client entry loads, but not ones that only share vinext's first-group helpers with it), grouping stylesheets by the entries that load them, the shared groups, the chunks that would be copied twice into one page, the Rolldown version check and the inlining guards.

  • tests/asset-prefix.test.ts checks that with deploymentId set, client reference Flight rows name stylesheets exactly as the server links them.

  • tests/build-optimization.test.ts checks that the SSR-manifest backfill lists the stylesheets of statically imported chunks, deepest first and ahead of the chunk's own.

  • tests/pages-css-order.test.ts now compares cascade positions across the linked stylesheets, since _app's CSS and a component CSS module it shares with a page now share one stylesheet, in import order.

  • tests/e2e/pages-router-prod/css-navigation.spec.ts builds tests/fixtures/pages-css-navigation. It checks computed colours on full loads, over a 22-step client navigation tour (including a page that imports a small CSS module after a next/dynamic component loaded it on another page), on back and forward, and when a page loads a next/dynamic component on click after a client navigation, and checks that only the page's <style> tags are on, in order, after the marker. Real Next.js 16.2.7 gives the same colours on this fixture with both webpack and Turbopack, except on that navigation, where webpack applies the small module's rules over the page's own and Turbopack doesn't; vinext matches Turbopack. tests/pages-page-stylesheets.test.ts unit-tests the route stylesheet lists and the preload stripping.

  • The tester's request-count specs compare what each page downloads with real Next.js 16.2.7 (webpack), which meets every expectation on their fixtures:

    • tests/e2e/pages-router-prod/client-chunk-requests.spec.ts (tests/fixtures/pages-client-chunk-requests): _app's imports load as one chunk, and a small module or CSS module that two of a page's shared chunks use loads once, its CSS linked ahead of both;
    • shared-group-requests.spec.ts (tests/fixtures/pages-shared-group-requests): a small component that two shared groups of small files use costs no request of its own, and the page links one stylesheet;
    • shared-requests.spec.ts (tests/fixtures/pages-shared-requests): shared lists of small components with CSS modules, a helper that a page and a shared list both use, a next/dynamic component, and a side-effect-free barrel that _app imports from. Five of its cases are test.fail() at their parity assertion: Vite and Rolldown can't meet them (see Known limitations).
  • tests/e2e/pages-router-prod/app-css-order.spec.ts (tests/fixtures/pages-app-css-order) checks that _app's global stylesheet stays ahead of a CSS module that a page sorting before _app also imports, and app-imports-page.spec.ts (tests/fixtures/pages-app-imports-page) that _app's imports load with _app when one of them imports a page.

  • tests/e2e/cloudflare-pages-router-dev/css-order.spec.ts (tests/fixtures/cf-pages-dev-css-order) checks that Vite adopts the Worker's initial Pages stylesheets instead of injecting them again, and that a component's CSS module still wins over _app's global stylesheet after hydration.

  • chunk-scenarios.spec.ts runs in CI against vp dev and, as the new pages-router-complex-prod project, against a production build.

Performance

Measured locally on an Apple M4 Pro: main at the merge base 124aa20 against this branch at 529bedb, in alternating rounds. The browser figures come from Playwright's Chromium with 4× CPU throttling and no cache, as medians of 8 loads per round, against local servers. The two apps are examples/pages-router-complex (served by vp preview on workerd) and benchmarks/pages-large (30 pages over 40 barrel packages of about 100 tiny modules each, served by vinext start on Node).

Dev. The chunking only applies to builds; dev gets the stylesheet shim and the data-vite-dev-id attributes.

  • vp dev cold start to the first / response, pages-large, 11 pairs: medians 8.37 s on main and 8.70 s here. The median paired difference is −66 ms, and pairs ranged from −2.0 s to +4.0 s, so this is noise (load average 5–6).
  • The same on the App Router benchmark app, 5 pairs: 1.65 s against 1.67 s.
  • First page load in the browser after a dev server start, pages-large, 3 pairs: 6.8–12.4 s with either, in no consistent order.
  • Warm reloads hydrate in 858–946 ms against 854–945 ms, and client navigations take 22–35 ms with either. The page requests 4105 modules instead of 4104 (the stylesheet shim).

Build.

  • pages-large, 4 rounds: the client environment builds in 1.79–1.89 s against 1.54–1.68 s on main. Build CPU time has a median of 17.6 s against 17.2 s (+2%); wall time is within noise, and the server environment is unchanged.
    • Profiling showed most of that time in this PR's buildEnd analysis. 529bedb reads each stylesheet's entries from the client graph instead of walking up from each stylesheet, which cut it from 463 ms to 143 ms. The rest of the gap is Rolldown rendering and minifying the larger output.
  • pages-router-complex: build CPU time is 3.2–3.6 s with either.

Server. Rendering is unchanged:

  • pages-router-complex: a median of 200 sequential requests is ~10 ms for the desks and ~17 ms for / with either;
  • pages-large: its pages are static.

Browser, pages-router-complex.

  • Hydration is the same: / takes 114–117 ms with either, ledger 139–144 ms against 140–141 ms.
  • Client navigations are a little faster and fetch fewer chunks: / to roster takes 49–50 ms against 57 ms, with 2 JS requests instead of 10.
  • With emulated mobile network conditions (60 ms RTT, 9 Mbps), hydration is still the same (~600 ms for /, ~635 ms for ledger). Client navigation from / to roster drops from 300–311 ms to 236–239 ms (−22%), and from ledger to roster from 260–262 ms to 244–254 ms.

Browser, pages-large. Each page loads 7 JS files instead of 13 and 1 stylesheet instead of 5 (Next.js webpack: 5 and 1), but 320 kB of gzipped JS instead of 183 kB (Next.js webpack: 204 kB).

  • Hydration takes 140–146 ms instead of 80–90 ms, and script time is 84–86 ms instead of 24–28 ms.
  • With 60 ms RTT and 9 Mbps, hydration takes 1.69 s instead of 1.38 s (+23%).
  • Client navigations take 15–18 ms against 13–20 ms.

This is the strict execution order wrapper from Results. Its cost grows with the number of modules, and pages-large has about 4000 tiny ones. Like Next.js, this PR puts what every page shares in the chunk that loads with _app, so nothing is over-fetched, but with each module wrapped, the pages-app chunk is 217 kB gzipped where Next.js's _app chunk with the same modules is 97 kB. See Known limitations.

The CI benchmark job (alternating rounds on one runner) found no regressions on a85e1e9: all 7 scenarios were within ±1.5%, including the large Pages Router dev cold start (−0.1%) and the production build (−0.2%). Its client bundle scenario builds an App Router app, so it doesn't cover this.

Known limitations

These come from Vite and Rolldown, so this PR leaves them rather than working around them. The five test.fail() cases in shared-requests.spec.ts cover the first three.

  • Vite gives every JavaScript chunk a stylesheet of its own. When a page renders two shared lists that each keep a chunk, the lists' small CSS modules can't stay in the page's stylesheet, where Next.js links one.
  • experimentalInlineCommonChunks copies a small chunk into the chunks that import it, not into the pages. A small module that two shared chunks over 20 kB import would download twice on a page that loads both, so it keeps a chunk of its own, where Next.js puts it in the pages' chunks. This covers a small component or helper that two shared lists use, and the modules of a side-effect-free barrel that _app imports from without using them when two large shared chunks use them.
  • Rolldown builds one chunk per import() target. webpack builds a next/dynamic component's chunk for each page and leaves out what the page has. So a small component with a CSS module that pages and a next/dynamic component both use keeps a chunk, since a copy in the dynamic chunk would link its CSS twice.
  • Strict execution order wraps every module. Rolldown requires it for inlining, and its lazy init wrappers cost bytes and script time in proportion to the number of modules. On a realistic app that's 2–4% more JS per route. On benchmarks/pages-large, with about 4000 tiny modules, it's 75% more JS and +60 ms of hydration at 4× CPU throttling (see Performance).
  • vinext decides what Rolldown may copy from the module graph before tree shaking, and Rolldown splits chunks after it. For modules that pages reach through a shared side-effect-free barrel, tree shaking can split their chunk by the pages that use each part. When such a part is over 20 kB only because several smaller modules add up (each under 20 kB), a small module that two of those parts import can be copied into both, and a page that loads both parts downloads it twice. This only costs bytes (each copy is under 20 kB), not correctness. Telling these parts apart before tree shaking would need the bindings each page imports from the barrel, which Rolldown's module info doesn't expose.

@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@4726

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@4726

@vinext/types

npm i https://pkg.pr.new/@vinext/types@4726

vinext

npm i https://pkg.pr.new/vinext@4726

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@4726

commit: a85e1e9

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared a85e1e9 against base 124aa20 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 7 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 153.9 KB 153.9 KB ⚫ 0.0%
Client entry size (gzip) vinext 142.2 KB 142.2 KB ⚫ 0.0%
Dev server cold start vinext 2.91 s 2.89 s ⚫ -0.7%
Dev server cold start (large Pages Router app) vinext 25.29 s 25.25 s ⚫ -0.1%
Production build time vinext 3.77 s 3.76 s ⚫ -0.2%
RSC entry closure size (gzip) vinext 146.1 KB 146.2 KB ⚫ +0.1%
Server bundle size (gzip) vinext 254.4 KB 254.5 KB ⚫ +0.1%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
workers-cache preview production
kv preview production
static-assets-cache preview production
static-assets-pages preview production
static-assets-pages-i18n preview production
static-export preview production
web preview production

@james-elicx
james-elicx force-pushed the perf/pages-router-client-chunks branch 5 times, most recently from 17c6cc1 to b371b8e Compare November 16, 2026 17:42
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head a309c7560fa1db8bf46019ebb797a8660eabd102 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

Comment thread packages/vinext/src/index.ts Outdated
const rolldownOptions = environment.config.build.rolldownOptions;
return withInlineCommonChunks(output, {
preserveEntrySignatures: pagesClientPreserveEntrySignatures,
onDemandWrapping: (rolldownOptions.experimental as { onDemandWrapping?: unknown })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environment.config.build.rolldownOptions does not include changes made by other plugins in their options hooks. If a plugin enables inputOptions.experimental.onDemandWrapping there, this check misses it and vinext adds experimentalInlineCommonChunks; Rolldown then rejects the otherwise-valid build with INVALID_OPTION. Capture the effective inputOptions.experimental?.onDemandWrapping in the existing post-order options hook alongside preserveEntrySignatures, and pass that captured value here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e43a422. The post-order options hook now captures onDemandWrapping from the effective input options, next to preserveEntrySignatures, and the outputOptions hook checks those captured values. A new test in tests/pages-client-chunks.test.ts adds a plugin that turns onDemandWrapping on from its options hook. Without the fix, that build fails with Rolldown's INVALID_OPTION. With it, the build succeeds and the shared module keeps its own chunk.

}
},
outputOptions: {
// Sees the client output after other plugins' outputOptions hooks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order: "post" only runs after normal hooks; a post-order outputOptions hook from a plugin placed after vinext() still runs later. Such a plugin can validly set an incompatible option (for example strictExecutionOrder: false) after this hook enables experimentalInlineCommonChunks, causing Rolldown to fail with INVALID_OPTION. Please ensure this compatibility check runs after every output mutation, or conservatively skip inlining when a later output-options hook may change these guarded values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly fixed in e43a422: the plugin is now enforce: "post", so its post-order options and outputOptions hooks run after those of every normal-order plugin, including user plugins.

I'm leaving the remaining case alone on purpose. That's a plugin that is itself enforce: "post", listed after vinext(), that sets one of the incompatible options from its own post-order hook. Handling it would mean inspecting the sorted plugin list, which vinext doesn't do for its other output defaults. If it happens, Rolldown fails the build with an INVALID_OPTION error that names the conflicting option, and disableNextLikeChunking: true turns the inlining off.

@ask-bonk

ask-bonk Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Review: 2 findings.

Posted 2 actionable inline comments on exact head a309c756.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head e43a42244754c17631d275aee71b315e7c1475e4 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

Comment thread packages/vinext/src/index.ts Outdated
// to avoid leaking into RSC/SSR environments.
...(!isSSR && !isMultiEnv ? { output: getClientOutputConfig() } : {}),
...(!isSSR && !isMultiEnv
? { output: getClientOutputConfig(pagesClientCodeSplitting) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Library builds still receive the new Pages-specific group here. Although build.lib prevents the dedicated application environments from being injected above, this standalone-output branch remains unconditional and passes pagesClientCodeSplitting; I reproduced a library entry that dynamically imports pages/_app.tsx, and it now emits a pages-app chunk. That changes library chunking despite this feature being scoped away from library builds. Please retain clientCodeSplittingConfig for build.lib (and avoid collecting roots/inlining there).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2f21f0c. With build.lib set, the single-output client config now keeps vinext's plain clientCodeSplittingConfig. The plugin's buildEnd also skips collecting roots for library builds. Inlining was already off there, because the outputOptions hook only acts on outputs that still hold the pages-app group. A new test in tests/pages-client-chunks.test.ts builds a library entry that dynamically imports pages/_app.tsx and checks that no pages-app chunk is emitted. Without the fix, that test fails.

@ask-bonk

ask-bonk Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Since last review: 2 resolved, 0 still open, 1 new.

Posted 1 actionable inline finding on exact head e43a422.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head 2f21f0c8c3bda973c5e9ab1fa52fd492902ce322 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@ask-bonk

ask-bonk Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

error: Your local changes to the following files would be overwritten by checkout:
pnpm-lock.yaml
Please commit your changes or stash them before you switch branches.
Aborting

github run

@ask-bonk

ask-bonk Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow timed out.

View workflow run · To retry, trigger Bonk again.

Pages Router production builds loaded 14-23 JS files per route on the
pages-router-complex fixture, against 5-6 for Next.js webpack and 10 for
Turbopack. Two causes:

- `_app`'s imports split into many chunks: a module that `_app` and some
  pages both import got a shared chunk of its own, though every page loads
  `_app`. vinext:pages-client-chunks now puts `_app` and its static imports
  in one "pages-app" chunk, as Next.js keeps `pages/_app` unsplit.
- Small modules shared by different sets of pages each got a tiny common
  chunk. With Rolldown 1.2.18+, small common chunks (under 20 kB, Next.js'
  webpack `minSize`) are now copied into their importers through
  `codeSplitting.experimentalInlineCommonChunks`. Each module still
  evaluates once and only when imported, as in webpack and Turbopack.
  Stylesheets keep their own chunk, as Turbopack keeps a shared CSS module
  in one stylesheet.

`disableNextLikeChunking` turns both off. Hybrid App + Pages builds keep
their current chunking.

The pages-router-complex fixture gains workbench desks that produce a
varied client chunk graph (shared panels, a 36 kB shared table, local
vendor packages, next/dynamic, React.lazy, on-demand imports, next/image,
next/script, next/form, next/navigation) with e2e specs, including one that
checks a module copied into several page chunks evaluates once.
@james-elicx
james-elicx force-pushed the perf/pages-router-client-chunks branch from 2f21f0c to f6014d6 Compare November 17, 2026 00:41
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head f6014d6f89a7ee565d2b0ef6cf2cafa502c26a23 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

1 similar comment
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head f6014d6f89a7ee565d2b0ef6cf2cafa502c26a23 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@ask-bonk

ask-bonk Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Since last review: 1 resolved, 0 still open, 0 new.
LGTM!

github run

@james-elicx
james-elicx marked this pull request as ready for review November 17, 2026 01:03

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of c24e8f0b.

This review, of f6014d6f

✅ Approved — No issues found. The chunking changes, inlining guards and SSR-manifest CSS ordering are consistent and covered by tests, and the issues raised in earlier rounds are fixed.

Not opened by the correctness review: 51 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/glyph.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/package.json
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.js
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/package.json
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.js
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/package.json
  • examples/pages-router-complex/lib/workbench/data/region-table.ts
  • examples/pages-router-complex/lib/workbench/desk-layout.tsx
  • examples/pages-router-complex/lib/workbench/export-menu.tsx
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/filter-bar.tsx
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/page-data.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/panel.module.css.d.ts
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/live-ticker.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-chart.tsx
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/diff-engine.ts
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/lib/workbench/use-hydrated.ts
  • examples/pages-router-complex/next.config.js
  • examples/pages-router-complex/package.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx
  • … and 1 more

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security issues found.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md issues found.


📋 Code Quality: ✅ LGTM

No issues found in the chunk-group selection, the plugin lifecycle, the inlining guards or the SSR-manifest CSS reordering. The graph walks guard against cycles, the plugin clears its roots between builds, and the guards match the Rolldown option conflicts the description lists.


⚡ Performance: ✅ LGTM

No performance issues found.


📝 Documentation: ✅ LGTM

No documentation issues found.


Reviewed commit: f6014d6f

Shared stylesheets that the same pages import keep a chunk of their own once
together they hold 20 kB of CSS, as webpack's minSize does for CSS, instead of
every stylesheet keeping its chunk. A stylesheet that only _app imports stays
in _app's chunk rather than a JavaScript stub of its own.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 91832d58.

This review, of c24e8f0b

✅ Approved — No issues found. The new stylesheet-size threshold for inlining is consistent with the code and covered by fixtures and unit tests. Earlier issues stay fixed.

Not opened by the correctness review: 47 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/glyph.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/package.json
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/package.json
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.js
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/package.json
  • examples/pages-router-complex/lib/workbench/data/region-table.ts
  • examples/pages-router-complex/lib/workbench/desk-layout.tsx
  • examples/pages-router-complex/lib/workbench/export-menu.tsx
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/filter-bar.tsx
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/page-data.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/panel.module.css.d.ts
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/live-ticker.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-chart.tsx
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/diff-engine.ts
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/tools.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

This pull request changes only build configuration, fixtures and tests. No secrets are used in CI, and nothing here can be exploited.


📖 AGENTS.md: ✅ LGTM

The new AGENTS.md entry matches the shared-stylesheet behaviour in this commit.


📋 Code Quality: ✅ LGTM

No issues found in the new handling of stylesheet sizes, the _app-only stylesheet guard, the SSR-manifest backfill or the new fixtures and tests.


⚡ Performance: ✅ LGTM

No performance issues found.


📝 Documentation: ✅ LGTM

No documentation issues found.


Reviewed commit: c24e8f0b

@james-elicx

Copy link
Copy Markdown
Member Author

Thanks for classifying the shared chunks on the app. Here's where each case in a87328a stands at 48b445a.

Fixed (fa88a5a)

  • Case 4 (cards, a helper that a page and a shared list it renders both import). Rolldown leaves out the page's copy when a chunk the page statically imports gets one, because that chunk runs first. The copy analysis now models this. Before, it counted two copies on /cards/full and kept the helper in a file of its own.
  • Case 6 (indexes, a side-effect-free barrel that _app imports without using most of it). Tree shaking leaves only what _app uses in "pages-app". The rest of the barrel, and what it imports, follows the pages that use it. The analysis used to treat all of it as always loaded with _app.

Vite / Rolldown limitations: not worked around (dda7c10 marks them test.fail with the reason)

  • Case 1 (panels, one stylesheet per shared chunk). Vite emits one stylesheet per JavaScript chunk. webpack counts a chunk's CSS against minSize separately from its JavaScript, so it keeps small CSS in the page's stylesheet. Vite has no way to move a chunk's CSS into the importing page's stylesheet.
  • Cases 2 and 3 (lists, tables, a small module that two shared lists use). experimentalInlineCommonChunks copies a small chunk into the chunks that import it, not into the pages. A copy in both list chunks would be downloaded twice on /lists/both and /tables/both, so the module keeps a file of its own. webpack can place it in the pages because it builds each page's chunk set separately.
  • Case 5 (drawer, a frame that pages and a next/dynamic component share). Rolldown builds one chunk per import() target. webpack builds the async chunk once per parent and leaves out what that parent already has. On /drawer/framed, a copy in the drawer's chunk would link the frame's CSS twice, which Next never does.

If Rolldown or Vite add support for these, the test.fail markers will start failing, which will tell us to drop them.

On the 6 Deploy jobs that failed at a87328a: those were Cloudflare API 429s, not this change.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk

Please review exact head 48b445a36ab247d927a1689dff91bab965d7627b without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 7045eec4.

This review, of 48b445a3

✅ Approved — Both findings from the last review (the failing repro spec and the leaked response listener) are fixed, and the code changed since then shows no new problems.

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Client stylesheet switching only fetches hrefs from the build-time manifest. It inserts the CSS as text nodes, and the rewritten url() values are JSON-quoted. On the server, the nonce and the attributes on the <link> and <noscript> tags are escaped. The deployment ID query on stylesheet URLs does not change anything security-relevant.


📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry matches what the code does.


📋 Code Quality: ✅ LGTM

Both earlier findings are fixed:

  • The repro cases in shared-requests.spec.ts that can't pass yet are marked test.fail(), each with its reason.
  • loadScripts now removes its listener with page.off in a finally.

The changes to client-build-config.ts, index.ts and tests/pages-client-chunks.test.ts look correct, and the fixtures match what their specs expect.


⚡ Performance: ✅ LGTM

The new graph helpers in client-build-config.ts run once per client build and visit each module only once per pass. That cost is acceptable for build-time code.


📝 Documentation: ✅ LGTM

The documentation still matches the code.


Reviewed commit: 48b445a3

Comment thread packages/vinext/src/index.ts Outdated
uncopied: pagesUncopiedModules,
declaresSideEffects: createSideEffectsDeclarationCheck(),
// `_app` takes from those only what stays in "pages-app".
importsNothingFrom: (importer, id) => importer === appId && leavingAppGroup.has(id),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importsNothingFrom only suppresses a direct _app -> leavingAppGroup edge. With _app -> layout -> side-effect-free barrel and pages consuming another barrel export, layout remains in pages-app while the barrel is marked as leaving, so layout -> barrel is still counted as an always-loaded importer. The duplicate-copy analysis then excludes the page-only export from inlining and adds a standalone request. I reproduced the emitted behavior with the bundled Rolldown 1.2.19: normal inlining put unit into both page chunks, while excluding it emitted a separate unit.js. Suppress edges crossing from the retained app group into the leaving subtree (not only edges whose importer is appId) and add an indirect-layout fixture.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5e11479. importsNothingFrom now ignores any edge from a module that stays in "pages-app" (_app or one of its retained imports) into the subtree that leaves it, not only edges from _app. In the pages-client-chunks fixture, _app's HomeLink now imports kitTitle from the side-effect-free lib/kit barrel, and pages import kitBadge from it. The fixture test now asserts that kit-badge is copied into alpha and beta. Without the fix it gets a file of its own. The direct _app → barrel shape is still covered by the indexes e2e case.


// Vite limitation: Vite gives every JavaScript chunk a stylesheet of its own,
// so the CSS of each list's chunk can't stay in the page's stylesheet.
test.fail(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring these cases with test.fail(title, body) marks the whole test as expected to fail before navigation and hydration. An unrelated route, hydration, or response-read regression therefore still produces the expected status and passes CI. Collect the measurements first, then call test.fail() immediately before the parity assertion(s); apply the same pattern to the other three expected-failure cases below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7045eec. Each of the four cases now takes its measurements first and calls test.fail() just before the parity assertions, with the limitation explained next to it. A navigation, hydration or response-read failure now fails the test.

@ask-bonk

ask-bonk Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Review: 2 findings.

Posted 2 actionable inline comments. tests/pages-client-chunks.test.ts passed; Rolldown reproduction confirmed the chunking issue.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk

Please review exact head 7045eec48069ff23ae43df9cbc0d64b8b5517544 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of f54d92f5.

This review, of 7045eec4

💬 Approved with comments — The changes since the last review are correct. The one remaining note is an optional defensive fix in the new leaving-app-group walk.

Findings: 1 suggestion (1 is an inline comment on the diff)

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 suggestion

The new code is correct. One optional suggestion: guard the getModuleInfo lookups in the leavingAppGroup walk.

Recommendation: 💬 Optional Nits

  • [SUGGESTION] The leavingAppGroup walk asserts getModuleInfo(id)!, but the appGroupModules walk that fills it reads the same info with ?.. (packages/vinext/src/index.ts:9867)
View full review

The new importsNothingFrom predicate does what the description and the HomeLink → lib/kit fixture say it should. shared-requests.spec.ts now takes its measurements before calling test.fail(), so a navigation or hydration failure still fails the test.

One small note. The new leavingAppGroup walk uses this.getModuleInfo(id)!. Two lines above it, the walk that fills appGroupModules reads the same info with ?.importedIds ?? []. That walk adds every id it reaches, including ids that may have no module info, such as externals. Reading the info the same defensive way in both walks would keep the build from throwing in buildEnd in that case.


✅ All other checks passed

🔒 Security: ✅ LGTM

The changes since the last review are limited to build-time chunk grouping and test fixtures. None of them is security-relevant.


📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry matches what the code does.


⚡ Performance: ✅ LGTM

The new walk visits each module in the _app group once per client build. That cost is fine for build-time code.


📝 Documentation: ✅ LGTM

The documentation still matches what the code does.


Reviewed commit: 7045eec4

Comment on lines +9866 to +9878
const leaving = [...appGroupModules].filter((id) =>
this.getModuleInfo(id)!.importers.some(
(importer) => importer !== appId && !appGroupModules.has(importer),
),
);
while (leaving.length > 0) {
const id = leaving.pop()!;
if (leavingAppGroup.has(id)) continue;
leavingAppGroup.add(id);
for (const imported of this.getModuleInfo(id)!.importedIds) {
if (appGroupModules.has(imported)) leaving.push(imported);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 SUGGESTION · Code Quality

The leavingAppGroup walk asserts getModuleInfo(id)!, but the appGroupModules walk that fills it reads the same info with ?..

appGroupModules is filled from this.getModuleInfo(id)?.importedIds ?? [] at line 9839. That walk adds every id it reaches without checking that the id has module info, for example a module the client build externalizes. Lines 9867 and 9875 then dereference getModuleInfo(id)! for each of those ids. If one has no info, buildEnd throws and the client build fails. Using ?. with a ?? [] fallback here, as line 9839 does, avoids that.

Suggested change
const leaving = [...appGroupModules].filter((id) =>
this.getModuleInfo(id)!.importers.some(
(importer) => importer !== appId && !appGroupModules.has(importer),
),
);
while (leaving.length > 0) {
const id = leaving.pop()!;
if (leavingAppGroup.has(id)) continue;
leavingAppGroup.add(id);
for (const imported of this.getModuleInfo(id)!.importedIds) {
if (appGroupModules.has(imported)) leaving.push(imported);
}
}
const leaving = [...appGroupModules].filter((id) =>
(this.getModuleInfo(id)?.importers ?? []).some(
(importer) => importer !== appId && !appGroupModules.has(importer),
),
);
while (leaving.length > 0) {
const id = leaving.pop()!;
if (leavingAppGroup.has(id)) continue;
leavingAppGroup.add(id);
for (const imported of this.getModuleInfo(id)?.importedIds ?? []) {
if (appGroupModules.has(imported)) leaving.push(imported);
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in f54d92f. Both reads in the leaving walk now use ?. with a ?? [] fallback, as the appGroupModules walk does.

@ask-bonk

ask-bonk Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk

Please review exact head f54d92f5539ceec87db3adf05c068f24ebead67a without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@ask-bonk

ask-bonk Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of aa678729.

This review, of f54d92f5

✅ Approved — The defensive module-info fix from the last review is in, and I found no new problems in the changed code.

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

The changes cover build-time chunk grouping, client stylesheet switching and test fixtures. None of them is security-relevant.


📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry matches what the code does.


📋 Code Quality: ✅ LGTM

The leavingAppGroup walk now reads module info with ?. and a ?? [] fallback, the same way the appGroupModules walk does, so buildEnd can't throw on an id that has no module info.

The rest checks out too:

  • Stylesheet switching: every navigation path is wired for it, including the error target and no-data navigations.
  • Stale navigations: they are still detected after each await.
  • Chunking guards: the inlining guards agree with each other across the options and outputOptions hooks.
  • Tests: the new behaviour is covered by unit, build and Playwright tests.

⚡ Performance: ✅ LGTM

The new chunking plugins run only during production builds, and their cost grows linearly with the number of modules. They add no file reads or other I/O per module. Their state is reset in buildStart and generateBundle, so it doesn't grow across builds.


📝 Documentation: ✅ LGTM

The README, differences.mdx and the example README match what the code does.


Reviewed commit: f54d92f5

Two cases added to the shared-requests spec, both failing on purpose:

- indexes: what _app leaves of a side-effect-free barrel is downloaded once
  now, but as a file of its own: each page makes one request more than in
  Next.js, where it stays in the pages' chunks
- atlas: the same two pages share rows without CSS and sections with CSS
  modules, each over 20 kB. They load as two files; Next.js loads one

Real Next.js 16.2.7 (webpack) meets both expectations on this fixture.
@james-elicx

Copy link
Copy Markdown
Member Author

Re-tested f54d92f the same way (large Pages Router app against real Next.js 16 webpack, dev and production, with and without the Cloudflare plugin).

Rendering: unchanged, still aligned. 4 of about 16,000 elements differ from Next.js in production on Node, 10 on Workers, 0 and 6 in dev, none about chunking. Workers and Node render identically.

Requests on the app

stylesheets, scripts in the page's HTML Next.js 640bb13 823fde4 f54d92f
404 page 1, 7 4, 10 1, 7 1, 7
home page 2, 8 11, 17 7, 12 7, 12
heaviest page 7, 23 28, 41 24, 41 24, 38

Summed over 17 routes in the browser: Next.js 267 scripts and 78 stylesheets; 823fde4 402 and 193; f54d92f 390 and 193.

What moved: the helper that a page and a shared list both use (cards) is fixed on the app too, and the page that downloaded 9 modules of a CommonJS package twice no longer does. Shared chunks under 20 kB of source went from 19 to 16: 12 that would be copied into two chunks one page loads (9 with a CSS module, 3 without) and 4 CSS-module components shared with a next/dynamic component.

What the four expected failures cost

The cases now marked test.fail() (panels, lists, tables, drawer) are where nearly all of the remaining difference is. With them accepted as they are, the heaviest page stays at 38 scripts and 24 stylesheets against 23 and 7, and the 17 routes at 123 scripts and 115 stylesheets more than Next.js. The stylesheet count has not changed since ec49e19.

Two more reproductions (aa67872)

Added to tests/e2e/pages-router-prod/shared-requests.spec.ts; both fail on purpose and Next.js 16.2.7 meets both.

case page Next.js vinext
indexes: what _app leaves of a side-effect-free barrel /indexes/both 2 scripts beyond / 3
/indexes/north 1 2
atlas: two pages share rows without CSS and sections with CSS modules, each over 20 kB /atlas/first 1 script beyond / 2
  • indexes: the barrel's leftovers are downloaded once now, but as a file of their own, so every page that uses them makes a request that Next.js doesn't. The existing case only checked that there was one copy.
  • atlas: everything here is shared by the same two pages, so Next.js loads it as one file. Here it is two: the shared group takes the modules without CSS, and the sections that import a stylesheet are left to a second chunk for the same pages. On the app this is the largest pair on the heaviest page: one set of five pages shares a 157 kB chunk and a 230 kB chunk.

One thing I could not reproduce in a fixture

The heaviest pages of the app still download 3 small modules twice (9 kB). The indexes case passes, so it doesn't cover them. What I can say from the build:

  • each sits behind a sideEffects: false barrel that about 30 modules inside pages-app also import from, using other exports;
  • they are counted as part of pages-app, are not marked to keep a file, and end up copied into between 3 and 12 chunks;
  • the two copies a page downloads are in the two chunks of the atlas shape: the shared group for a set of five pages, and the common chunk for the same five pages. 16 modules of the first and 34 of the second import from the barrel, all small.

I tried that shape with the barrel in the fixture (large module plus list, groups of small files, _app reaching the barrel through its own component, and the atlas board using the barrel) and each time the helper came out as one file, so something else about the app is involved. If the atlas split goes away, these two copies probably do too.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 3b5c6bab.

This review, of aa678729

💬 Approved with comments — One WARNING: the head commit adds two e2e cases that it says fail on purpose, but neither is marked as an expected failure, so the pages-router-prod Playwright project should go red. No production code changed since the last review.

Findings: 1 warning (1 is an inline comment on the diff)

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #4726.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Code Quality] The new indexes request-count and atlas cases fail on purpose (commit aa678729) but are not marked as expected failures, so the pages-router-prod Playwright project should fail at this head.
- **File:** tests/e2e/pages-router-prod/shared-requests.spec.ts:226

📋 Code Quality: ⚠️ 1 warning

Two new shared-requests cases fail on purpose but have no test.fail() marker.

Recommendation: 📝 Minor Comments

  • [WARNING] The new indexes request-count and atlas cases fail on purpose (commit aa67872) but are not marked as expected failures, so the pages-router-prod Playwright project should fail at this head. (tests/e2e/pages-router-prod/shared-requests.spec.ts:226)
View full review

Commit aa67872 says both new cases fail on purpose:

  • indexes request count: each page makes one request more than in Next.js.
  • atlas: the shared board loads as two files where Next.js loads one.

The tests at tests/e2e/pages-router-prod/shared-requests.spec.ts:218-227 and :229-239 end in a plain expect(...) with no test.fail(). The other cases in this file that can't pass yet (lines 140, 158, 171 and 201) take their measurements first and then call test.fail() with the reason next to it. These two should do the same, or land with the change that makes them pass. As written, the required Playwright E2E check should fail on this branch.

The new lib/atlas/* and pages/atlas/* fixtures match what the spec says they test.


✅ All other checks passed

🔒 Security: ✅ LGTM

Since the last review, only test fixtures and an e2e spec changed. No security-relevant changes.


📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry still matches the code.


⚡ Performance: ✅ LGTM

Since the last review, only test fixtures and an e2e spec changed.


📝 Documentation: ✅ LGTM

The README, differences.mdx and the example README still match the code.


Reviewed commit: aa678729

// makes a request for what `_app` leaves of the barrel.
const extra = await extraScripts(page, ["/indexes/both", "/indexes/north", "/indexes/south"]);

expect(extra).toEqual({ "/indexes/both": 2, "/indexes/north": 1, "/indexes/south": 1 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ WARNING · Code Quality

The new indexes request-count and atlas cases fail on purpose (commit aa67872) but are not marked as expected failures, so the pages-router-prod Playwright project should fail at this head.

Commit aa67872 says this case and the atlas case below (line 238) both fail on purpose: one request more than Next.js per page, and two files instead of one. Neither calls test.fail(), so the required Playwright E2E check goes red. A real regression in this spec would also be hidden behind the known failure. Add test.fail() with the limitation just before the parity assertion in both tests, after the measurements, as the panels/lists/tables/drawer cases at lines 140-201 already do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed at 3b5c6ba. f3670b1 fixes atlas in vinext, and it passes now. The indexes request count is a Rolldown limitation (the same shape as tables), so 3b5c6ba marks it with test.fail() just before its parity assertion and gives the reason.

@james-elicx

Copy link
Copy Markdown
Member Author

Thanks. Here's where the two new cases in aa67872 stand at 3b5c6ba.

atlas: fixed (f3670b1)

This one was vinext's own grouping. A small module that imports a stylesheet stays out of its set's group, so that it gets copied into the pages. When the modules left out of one set's group reach 20 kB together, Rolldown doesn't copy them: it gives them a common chunk of its own for the same pages. That chunk was atlas-board next to pages-shared-6~first~second. Those modules now stay in the group. A stylesheet that only one group's modules import joins that group too, so its CSS-module code goes with its importers and needs no file of its own. /atlas/first and /atlas/second now load one shared chunk and one stylesheet, as before.

indexes request count: Rolldown limitation, marked test.fail() (3b5c6ba)

unitName and the chip are imported from north-index and south-index (through the summaries). Each index is a chunk over 20 kB, and /indexes/both loads both. This is the same shape as tables. Rolldown copies a small chunk into the chunks that import it, so a copy in each index chunk would download twice on /indexes/both. That's why it keeps a file. Webpack can place these modules in each page's chunk because its runtime looks modules up by id from any loaded chunk. Rolldown's ESM chunks import them from a fixed chunk.

On the app: with the atlas split gone, the three small modules downloaded twice on the heaviest pages may go too, as you suspected. I couldn't confirm that without the app.

pages-large builds the same output as before (39 JS files, 4 scripts and 1 stylesheet per page, the same bytes). Build time is within noise.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk

Please review exact head 3b5c6bab55c627cbdb7b503e1917b73ba0357e63 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 529bedb7.

This review, of 3b5c6bab

✅ Approved — The only earlier finding, the unmarked failing e2e cases, is fixed at this head. No new issues were found in the code changed since the last review.

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security-relevant issues in the changes.


📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry still matches the code.


📋 Code Quality: ✅ LGTM

The earlier WARNING is fixed:

  • The indexes request-count case in tests/e2e/pages-router-prod/shared-requests.spec.ts measures first, then calls test.fail() just before its parity assertion (line 229).
  • The atlas case passes as written after f3670b1, so it needs no marker.

In client-build-config.ts, the new helpers are consistent with how tests/pages-client-chunks.test.ts uses them. The inlining guards match the Rolldown restrictions the description lists.


⚡ Performance: ✅ LGTM

No performance issues in the changes.


📝 Documentation: ✅ LGTM

The README, differences.mdx and the example README still match the code.


Reviewed commit: 3b5c6bab

@ask-bonk

ask-bonk Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

…he client graph

collectUncopiedStylesheets walked every stylesheet's importers up to the
entries, which cost 279 ms of the client build on the large Pages Router
benchmark (about 800 stylesheets in 4000 modules). The client graph that
buildEnd already collects has the same entries for each module.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of a85e1e9c.

This review, of 529bedb7

✅ Approved — No new issues in the code changed since the last review, and the earlier findings are fixed or answered.

Not opened by the correctness review: 31 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/status-pill.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/media.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security-relevant issues in the changes:

  • Stylesheet hrefs come from the build manifest.
  • Attributes are escaped.
  • The deployment-ID query adds no new exposure.

📖 AGENTS.md: ✅ LGTM

The AGENTS.md entry still matches the code.


📋 Code Quality: ✅ LGTM

The new and changed helpers in client-build-config.ts are consistent with how tests/pages-client-chunks.test.ts uses them:

  • collectPagesClientGraph
  • collectUncopiedStylesheets
  • collectSharedGroupModules

The plugin clears its per-build state in buildStart, so the SSR build that follows sees empty sets. The test file's conditional expectations on supportsInlineCommonChunks cannot pass without checking anything.


⚡ Performance: ✅ LGTM

Reading the entries that load each stylesheet from the shared client graph removes the importer walk the build ran for every stylesheet.


📝 Documentation: ✅ LGTM

The README, differences.mdx and the example README still match the code.


Reviewed commit: 529bedb7

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — The only change since the last review is the AGENTS.md entry, which matches the code. A re-read of the rest of the pull request found no new issues.

Not opened by the correctness review: 29 changed files it was meant to read
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/arrow.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/box.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/ledger.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/person.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/truck.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/glyphs/unused.js
  • examples/pages-router-complex/__test_packages__/atlas-glyphs/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/grid-kit.module.css
  • examples/pages-router-complex/__test_packages__/atlas-grid-kit/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/index.d.ts
  • examples/pages-router-complex/__test_packages__/atlas-legacy-format/lib/pad.js
  • examples/pages-router-complex/lib/workbench/export/csv.ts
  • examples/pages-router-complex/lib/workbench/format/currency.ts
  • examples/pages-router-complex/lib/workbench/format/durations.ts
  • examples/pages-router-complex/lib/workbench/panel.module.css
  • examples/pages-router-complex/lib/workbench/reporting/breakdown-table.tsx
  • examples/pages-router-complex/lib/workbench/reporting/shared-axis.ts
  • examples/pages-router-complex/lib/workbench/reporting/trend-legend.tsx
  • examples/pages-router-complex/lib/workbench/summary-strip.tsx
  • examples/pages-router-complex/lib/workbench/tools/presets.json
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css
  • examples/pages-router-complex/pages/[zone]/workbench/desk.module.css.d.ts
  • examples/pages-router-complex/pages/[zone]/workbench/dispatch.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/index.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/inventory.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/ledger.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/reports.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/roster.page.tsx
  • examples/pages-router-complex/pages/[zone]/workbench/search.page.tsx

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Stylesheet hrefs come from the build manifest. Fetched CSS goes into <style> text nodes, not HTML markup. The nonce is read only from noscript[data-n-css]. The new CI matrix entry uses no secrets.


📖 AGENTS.md: ✅ LGTM

The new AGENTS.md entry matches the code: the Pages Router shared groups and the _app imports that stay out of pages-app.


📋 Code Quality: ✅ LGTM

Every client-navigation path passes the page's own stylesheets to the render. The pagesRenderId guard stops a navigation that was cancelled from switching stylesheets. Per-build plugin state is cleared in buildStart and generateBundle, so the SSR build that follows doesn't inherit the groups. The entry-code rewrite keeps the source map aligned. The deployment-ID query is handled the same way in the built asset URL helper, the Flight rows, the Pages stylesheet URLs and the inline-CSS lookup.


⚡ Performance: ✅ LGTM

The build reads the entries that load each stylesheet from the shared client graph, so it no longer walks the importers of every stylesheet.


📝 Documentation: ✅ LGTM

The README, differences.mdx and the example README still match the code.


Reviewed commit: a85e1e9c

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Please review exact head a85e1e9c5b6b6f64dbe2d93be5478e7b6593cd34 without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit. Only flag issues that affect real-world usage, not contrived edge cases.

@ask-bonk

ask-bonk Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

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