terser 5.12.0 → 5.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/bundle.min.js +24 -1
- package/lib/output.js +2 -1
- package/lib/scope.js +22 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bundle.min.js
CHANGED
@@ -7901,7 +7901,8 @@ function OutputStream(options) {
|
|
7901
7901
|
var p = output.parent();
|
7902
7902
|
if (this.args.length === 0
|
7903
7903
|
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|
7904
|
-
|| p instanceof AST_Call && p.expression === this
|
7904
|
+
|| p instanceof AST_Call && p.expression === this
|
7905
|
+
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
|
7905
7906
|
return true;
|
7906
7907
|
});
|
7907
7908
|
|
@@ -9440,6 +9441,11 @@ const MASK_EXPORT_WANT_MANGLE = 1 << 1;
|
|
9440
9441
|
|
9441
9442
|
let function_defs = null;
|
9442
9443
|
let unmangleable_names = null;
|
9444
|
+
/**
|
9445
|
+
* When defined, there is a function declaration somewhere that's inside of a block.
|
9446
|
+
* See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
|
9447
|
+
*/
|
9448
|
+
let scopes_with_block_defuns = null;
|
9443
9449
|
|
9444
9450
|
class SymbolDef {
|
9445
9451
|
constructor(scope, orig, init) {
|
@@ -9990,6 +9996,15 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|
9990
9996
|
});
|
9991
9997
|
|
9992
9998
|
function next_mangled(scope, options) {
|
9999
|
+
let defun_scope;
|
10000
|
+
if (
|
10001
|
+
scopes_with_block_defuns
|
10002
|
+
&& (defun_scope = scope.get_defun_scope())
|
10003
|
+
&& scopes_with_block_defuns.has(defun_scope)
|
10004
|
+
) {
|
10005
|
+
scope = defun_scope;
|
10006
|
+
}
|
10007
|
+
|
9993
10008
|
var ext = scope.enclosed;
|
9994
10009
|
var nth_identifier = options.nth_identifier;
|
9995
10010
|
out: while (true) {
|
@@ -10124,6 +10139,13 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
10124
10139
|
lname = save_nesting;
|
10125
10140
|
return true; // don't descend again in TreeWalker
|
10126
10141
|
}
|
10142
|
+
if (
|
10143
|
+
node instanceof AST_Defun
|
10144
|
+
&& !(tw.parent() instanceof AST_Scope)
|
10145
|
+
) {
|
10146
|
+
scopes_with_block_defuns = scopes_with_block_defuns || new Set();
|
10147
|
+
scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
|
10148
|
+
}
|
10127
10149
|
if (node instanceof AST_Scope) {
|
10128
10150
|
node.variables.forEach(collect);
|
10129
10151
|
return;
|
@@ -10172,6 +10194,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
10172
10194
|
|
10173
10195
|
function_defs = null;
|
10174
10196
|
unmangleable_names = null;
|
10197
|
+
scopes_with_block_defuns = null;
|
10175
10198
|
|
10176
10199
|
function collect(symbol) {
|
10177
10200
|
if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
|
package/lib/output.js
CHANGED
@@ -1098,7 +1098,8 @@ function OutputStream(options) {
|
|
1098
1098
|
var p = output.parent();
|
1099
1099
|
if (this.args.length === 0
|
1100
1100
|
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|
1101
|
-
|| p instanceof AST_Call && p.expression === this
|
1101
|
+
|| p instanceof AST_Call && p.expression === this
|
1102
|
+
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
|
1102
1103
|
return true;
|
1103
1104
|
});
|
1104
1105
|
|
package/lib/scope.js
CHANGED
@@ -116,6 +116,11 @@ const MASK_EXPORT_WANT_MANGLE = 1 << 1;
|
|
116
116
|
|
117
117
|
let function_defs = null;
|
118
118
|
let unmangleable_names = null;
|
119
|
+
/**
|
120
|
+
* When defined, there is a function declaration somewhere that's inside of a block.
|
121
|
+
* See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
|
122
|
+
*/
|
123
|
+
let scopes_with_block_defuns = null;
|
119
124
|
|
120
125
|
class SymbolDef {
|
121
126
|
constructor(scope, orig, init) {
|
@@ -666,6 +671,15 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|
666
671
|
});
|
667
672
|
|
668
673
|
function next_mangled(scope, options) {
|
674
|
+
let defun_scope;
|
675
|
+
if (
|
676
|
+
scopes_with_block_defuns
|
677
|
+
&& (defun_scope = scope.get_defun_scope())
|
678
|
+
&& scopes_with_block_defuns.has(defun_scope)
|
679
|
+
) {
|
680
|
+
scope = defun_scope;
|
681
|
+
}
|
682
|
+
|
669
683
|
var ext = scope.enclosed;
|
670
684
|
var nth_identifier = options.nth_identifier;
|
671
685
|
out: while (true) {
|
@@ -800,6 +814,13 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
800
814
|
lname = save_nesting;
|
801
815
|
return true; // don't descend again in TreeWalker
|
802
816
|
}
|
817
|
+
if (
|
818
|
+
node instanceof AST_Defun
|
819
|
+
&& !(tw.parent() instanceof AST_Scope)
|
820
|
+
) {
|
821
|
+
scopes_with_block_defuns = scopes_with_block_defuns || new Set();
|
822
|
+
scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
|
823
|
+
}
|
803
824
|
if (node instanceof AST_Scope) {
|
804
825
|
node.variables.forEach(collect);
|
805
826
|
return;
|
@@ -848,6 +869,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
848
869
|
|
849
870
|
function_defs = null;
|
850
871
|
unmangleable_names = null;
|
872
|
+
scopes_with_block_defuns = null;
|
851
873
|
|
852
874
|
function collect(symbol) {
|
853
875
|
if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
|