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 e538a18
Browse filesBrowse the repository at this point in the historyBrowse files
feat(javascript): name bindings by the keys and module names they spell, drop dead class parts and write exact fractions in the minifier (#22679)
* fix(javascript): keep the callers of an `__INLINE__` function reading their own parameters
* feat(javascript): name bindings by the keys and module names they spell, drop dead class parts and write exact fractions in the minifier
Keep a destructured, imported or exported name's own spelling where it
saves the `:` or ` as ` clause; drop an unused class run only for what
it extends, a derived constructor only forwarding to `super` and private
fields nothing reads; fold `[...].slice()`, merge spread calls across a
conditional; print `2/3` for `.6666666666666666`.
* fix(javascript): spell a binding only by a key or module name that is an identifier, quoted or not
* fix(javascript): never spell a binding by a name strict code cannot bind
* fix(javascript): keep a derived class's unread instance private fields
Adding one throws when `super()` returns an object already holding it,
which test262's privatefieldadd-typeerror reads.
* fix(javascript): merge spread calls only where no spread precedes the one they differ in
Its iteration ran after the conditional's test, and in the merged call runs
before it, where an iterator may change what the test reads.
* @property {EXPECTED_ANY=} keep_classnames which class names survive, collecting the declarators naming one under `classDeclarators`
1691
1718
* @property {boolean=} classDeclarators whether, under `keep_classnames`, the names declarators give anonymous classes are kept as `keep_fnames` keeps a function's
1692
1719
* @property {boolean=} parameterScopes whether names are scoped as the spec scopes them where terser does not: a parameter list's or a catch parameter's reads skip what the body declares, and a block's async or generator function stays in the block
1720
+
* @property {number=} spelledNames which names to collect that the mangler may give the name beside them to write less: 1 for an import's or export's, 2 for a key's too
* @property {PrintIdentifier[] | null} classDeclarators under `classDeclarators` and `keep_classnames`, the names declarators give anonymous classes
1703
1731
* @property {PrintIdentifier[]} catchParameters unless `ie8` or `safari10` move them, the catch parameters, each named where the mangler's walk meets its scope
1704
1732
* @property {boolean} namesPrivate whether the program names a private member, which renaming walks it for
1733
+
* @property {SpelledNames | null} spelledNames under `spelledNames`, the names a key or an import or export spells for a name beside it
1734
+
*/
1735
+
1736
+
/**
1737
+
* Where a name stands beside one spelled for it: a property's key, which the
1738
+
* name as its value lets print alone, or an import's or export's other name.
1739
+
* @typedef {object} SpelledNames
1740
+
* @property {PrintIdentifier[]} identifiers each name, its `definition` read once the analysis resolves
1741
+
* @property {string[]} spellings the name spelled beside each
1742
+
* @property {number[]} savings the characters each saves, its own name one long, where it takes the name spelled
1705
1743
*/
1706
1744
1707
1745
/**
@@ -1905,6 +1943,67 @@ class MinifierScopeAnalyzer extends ScopeAnalyzer {
1905
1943
this.currentLabel=null;
1906
1944
/** @type {PrintNode | null} the pattern the walk is inside, which `_markExport` counts from */
1907
1945
this.inDestructuring=null;
1946
+
/** @type {SpelledNames | null} */
1947
+
this.spelledNames=options.spelledNames
1948
+
? {identifiers: [],spellings: [],savings: []}
1949
+
: null;
1950
+
/** @type {boolean} whether a key spells a name, which prints alone where it is its value's */
0 commit comments