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 e038bb5
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
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`.
* @property {EXPECTED_ANY=} keep_classnames which class names survive, collecting the declarators naming one under `classDeclarators`
1691
1699
* @property {boolean=} classDeclarators whether, under `keep_classnames`, the names declarators give anonymous classes are kept as `keep_fnames` keeps a function's
1692
1700
* @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
1701
+
* @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
1712
* @property {PrintIdentifier[]} catchParameters unless `ie8` or `safari10` move them, the catch parameters, each named where the mangler's walk meets its scope
1704
1713
* @property {boolean} namesPrivate whether the program names a private member, which renaming walks it for
1714
+
* @property {SpelledNames | null} spelledNames under `spelledNames`, the names a key or an import or export spells for a name beside it
1715
+
*/
1716
+
1717
+
/**
1718
+
* Where a name stands beside one spelled for it: a property's key, which the
1719
+
* name as its value lets print alone, or an import's or export's other name.
1720
+
* @typedef {object} SpelledNames
1721
+
* @property {PrintIdentifier[]} identifiers each name, its `definition` read once the analysis resolves
1722
+
* @property {string[]} spellings the name spelled beside each
1723
+
* @property {number[]} savings the characters each saves, its own name one long, where it takes the name spelled
1705
1724
*/
1706
1725
1707
1726
/**
@@ -1905,6 +1924,52 @@ class MinifierScopeAnalyzer extends ScopeAnalyzer {
1905
1924
this.currentLabel=null;
1906
1925
/** @type {PrintNode | null} the pattern the walk is inside, which `_markExport` counts from */
1907
1926
this.inDestructuring=null;
1927
+
/** @type {SpelledNames | null} */
1928
+
this.spelledNames=options.spelledNames
1929
+
? {identifiers: [],spellings: [],savings: []}
1930
+
: null;
1931
+
/** @type {boolean} whether a key spells a name, which prints alone where it is its value's */
0 commit comments