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 af8bf0b
Browse filesBrowse the repository at this point in the historyBrowse files
build(tooling): compare JavaScript parsers and printers, and widen the CSS and HTML fixtures (#22010)
* build(tooling): compare JavaScript parsers and printers, and hold them to acorn
The CSS and HTML comparisons already weigh what webpack's own parser and
printer cost against the ecosystem's. This is the same three tables for
JavaScript, over fourteen bundles as they ship — jQuery through the 8.9 MB
TypeScript one, ES5 and modern, script and module.
webpack owns a parser there and no printer, so it has a row in the parse
table only, and that table's last column is what the comparison is for: every
ESTree parser is held against acorn's tree and the first node where the two
differ is named, so a divergence in `lib/javascript/syntax.js` is a line of
output rather than a bug someone hits later. A parser answering in a dialect
of its own reads as `own dialect` instead of as a disagreement.
* build(tooling): widen what the comparisons are measured over
Every fixture so far was source as its author wrote it, which is not the
shape most of what a build reads is in. The JavaScript comparison gains
minified bundles (jQuery, React DOM and Vue as they ship to production, plus
Swagger UI's own bundle), a modern ESM one written in classes and private
fields (pdf.js), the smallest module worth timing (Preact) and two more that
dwarf the rest (ECharts, Immutable).
CSS gains the shapes the framework sheets do not have: an icon font's
thousands of one-declaration rules, a sheet that is custom properties and
nothing else, and four more component and widget sheets.
HTML gains the parts of §13.2 nothing there reached — a document that is all
tables, one that leans on every recovery rule the spec writes down, one built
out of templates and a declarative shadow root, and an inlined icon sprite
for foreign content.
* build(tooling): read what oxc refused rather than what it recovered
oxc does not throw on a file it cannot parse: it answers with whatever tree
or text it salvaged and the diagnostics beside it. The parse row then read a
refusal as a tree that merely disagreed with acorn's, and the minify row read
one as an empty output — which is how `oxc-minify` first came out at 0.0 KB
with every property name lost. Both rows raise the first diagnostic now, so a
refusal reads as one.
-`hot/` — Runtime code shipped to browsers for HMR (browser-side, not Node tooling).
94
94
-`bin/` — `webpack` CLI entry point.
95
-
- `tooling/` — Repo-internal scripts: build/codegen (runtime/wasm generators, hash-debug tool) invoked by `yarn fix:special`, plus standalone analysis tools such as `compare-css-tools.js` / `compare-html-tools.js` (`yarn benchmark:css-tools`, `yarn benchmark:html-tools`), which share the measuring harness in `compare-tools-harness.js`. Those two need no arguments and no reading of their source: each runs webpack's CSS/HTML parser and printer and the ecosystem's over popular framework stylesheets and real documents, printing **three tables per fixture** — parsing alone, parsing and printing readably (`beautify`), and parsing and printing minified (`minify`) — so what a parse costs is separated from what the printing and the transforms on top of it cost. Every table reports best-of-3 wall and cpu ms and the worker's own peak RSS (each tool × fixture measured in its own process, so the numbers are attributable; read from `/proc/self/status`, since Linux carries `maxRSS` across `fork`+`exec` and a worker asking for its own would report the parent's). **Read wall and cpu together**: cpu above wall is a tool using more than one core (V8's background threads, a native thread pool), cpu below it is a tool waiting rather than computing. A tool that works in a service process of its own says so in its name and reports `-` for cpu and peak, which are spent where nothing here can see them — esbuild is the one today. The two printing tables add output size raw and under gzip/brotli/zstd (the `test:size` settings) and whether the output lost classes / changed the DOM ("rejects it" rows mean the tool errored on that input). A round-trip printer that reformats nothing — postcss for CSS, parse5 for HTML — sits in the `beautify` table as the floor the others are read against. `FIXTURE=`, `TOOL=` and `STAGE=` narrow a run to matching rows. They install the packages they compare against into `node_modules/.cache/` on first run rather than into webpack's dependencies; expect the first run to install for a minute and every full run to take upwards of ten. `check-comment-length.js` (`yarn lint:comments`) reports the plain comments a change grows past the two-line limit of [Code comments](#code-comments). `measure-color-agreement.js` (`yarn measure:color-agreement`) is the third: it asks a real browser for its own color conversions rather than for a pixel, and prints how far they sit from webpack's — which is where the rounding margins in `lib/css/syntax.js` and the list of spaces an engine reads through another transfer come from. Re-run it (a few seconds; `PUPPETEER_EXECUTABLE_PATH` picks the binary) rather than adjusting either by hand.
95
+
- `tooling/` — Repo-internal scripts: build/codegen (runtime/wasm generators, hash-debug tool) invoked by `yarn fix:special`, plus standalone analysis tools such as `compare-css-tools.js` / `compare-html-tools.js` / `compare-js-tools.js` (`yarn benchmark:css-tools`, `yarn benchmark:html-tools`, `yarn benchmark:js-tools`), which share the measuring harness in `compare-tools-harness.js`. Those three need no arguments and no reading of their source: each runs what webpack owns for that language and the ecosystem's equivalents over popular framework stylesheets, real documents and shipped JavaScript bundles, printing **three tables per fixture** — parsing alone, parsing and printing readably (`beautify`), and parsing and printing minified (`minify`) — so what a parse costs is separated from what the printing and the transforms on top of it cost. Every table reports best-of-3 wall and cpu ms and the worker's own peak RSS (each tool × fixture measured in its own process, so the numbers are attributable; read from `/proc/self/status`, since Linux carries `maxRSS` across `fork`+`exec` and a worker asking for its own would report the parent's). **Read wall and cpu together**: cpu above wall is a tool using more than one core (V8's background threads, a native thread pool), cpu below it is a tool waiting rather than computing. A tool that works in a service process of its own says so in its name and reports `-` for cpu and peak, which are spent where nothing here can see them — esbuild is the one today. The two printing tables add output size raw and under gzip/brotli/zstd (the `test:size` settings) and whether the output lost classes / changed the DOM / stopped naming a property ("rejects it" rows mean the tool errored on that input). The JavaScript one is shaped by webpack owning a parser there and no printer: webpack has a row in the parse table only, and that table's last column holds every ESTree parser against acorn's tree and names the first node where the two differ — which is how a divergence in `lib/javascript/syntax.js` is caught — while a parser answering in a dialect of its own reads as `own dialect` rather than as a disagreement. A round-trip printer that reformats nothing — postcss for CSS, parse5 for HTML — sits in the `beautify` table as the floor the others are read against. `FIXTURE=`, `TOOL=` and `STAGE=` narrow a run to matching rows. They install the packages they compare against into `node_modules/.cache/` on first run rather than into webpack's dependencies; expect the first run to install for a minute and every full run to take upwards of ten. `check-comment-length.js` (`yarn lint:comments`) reports the plain comments a change grows past the two-line limit of [Code comments](#code-comments). `measure-color-agreement.js` (`yarn measure:color-agreement`) is the third: it asks a real browser for its own color conversions rather than for a pixel, and prints how far they sit from webpack's — which is where the rounding margins in `lib/css/syntax.js` and the list of spaces an engine reads through another transfer come from. Re-run it (a few seconds; `PUPPETEER_EXECUTABLE_PATH` picks the binary) rather than adjusting either by hand.
96
96
-`assembly/` — WebAssembly source for the hash function.
97
97
-`setup/` — One-time setup. `setup.js` (`yarn setup`) is the only entry point and picks its own path: a contributor at a terminal gets the interactive one, which installs yarn when it is missing and links through yarn's registry, while everything else gets the non-interactive one — it verifies the lockfile instead of rewriting it, installs no global yarn, and links the checkout in as `node_modules/webpack` without touching yarn's machine-global registry. What it reads is both streams being a terminal plus an unset `CI`, never a list of vendor variables, so an agent nobody has heard of yet takes the safe path — but one that allocates a PTY reads as a contributor, and should set `WEBPACK_SETUP=automated`, which with `interactive` forces either path. Safe to re-run.
98
98
@@ -283,7 +283,7 @@ A perf/memory claim needs evidence, and the cheap kinds are the trustworthy ones
283
283
284
284
`FILTER="<case-name>" yarn benchmark` drives the repo's own cases; `test/benchmarkCases/` is the fixture set.
285
285
286
-
A claim about **webpack's CSS or HTML minifierversus the ecosystem's** (size, speed, memory, or safety) is already harnessed: run `yarn benchmark:css-tools` / `yarn benchmark:html-tools` and read the tables — see the `tooling/` entry in [Architecture](#architecture) for what they report — rather than hand-rolling a comparison.
286
+
A claim about **webpack's CSS or HTML minifier, or its JavaScript parser, versus the ecosystem's** (size, speed, memory, or safety) is already harnessed: run `yarn benchmark:css-tools` / `yarn benchmark:html-tools` / `yarn benchmark:js-tools` and read the tables — see the `tooling/` entry in [Architecture](#architecture) for what they report — rather than hand-rolling a comparison.
287
287
288
288
A claim about the **size of what webpack emits** is the counting kind, and `yarn test:size` is how it is counted: it builds every `configCases/` case with the defaults a user gets and reports the raw/gzip/brotli/zstd size of every asset, so a change to `lib/runtime/` or to a dependency template shows up as bytes on the wire. Compare two runs with `--baseline <report>`; the `Code Size` CI job does the same against the report `main` last uploaded and comments the diff on the pull request.
0 commit comments