You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 046a004
Browse filesBrowse the repository at this point in the historyBrowse files
test(size): report whole bundles of sample apps for every target and library type (#22997)
* test(size): report whole bundles of generated React apps
Build three apps from the realistic-app generator (100, 1k and 5k
components) in yarn test:size and add a Sample apps table with each
app's total gzip and raw size.
* test(size): read sample apps from test/sizeCoreReports
Each app is a directory with a webpack config and an optional
options.mjs setup(), like benchmarkCases, so new apps need no
harness change.
* test(size): add node, webworker, ESM and per-library-type sample apps
Cover web, node (React SSR) and webworker targets with script and ES
module output, and build one library per output.library.type read from
the schema; a multi-compiler app reports one row per compiler.
-**Purpose**: Whole applications for `yarn test:size` ([below](#codesizetestcasessizejs)), whose report gives each one's total download in a **Sample apps** table.
115
+
-**A case** is a directory with a `webpack.config.mjs` (or `.js`; an array builds one compiler per entry, each reported on its own row) and, optionally, an `options.mjs` whose exported `setup()` runs first to generate or install its sources (into `generated/`, which git ignores). The harness sets only `context`, `output.path`, `mode: "production"` when unset and quiet logging; everything else is the application's own configuration.
116
+
-**Today**, each target with script (or CommonJS) and ES module output (`-esm`):
117
+
-`web`: `react-100`, `react-1k`, `react-5k` and `react-1k-esm`, React apps of that many components (lazy routes, CSS modules, JSON, SVG) from the `realistic-app` benchmark's generator (`test/harness/benchmark/create-app.mjs`).
118
+
-`node`: `node-ssr` and `node-ssr-esm`, that app rendered on the server by an `http` server with `react-dom/server` (`test/harness/size/create-server.mjs`).
119
+
-`webworker`: `webworker` and `webworker-esm`, a message loop lazily loading 40 data tasks built on `lodash-es` and `date-fns` (`test/harness/size/create-worker.mjs`).
120
+
-`library`: one small library built once per `output.library.type`, the types read from the schema.
121
+
112
122
### `specCases/`
113
123
114
124
-**Purpose**: Holds the runners for specification-conformance suites.
@@ -153,8 +163,8 @@ Directories come first, in alphabetical order, then the individual files worth t
153
163
### `CodeSizeTestCases.size.js`
154
164
155
165
-**Purpose**: Measures how large the code webpack generates is, so a change to `lib/` that grows (or shrinks) every bundle is visible.
156
-
-**Usage**: `yarn test:size` builds every `configCases/` case — one plain Node.js process, outside jest, no worker pool — and writes a JSON report of what each case emitted: the raw, gzip, brotli and zstd size of every asset, plus a per-runtime-module breakdown (total bytes over the suite, how many cases emit it, the biggest single instance) — which is what shows _which_ runtime grew, which is no longer emitted at all, and which one is simply large. The CI job (`.github/workflows/code-size.yml`) compares the report against the one `main` last uploaded, posts it as a pull request comment (updated in place on every push) and repeats it in the job summary.
157
-
-**What the comparison shows**: how many cases, runtime modules and assets are changed / new / deleted / unchanged, then **one row per changed asset** — raw before → after, and the percentage each of gzip, brotli and zstd moved. A suite-wide total is deliberately not reported: a single number over 1400 cases hides which file moved, which is the only actionable part. With no baseline to compare against, the same table ranks the biggest assets instead.
166
+
-**Usage**: `yarn test:size` builds every `configCases/` case, plus every application in [`sizeCoreReports/`](#sizecorereports) (reported as `apps/<case>`) — one plain Node.js process, outside jest, no worker pool — and writes a JSON report of what each case emitted: the raw, gzip, brotli and zstd size of every asset, plus a per-runtime-module breakdown (total bytes over the suite, how many cases emit it, the biggest single instance) — which is what shows _which_ runtime grew, which is no longer emitted at all, and which one is simply large. The CI job (`.github/workflows/code-size.yml`) compares the report against the one `main` last uploaded, posts it as a pull request comment (updated in place on every push) and repeats it in the job summary.
167
+
-**What the comparison shows**: how many cases, runtime modules and assets are changed / new / deleted / unchanged, then **one row per changed asset** — raw before → after, and the percentage each of gzip, brotli and zstd moved. A suite-wide total is deliberately not reported: a single number over 1400 cases hides which file moved, which is the only actionable part. The applications are the exception: a **Sample apps** table gives each one's whole download (gzip and raw, summed over its assets), which per-asset rows hide once code moves between chunks. With no baseline to compare against, the same table ranks the biggest assets instead.
158
168
-**It never fails.** There is nothing to assert here and no size budget to breach: a growing bundle is information, not a defect. Cases whose expected result _is_ a build error emit nothing and are reported as such, with the reason, rather than counted as failures.
159
169
-**Options**: `--output <file>` (report path), `--baseline <file>` (report to compare against), `--summary <file>` (append the markdown comparison, e.g. `$GITHUB_STEP_SUMMARY`), `--filter` / `--negative-filter` (regexps matched against `<category>/<case>`, also read from `FILTER` / `NEGATIVE_FILTER`).
160
170
-**Note**: the cases are built with the defaults a user gets — minification on, no `output.pathinfo` — not with the `ConfigTestCases` ones. Needs Node.js >= 22.15 for zstd.
-`templates/` — suite drivers (`TestCases.js`, `ConfigTestCases.js`, `HotTestCases.js`, `WatchTestCases.js`); the top-level `*.test.js` / `*.basictest.js` / `*.longtest.js` are thin shims over them. Each exports `describeCases(config)` and resolves case directories against `test/`, never its own. The shims' option sets live together in `templates/variants.js` (re-exported as `variants`) so suite differences read side by side; there's one shim per entry because jest parallelizes per file, not per describe.
87
87
-`harness/` — what runs the suites: jest lifecycle (`globalSetup.js`, `globalTeardown.js`, `setupTestFramework.js`), the `patch-node-env.js` environment, the crash reporter, the case `runner/`, the `snapshot/` resolver, and `runtimes/` (preload/setup files for Bun and Deno). Reusable assertions and fixtures go in `helpers/`.
88
88
-`RoundTripConfigCases` re-bundles the output of `configCases` that have a `roundTrip.js`.
Copy file name to clipboardExpand all lines: docs/performance.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,7 @@ Pitfalls that produced wrong conclusions here:
50
50
-**Which way?** 🔴 ↑ grew, 🟢 ↓ shrank.
51
51
-**Change or new?** Assets both runs emit are changes; ones only one run emits are new or deleted files, not deltas. They're in separate tables — changed first and unfolded, new/deleted folded, each with its own row budget — and separate verdict rows (`Changed …` vs `New` / `Deleted`), so new test cases' bundles don't bury real changes.
52
52
-**webpack or the case?** A bundle is a function of its case's source, so adding assertions to a `configCases/` case grows its bundle without touching `lib/`. The report measures each case's module source and splits changed assets: `Changed, test untouched` is webpack's doing and the row size claims are read from; `Changed, test edited` has a `Test edit` column with bytes of source gained — a bundle growing less than its case isn't a regression. Cite the first row, never suite-wide numbers, when a PR touches both `lib/` and tests.
53
+
-**What does a whole app download?** The **Sample apps** table sums every asset of each application in `test/sizeCoreReports/` (web, node and webworker apps with script and ES module output, and a library per `output.library.type`): the one place the report reads like a real bundle, since a config case isolates a single feature.
53
54
-**Did a runtime gain or lose a runtime module?** A second table counts runtime modules per runtime and names those that came or went, split the same way (a runtime a new case brought gained nothing). Deliberately no per-runtime-module bytes (not what anyone downloads); the count catches a runtime module added for one target and forgotten for another.
54
55
55
56
Read the "emitted nothing" note first: a case whose build now errors contributes no bytes, which otherwise looks like an improvement. When the numbers moved, say what it reported in the PR.
0 commit comments