Skip to content

Commit 2acd821

Browse files
refactor(javascript): own terser's node walks and hand-written node methods in the printer (#22379)
1 parent e9998de commit 2acd821

5 files changed

Lines changed: 3073 additions & 117 deletions

File tree

‎docs/syntax.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Read this before touching the CSS, HTML or JavaScript parser, printer or minifie
2323

2424
- `lib/css/data.js` — every table the CSS minifier looks names up in, plus the arithmetic its math-function descriptors bind to: from `mdn-data` + `color-name` (box shorthands, color-argument and math functions, named colors) and the generator's `SUPPLEMENT` of spec-prose tables and math primitives, by `tooling/generate-css-data.js` — which also holds the value-definition-syntax parser those grammars are read with, and runs generation only as the entry point so its tests can require it.
2525
- `lib/html/data.js` — every table the HTML parser and minifier look names up in: reflected-attribute tables from webref's HTML IDL (`@webref/idl`, `@webref/elements`) plus the generator's `SUPPLEMENT` and `PARSER_TABLES` of §13.2 tree-construction vocabulary, by `tooling/generate-html-data.js` — which also emits the `// #region html entities` block in `lib/html/syntax-parser.js` from the vendored `tooling/html-entities.json` (WHATWG's named character references).
26-
- `lib/javascript/data.js` — the JS parser's and printer's Unicode tables in one module: run-length identifier ranges the tokenizer decodes at its first non-ASCII code point, and per-edition `\p{...}` property names (reached only for a pattern the engine rejected), which `tooling/generate-js-data.js` reads from the pinned acorn devDependency — bumping it moves them; plus the Unicode 8.0 identifier ranges the printer writes unescaped (so older engines read its output), read from terser's own frozen tables; plus the native-object tables of pure globals, calls, methods and static properties the compressor reads (`NATIVE_*`, built only when `nativeObjectTables()` is called, so the parser loading the module allocates none), each name with its `unsafe` / `builtins_ecma >= N` conditions in terser's order, parsed with acorn out of terser's `lib/compress/native-objects.js`.
26+
- `lib/javascript/data.js` — the JS parser's and printer's Unicode tables in one module: run-length identifier ranges the tokenizer decodes at its first non-ASCII code point, and per-edition `\p{...}` property names (reached only for a pattern the engine rejected), which `tooling/generate-js-data.js` reads from the pinned acorn devDependency — bumping it moves them; plus the Unicode 8.0 identifier ranges the printer writes unescaped (so older engines read its output), read from terser's own frozen tables; plus the native-object tables of pure globals, calls, methods and static properties the compressor reads (`NATIVE_*`, built only when `nativeObjectTables()` is called, so the parser loading the module allocates none), each name with its `unsafe` / `builtins_ecma >= N` conditions in terser's order, parsed with acorn out of terser's `lib/compress/native-objects.js`. Plus terser's node classes (`nodeClasses()`, built on call too): each class's base, the fields its constructor copies, and its children in the order its `_walk` and `_children_backwards` reach them, parsed out of terser's `lib/ast.js` — the printer builds every node's walk from them.
2727

2828
## CSS
2929

0 commit comments

Comments
 (0)