Repository navigation
Commit 5321871
committed
perf(javascript): minify with webpack's own parser, not terser's
The printer's tree is built by webpack's parser as it finishes each
statement, with that parser's tokens and comments, so an asset is read by
one parser rather than two. terser's parser stays behind it for what it
reads its own way: an expression, `strict`, TypeScript, a line opening an
HTML comment, and a source webpack's parser refuses.
A token is built only when a node is first given one. The parser reports
every token at its deepest, where frames are what it has least of, so
nothing is built there: the offsets, kinds and line breaks go into arrays,
and the comments of a gap into the list the tokens on both sides share,
which is one empty list wherever a gap holds none.
Output is byte for byte terser's over the 180 corpus cases and the 288
printer tests. Peak on a real bundle, minified with compress and mangle:
1121 -> 1048 MiB for 8.8 MiB of input, 1591 -> 1529 MiB for 17.3 MiB,
with the time unchanged either way.1 parent 9024861 commit 5321871
4 files changed
Lines changed: 791 additions & 45 deletions
File tree
- .changeset
- lib/javascript
- test/unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
0 commit comments