Skip to content

chore(scripts): size:pages --bundler rolldown measures each page as a Vite app ships it - #12052

Open
cixzhang wants to merge 10 commits into
mainfrom
tools/size-pages-rolldown
Open

cixzhang wants to merge 10 commits into
mainfrom
tools/size-pages-rolldown

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

A release gate should measure the JavaScript a consumer's app ships. pnpm size:pages builds each reference page with esbuild and code splitting, and a Vite app built from the same package loads 4–11% less gzip up front on the reference pages. Part of the gap is placement: esbuild puts modules into up-front chunks because unused sibling components reach them through import() (about half of the minified gap on the docs page, a fifth or less on the others). The rest is how each bundler generates and minifies code. Either way, the esbuild number is not what a Vite app ships.

Intended invariant

Without --bundler, pnpm size:pages behaves as before: same build, same numbers, same text and JSON, with no bundler key. The new mode is opt-in, and only it adds "bundler": "rolldown" to the JSON.

Change

--bundler rolldown builds each reference page as a production Vite app. Vite 8 bundles with Rolldown.

  • The build: the same page entry the esbuild path uses, which exports each component from the built package. React, React DOM and StyleX stay external, as on the esbuild path. Otherwise Vite's production defaults apply: module preload stays on, so its helper code counts as a Vite app ships it. Options go through build.rolldownOptions, and the chunks are read from memory (write: false).
  • What it measures, from Rolldown's output chunks: the entry chunk plus the chunks it imports statically, meaning what loads up front:
    • minified and gzip bytes;
    • kept modules: modules with rendered code in those chunks, not counting a bundler's virtual helper modules;
    • chunk count and chunk depth.
      import() targets load later and are not counted. The Rolldown chunks are mapped to an esbuild metafile's outputs shape (packages left external stay marked external), so the same shared walks give both builds' figures: eagerText and gzipBytes from the size helper, and this script's chunkGraphStats and keptModuleCount.
  • The esbuild figures stay, as a secondary table under the others ("built by esbuild with code splitting, for the earlier trend"), so the existing trend stays readable. In JSON they appear under esbuild in base, head and delta.
  • The PASS/FAIL gate (--unused-on) and its JSON read the chosen bundler's gzip delta.
  • Unchanged: the static module graph (modules reached and module depth). It comes from the page's input graph and does not depend on the bundler.
  • No new dependency: this uses the repository's existing vite devDependency (the catalog's ^8.1.3; 8.3.5 installed), which bundles with Rolldown.

Evidence

  • Failure before the change: only esbuild-split sizes, which overstate what a Vite app ships up front.

  • Success after the change: on main at 88c4e0a, with base and head on the same commit (all deltas 0), first-load minified / gzip bytes:

    Page Vite (Rolldown) esbuild, split Rolldown vs esbuild (gzip)
    docs 208,599 / 66,949 229,089 / 75,070 −10.8%
    form 229,841 / 74,470 239,364 / 78,209 −4.8%
    menu 304,882 / 101,247 314,646 / 106,396 −4.8%
    table 331,662 / 111,496 343,947 / 117,664 −5.2%
  • Product/runtime behavior verified unchanged: no package source changes.

  • CI impact: none; no workflow changes. A Rolldown run adds one Vite build per page and side, a few seconds each.

Scope

Components: none (repository script and its test)

Owner: Code Quality & Guardrails (Table worker). Builds on #11994 (merged); based on main.

Overlap checked: #11994 and #11840, both merged. This branch merges main, and --help (#11840) now lists --bundler.

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project node scripts/measure-reference-pages.test.mjs .github/scripts/lib/component-size.test.mjs: 37 tests pass on the merged branch. The new ones cover:
    • rolldownPageStats on fixture output: counts the entry and its static imports, leaves out an import() target, an asset, an external package and a virtual helper module, counts kept modules, and fails without an entry chunk;
    • measurePageRolldown, as a real Vite build of a small fixture dist: one up-front chunk, two kept modules, and the lazy module out of the first load;
    • --bundler parsing: the esbuild default, rolldown, and an unknown bundler refused; --help lists --bundler;
    • a gate that reads the Rolldown delta while the esbuild delta shows in its own table.
  • node scripts/measure-reference-pages.mjs --base 88c4e0a8a7 --head 88c4e0a8a7 --bundler rolldown --unused-on table: the numbers above, with PASS.

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 7:48am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 7:44 AM UTC

@astracat-bot astracat-bot Bot left a comment •

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.

Changes requested: the Rolldown mode is a useful addition and its figures reproduce, but four points need fixing before INV10 reports can rely on it.

  • modulePreload: false (scripts/measure-reference-pages.mjs:509) leaves out the preload code a default Vite production build ships, 420 B gzip on the menu page and 374 B on the table page, so keep Vite's default or say in the title, the JSDoc and the description that the figures exclude it.
  • rolldownPageStats (:454-462, :469) re-implements the chunk walk and eager-text join that importLevels and eagerText in .github/scripts/lib/component-size.js and this file's chunkGraphStats already provide, so map Rolldown's chunks to that graph shape and call the shared helpers.
  • Without --bundler, --json now prints "bundler": "esbuild" (:609, :613), which contradicts the description's "same text and JSON", so add the key only for rolldown or reword the invariant.
  • The description credits esbuild's chunk placement with the whole 5–11% gap, but the extra up-front modules account for about half of the minified gap on docs and about a fifth or less on form, menu and table, so reword that sentence.

Smaller notes: in Rolldown mode keptModules also counts Vite's and Rolldown's virtual modules, and build.rollupOptions is a deprecated alias of rolldownOptions in Vite 8.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: the script builds each page with esbuild and code splitting — verified (size helper options, splitting: true; measurePage).
  • Claim: esbuild keeps more modules up front than Vite — verified: 10, 4, 1 and 2 more first-load modules on docs, form, menu and table.
  • Claim: that placement is why esbuild's figures are 5–11% higher — false in part: those modules carry 11,050 of 20,348 minified bytes of the gap on docs and 581 of 9,549, 2,148 of 10,830 and 2,756 of 13,324 elsewhere.
  • Claim: without --bundler, same build, numbers and text — verified (text output identical to the base script's); same JSON — false (bundler key, :609, :613).
  • Claim: the mode builds each page as a production Vite app, and Vite 8 bundles with Rolldown — verified for Vite 8.3.5 with Rolldown 1.2.16, except that module preload is off (:509), unlike a default production build.
  • Claim: same page entry, with React, React DOM and StyleX external — verified (:491-500, isAppExternal over the shared externals list).
  • Claim: minification on, preload off, chunks read from memory — verified (:506-509).
  • Claim: it measures the entry chunk and its static imports and leaves import() targets out — verified (:454-462; tests at scripts/measure-reference-pages.test.mjs:179 and :196).
  • Claim: gzip via the shared gzipBytes; kept modules are modules with rendered code; chunk count and depth — verified (:463-475); kept modules also include bundler-virtual modules.
  • Claim: esbuild figures stay as a secondary table and under esbuild in base, head and delta — verified (:186-198, :88, :109-116).
  • Claim: PASS/FAIL and its JSON read the chosen bundler's gzip delta — verified (:126-128; test at scripts/measure-reference-pages.test.mjs:385).
  • Claim: modules reached and module depth stay on the input graph — verified (:534-538).
  • Claim: no new dependency; the existing vite devDependency (catalog ^8.1.3, 8.3.5 installed) — verified (root package.json, workspace catalog, lockfile).
  • Claim: the per-page table of first-load sizes — verified: minified bytes match exactly for both bundlers; gzip within 0.3% on this platform.
  • Claim: no package source and no workflow changes, and a Rolldown run adds one Vite build per page and side — verified (two script files; :539; about 2 s for four pages here).
  • Claim: stacked on #11994, and #11840 adds --help text — verified (base branch is #11994's head; #11840's description).
  • Claim: no public API, product, visual or policy change, and no internal context — verified.
  • Claim: 22 tests pass, covering stats on fixture output, a real Vite build, --bundler parsing and the gate — verified (22 passed; tests at scripts/measure-reference-pages.test.mjs:179, :188, :196, :385, :484).
  • File scripts/measure-reference-pages.mjs — findings 1–3 above, plus the two smaller notes.
  • File scripts/measure-reference-pages.test.mjs — clear; it matches the script's new exports, though isAppExternal has no test of its own.

Automated review (maintainer link)

Comment thread scripts/measure-reference-pages.mjs Resolved
Comment thread scripts/measure-reference-pages.mjs Resolved
Comment thread scripts/measure-reference-pages.mjs Resolved
Comment thread scripts/measure-reference-pages.mjs Resolved

@astracat-bot astracat-bot Bot left a comment

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.

Approved pending CI: CI has not run on this head yet, and it runs once the pull request is ready for review and targets main.

The Rolldown mode now keeps Vite's default module preload, computes its figures through the shared size walks, and leaves the default text and JSON output byte-identical, so the points from the earlier review are resolved. Two small optional follow-ups:

  • With module preload counted, chunk placement explains 22% of the minified gap on the menu and table pages (2,148 of 9,764 B and 2,756 of 12,285 B), so "about a fifth" describes it better than "a fifth or less".
  • isAppExternal still has no test; importing react/jsx-runtime in the measurePageRolldown fixture would catch a pattern that stops matching and silently bundles React.
Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Without --bundler, the build, numbers, text and JSON are unchanged, with no bundler key: verified, byte-identical text and JSON against the base script on one Core build.
  • Only the Rolldown mode adds "bundler": "rolldown" to the JSON: verified (scripts/measure-reference-pages.mjs:621-625, a JSON run).
  • A Vite app built from the same package loads 4–11% less gzip up front on the reference pages: verified, 4.8–11.0% in a run at this head.
  • Part of the gap is module placement (about half on docs, a fifth or less elsewhere) and the rest is code generation and minification: verified with a note, 54% on docs, 6% on form, 22% on menu and table.
  • The Rolldown build uses the same page entry with React, React DOM and StyleX external: verified (:507-529, the shared external list).
  • Vite's production defaults apply, with module preload on: verified, no preload override, and the preload helper is in every page's first load.
  • Options go through build.rolldownOptions and chunks are read from memory: verified (:522-529).
  • The figure is the entry chunk plus its static imports, with import() targets not counted: verified (shared walks over static edges; tests at scripts/measure-reference-pages.test.mjs:180 and :197).
  • Kept modules leave out a bundler's virtual helper modules: verified (:465-469, test at :180).
  • Rolldown's chunks are mapped to the esbuild metafile outputs shape with externals marked, so the same shared walks give both builds' figures: verified (:445-493).
  • The esbuild figures stay as a secondary table and under esbuild in base, head and delta: verified (:88, :109-116, :186-198, a JSON run).
  • The PASS/FAIL gate and its JSON read the chosen bundler's gzip delta: verified (:126-128, test at :387).
  • The static module graph is unchanged and comes from the input graph: verified (:549-553).
  • No new dependency; the existing Vite 8 devDependency (8.3.5 installed) bundles with Rolldown: verified, root manifest, workspace catalog and lockfile unchanged.
  • The per-page figures table: verified, minified bytes match exactly for both bundlers; gzip is within 0.5%.
  • No package source or workflow changes: verified, two files under scripts/.
  • The 22 tests pass and the new ones cover the listed cases: verified, 22 passed.
  • The gate run with the same commit on both sides prints PASS: verified, PASS at +0 B.
  • Stacked on #11994 and based on its branch: verified, the base branch's head is that pull request's head.
  • Overlap with #11840 is limited to its --help text in the argument parser: verified, it touches the same two files and adds the usage text and its tests.
  • A Rolldown run adds one Vite build per page and side, a few seconds each, with no CI impact: verified, each run finished within seconds and no workflow changes.
  • No public API, product behavior, visual direction or policy change: verified.
  • Public text contains no internal context: verified.
  • scripts/measure-reference-pages.mjs: clear, with two non-blocking notes (an untested isAppExternal, a no-op template literal at :177).
  • scripts/measure-reference-pages.test.mjs: clear; its imports and cases match the script's new exports and output.

Automated review (maintainer link)

…down

# Conflicts:
#	scripts/measure-reference-pages.mjs
#	scripts/measure-reference-pages.test.mjs
@cixzhang
cixzhang changed the base branch from tools/size-pages-chunks-depth to main November 19, 2026 07:21
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

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.

Approved pending CI: CI has not run on this head yet; it runs once the pull request is marked ready for review.

The --bundler rolldown mode keeps the default report byte-identical, measures the first load through the shared size walks with Vite's defaults, and --help now lists the flag. Two small optional follow-ups carry over:

  • With module preload counted, chunk placement explains 22% of the minified gap on the menu and table pages (2,148 of 9,764 B and 2,756 of 12,285 B), so "about a fifth" describes it better than "a fifth or less".
  • isAppExternal still has no test; importing react/jsx-runtime in the measurePageRolldown fixture would catch a pattern that stops matching and silently bundles React.
Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Without --bundler, the build, numbers, text and JSON are unchanged, with no bundler key: verified, byte-identical text and JSON against main's script on one Core build.
  • Only the Rolldown mode adds "bundler": "rolldown" to the JSON: verified (scripts/measure-reference-pages.mjs:653-657, a JSON run).
  • A Vite app built from the same package loads 4–11% less gzip up front on the reference pages: verified, 4.8–11.0% on the description's commit and 4.9–10.6% on this head's Core.
  • Part of the gap is chunk placement (about half on docs, a fifth or less elsewhere) and the rest is code generation and minification: verified with a note, 54% on docs, 6% on form, 22% on menu and table.
  • --bundler rolldown builds each page as a production Vite app, which bundles with Rolldown: verified (:499-534; Vite 8.3.5 in the lockfile).
  • The Rolldown build uses the same page entry with React, React DOM and StyleX external: verified (:507-528, the shared external list through isAppExternal).
  • Vite's production defaults apply, with module preload on: verified, no preload override (:517-531).
  • Options go through build.rolldownOptions and chunks are read from memory: verified (:522-529).
  • The figure is the entry chunk plus its static imports, with import() targets, assets, external packages and virtual helper modules not counted: verified (:445-493; tests at scripts/measure-reference-pages.test.mjs:181 and :198).
  • Rolldown's chunks are mapped to the esbuild metafile outputs shape with externals marked, so the same shared walks give both builds' figures: verified (:445-476, :484-493).
  • The esbuild figures stay as a secondary table and under esbuild in base, head and delta: verified (:88, :109-116, :186-198, a JSON run).
  • The PASS/FAIL gate and its JSON read the chosen bundler's gzip delta: verified (:119-130; test at :388).
  • The static module graph is unchanged and comes from the input graph: verified (:549-553).
  • No new dependency; the existing Vite devDependency (catalog ^8.1.3, 8.3.5 installed) is used: verified, no manifest, catalog or lockfile change in the pull request.
  • The per-page figures table on the description's commit: verified, all eight minified figures match exactly; gzip is within 0.5%.
  • No package source or workflow changes, and no CI impact: verified, two files under scripts/.
  • A Rolldown run adds one Vite build per page and side, a few seconds each: verified, each run finished within seconds.
  • Builds on the merged module-graph change and is based on main: verified, that change is on main and the base branch is main.
  • The branch merges main, and --help from the merged help change now lists --bundler: verified (:581-583; test at scripts/measure-reference-pages.test.mjs:513).
  • The 37 tests pass and the new ones cover the listed cases: verified, 37 passed.
  • The gate run with the same commit on both sides prints PASS: verified, PASS at +0 B.
  • No public API, product behavior, visual direction or policy change: verified.
  • Public text contains no internal context: verified.
  • scripts/measure-reference-pages.mjs: clear, with one non-blocking note (isAppExternal at :429-436 is untested).
  • scripts/measure-reference-pages.test.mjs: clear; its imports and cases match the script's new exports, output and help text.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 29f61bb2 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant