terser 5.35.0 → 5.36.0
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 +4 -0
- package/dist/bundle.min.js +52 -44
- package/lib/ast.js +6 -6
- package/lib/mozilla-ast.js +30 -25
- package/lib/output.js +6 -6
- package/lib/parse.js +10 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bundle.min.js
CHANGED
@@ -2871,8 +2871,11 @@ function parse($TEXT, options) {
|
|
2871
2871
|
return new AST_ClassStaticBlock({ start, body, end: prev() });
|
2872
2872
|
}
|
2873
2873
|
|
2874
|
-
function
|
2875
|
-
if (
|
2874
|
+
function maybe_import_attributes() {
|
2875
|
+
if (
|
2876
|
+
(is("keyword", "with") || is("name", "assert"))
|
2877
|
+
&& !has_newline_before(S.token)
|
2878
|
+
) {
|
2876
2879
|
next();
|
2877
2880
|
return object_or_destructuring_();
|
2878
2881
|
}
|
@@ -2903,7 +2906,7 @@ function parse($TEXT, options) {
|
|
2903
2906
|
}
|
2904
2907
|
next();
|
2905
2908
|
|
2906
|
-
const
|
2909
|
+
const attributes = maybe_import_attributes();
|
2907
2910
|
|
2908
2911
|
return new AST_Import({
|
2909
2912
|
start,
|
@@ -2915,7 +2918,7 @@ function parse($TEXT, options) {
|
|
2915
2918
|
quote: mod_str.quote,
|
2916
2919
|
end: mod_str,
|
2917
2920
|
}),
|
2918
|
-
|
2921
|
+
attributes,
|
2919
2922
|
end: S.token,
|
2920
2923
|
});
|
2921
2924
|
}
|
@@ -3048,7 +3051,7 @@ function parse($TEXT, options) {
|
|
3048
3051
|
}
|
3049
3052
|
next();
|
3050
3053
|
|
3051
|
-
const
|
3054
|
+
const attributes = maybe_import_attributes();
|
3052
3055
|
|
3053
3056
|
return new AST_Export({
|
3054
3057
|
start: start,
|
@@ -3061,7 +3064,7 @@ function parse($TEXT, options) {
|
|
3061
3064
|
end: mod_str,
|
3062
3065
|
}),
|
3063
3066
|
end: prev(),
|
3064
|
-
|
3067
|
+
attributes
|
3065
3068
|
});
|
3066
3069
|
} else {
|
3067
3070
|
return new AST_Export({
|
@@ -3107,7 +3110,7 @@ function parse($TEXT, options) {
|
|
3107
3110
|
exported_value: exported_value,
|
3108
3111
|
exported_definition: exported_definition,
|
3109
3112
|
end: prev(),
|
3110
|
-
|
3113
|
+
attributes: null
|
3111
3114
|
});
|
3112
3115
|
}
|
3113
3116
|
|
@@ -5097,13 +5100,13 @@ var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_N
|
|
5097
5100
|
|
5098
5101
|
var AST_Import = DEFNODE(
|
5099
5102
|
"Import",
|
5100
|
-
"imported_name imported_names module_name
|
5103
|
+
"imported_name imported_names module_name attributes",
|
5101
5104
|
function AST_Import(props) {
|
5102
5105
|
if (props) {
|
5103
5106
|
this.imported_name = props.imported_name;
|
5104
5107
|
this.imported_names = props.imported_names;
|
5105
5108
|
this.module_name = props.module_name;
|
5106
|
-
this.
|
5109
|
+
this.attributes = props.attributes;
|
5107
5110
|
this.start = props.start;
|
5108
5111
|
this.end = props.end;
|
5109
5112
|
}
|
@@ -5116,7 +5119,7 @@ var AST_Import = DEFNODE(
|
|
5116
5119
|
imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
|
5117
5120
|
imported_names: "[AST_NameMapping*] The names of non-default imported variables",
|
5118
5121
|
module_name: "[AST_String] String literal describing where this module came from",
|
5119
|
-
|
5122
|
+
attributes: "[AST_Object?] The import attributes (with {...})"
|
5120
5123
|
},
|
5121
5124
|
_walk: function(visitor) {
|
5122
5125
|
return visitor._visit(this, function() {
|
@@ -5155,7 +5158,7 @@ var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props)
|
|
5155
5158
|
|
5156
5159
|
var AST_Export = DEFNODE(
|
5157
5160
|
"Export",
|
5158
|
-
"exported_definition exported_value is_default exported_names module_name
|
5161
|
+
"exported_definition exported_value is_default exported_names module_name attributes",
|
5159
5162
|
function AST_Export(props) {
|
5160
5163
|
if (props) {
|
5161
5164
|
this.exported_definition = props.exported_definition;
|
@@ -5163,7 +5166,7 @@ var AST_Export = DEFNODE(
|
|
5163
5166
|
this.is_default = props.is_default;
|
5164
5167
|
this.exported_names = props.exported_names;
|
5165
5168
|
this.module_name = props.module_name;
|
5166
|
-
this.
|
5169
|
+
this.attributes = props.attributes;
|
5167
5170
|
this.start = props.start;
|
5168
5171
|
this.end = props.end;
|
5169
5172
|
}
|
@@ -5178,7 +5181,7 @@ var AST_Export = DEFNODE(
|
|
5178
5181
|
exported_names: "[AST_NameMapping*?] List of exported names",
|
5179
5182
|
module_name: "[AST_String?] Name of the file to load exports from",
|
5180
5183
|
is_default: "[Boolean] Whether this is the default exported value of this module",
|
5181
|
-
|
5184
|
+
attributes: "[AST_Object?] The import attributes"
|
5182
5185
|
},
|
5183
5186
|
_walk: function (visitor) {
|
5184
5187
|
return visitor._visit(this, function () {
|
@@ -7157,23 +7160,23 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7157
7160
|
return body;
|
7158
7161
|
};
|
7159
7162
|
|
7160
|
-
|
7161
|
-
if (
|
7163
|
+
function import_attributes_from_moz(attributes) {
|
7164
|
+
if (attributes && attributes.length > 0) {
|
7162
7165
|
return new AST_Object({
|
7163
|
-
start: my_start_token(
|
7164
|
-
end: my_end_token(
|
7165
|
-
properties:
|
7166
|
+
start: my_start_token(attributes),
|
7167
|
+
end: my_end_token(attributes),
|
7168
|
+
properties: attributes.map((attr) =>
|
7166
7169
|
new AST_ObjectKeyVal({
|
7167
|
-
start: my_start_token(
|
7168
|
-
end: my_end_token(
|
7169
|
-
key:
|
7170
|
-
value: from_moz(
|
7170
|
+
start: my_start_token(attr),
|
7171
|
+
end: my_end_token(attr),
|
7172
|
+
key: attr.key.name || attr.key.value,
|
7173
|
+
value: from_moz(attr.value)
|
7171
7174
|
})
|
7172
7175
|
)
|
7173
7176
|
});
|
7174
7177
|
}
|
7175
7178
|
return null;
|
7176
|
-
}
|
7179
|
+
}
|
7177
7180
|
|
7178
7181
|
var MOZ_TO_ME = {
|
7179
7182
|
Program: function(M) {
|
@@ -7545,7 +7548,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7545
7548
|
imported_name: imported_name,
|
7546
7549
|
imported_names : imported_names,
|
7547
7550
|
module_name : from_moz(M.source),
|
7548
|
-
|
7551
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
7549
7552
|
});
|
7550
7553
|
},
|
7551
7554
|
|
@@ -7572,6 +7575,10 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7572
7575
|
},
|
7573
7576
|
|
7574
7577
|
ImportExpression: function(M) {
|
7578
|
+
const args = [from_moz(M.source)];
|
7579
|
+
if (M.options) {
|
7580
|
+
args.push(from_moz(M.options));
|
7581
|
+
}
|
7575
7582
|
return new AST_Call({
|
7576
7583
|
start: my_start_token(M),
|
7577
7584
|
end: my_end_token(M),
|
@@ -7580,7 +7587,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7580
7587
|
name: "import"
|
7581
7588
|
}),
|
7582
7589
|
optional: false,
|
7583
|
-
args
|
7590
|
+
args
|
7584
7591
|
});
|
7585
7592
|
},
|
7586
7593
|
|
@@ -7598,7 +7605,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7598
7605
|
})
|
7599
7606
|
],
|
7600
7607
|
module_name: from_moz(M.source),
|
7601
|
-
|
7608
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
7602
7609
|
});
|
7603
7610
|
},
|
7604
7611
|
|
@@ -7609,7 +7616,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7609
7616
|
exported_definition: from_moz(M.declaration),
|
7610
7617
|
exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : null,
|
7611
7618
|
module_name: from_moz(M.source),
|
7612
|
-
|
7619
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
7613
7620
|
});
|
7614
7621
|
},
|
7615
7622
|
|
@@ -8196,10 +8203,11 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8196
8203
|
});
|
8197
8204
|
def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
|
8198
8205
|
if (M.expression instanceof AST_SymbolRef && M.expression.name === "import") {
|
8199
|
-
const [source] = M.args.map(to_moz);
|
8206
|
+
const [source, options] = M.args.map(to_moz);
|
8200
8207
|
return {
|
8201
8208
|
type: "ImportExpression",
|
8202
8209
|
source,
|
8210
|
+
options
|
8203
8211
|
};
|
8204
8212
|
}
|
8205
8213
|
|
@@ -8360,22 +8368,22 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8360
8368
|
};
|
8361
8369
|
});
|
8362
8370
|
|
8363
|
-
|
8364
|
-
const
|
8365
|
-
if (
|
8366
|
-
for (const { key, value } of
|
8371
|
+
function import_attributes_to_moz(attribute) {
|
8372
|
+
const import_attributes = [];
|
8373
|
+
if (attribute) {
|
8374
|
+
for (const { key, value } of attribute.properties) {
|
8367
8375
|
const key_moz = is_basic_identifier_string(key)
|
8368
8376
|
? { type: "Identifier", name: key }
|
8369
8377
|
: { type: "Literal", value: key, raw: JSON.stringify(key) };
|
8370
|
-
|
8378
|
+
import_attributes.push({
|
8371
8379
|
type: "ImportAttribute",
|
8372
8380
|
key: key_moz,
|
8373
8381
|
value: to_moz(value)
|
8374
8382
|
});
|
8375
8383
|
}
|
8376
8384
|
}
|
8377
|
-
return
|
8378
|
-
}
|
8385
|
+
return import_attributes;
|
8386
|
+
}
|
8379
8387
|
|
8380
8388
|
def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
|
8381
8389
|
if (M.exported_names) {
|
@@ -8390,7 +8398,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8390
8398
|
type: "ExportAllDeclaration",
|
8391
8399
|
source: to_moz(M.module_name),
|
8392
8400
|
exported: exported,
|
8393
|
-
|
8401
|
+
attributes: import_attributes_to_moz(M.attributes)
|
8394
8402
|
};
|
8395
8403
|
}
|
8396
8404
|
return {
|
@@ -8404,7 +8412,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8404
8412
|
}),
|
8405
8413
|
declaration: to_moz(M.exported_definition),
|
8406
8414
|
source: to_moz(M.module_name),
|
8407
|
-
|
8415
|
+
attributes: import_attributes_to_moz(M.attributes)
|
8408
8416
|
};
|
8409
8417
|
}
|
8410
8418
|
return {
|
@@ -8442,7 +8450,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8442
8450
|
type: "ImportDeclaration",
|
8443
8451
|
specifiers: specifiers,
|
8444
8452
|
source: to_moz(M.module_name),
|
8445
|
-
|
8453
|
+
attributes: import_attributes_to_moz(M.attributes)
|
8446
8454
|
};
|
8447
8455
|
});
|
8448
8456
|
|
@@ -10590,9 +10598,9 @@ function OutputStream(options) {
|
|
10590
10598
|
output.space();
|
10591
10599
|
}
|
10592
10600
|
self.module_name.print(output);
|
10593
|
-
if (self.
|
10594
|
-
output.print("
|
10595
|
-
self.
|
10601
|
+
if (self.attributes) {
|
10602
|
+
output.print("with");
|
10603
|
+
self.attributes.print(output);
|
10596
10604
|
}
|
10597
10605
|
output.semicolon();
|
10598
10606
|
});
|
@@ -10686,9 +10694,9 @@ function OutputStream(options) {
|
|
10686
10694
|
output.space();
|
10687
10695
|
self.module_name.print(output);
|
10688
10696
|
}
|
10689
|
-
if (self.
|
10690
|
-
output.print("
|
10691
|
-
self.
|
10697
|
+
if (self.attributes) {
|
10698
|
+
output.print("with");
|
10699
|
+
self.attributes.print(output);
|
10692
10700
|
}
|
10693
10701
|
if (self.exported_value
|
10694
10702
|
&& !(self.exported_value instanceof AST_Defun ||
|
package/lib/ast.js
CHANGED
@@ -1481,13 +1481,13 @@ var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_N
|
|
1481
1481
|
|
1482
1482
|
var AST_Import = DEFNODE(
|
1483
1483
|
"Import",
|
1484
|
-
"imported_name imported_names module_name
|
1484
|
+
"imported_name imported_names module_name attributes",
|
1485
1485
|
function AST_Import(props) {
|
1486
1486
|
if (props) {
|
1487
1487
|
this.imported_name = props.imported_name;
|
1488
1488
|
this.imported_names = props.imported_names;
|
1489
1489
|
this.module_name = props.module_name;
|
1490
|
-
this.
|
1490
|
+
this.attributes = props.attributes;
|
1491
1491
|
this.start = props.start;
|
1492
1492
|
this.end = props.end;
|
1493
1493
|
}
|
@@ -1500,7 +1500,7 @@ var AST_Import = DEFNODE(
|
|
1500
1500
|
imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
|
1501
1501
|
imported_names: "[AST_NameMapping*] The names of non-default imported variables",
|
1502
1502
|
module_name: "[AST_String] String literal describing where this module came from",
|
1503
|
-
|
1503
|
+
attributes: "[AST_Object?] The import attributes (with {...})"
|
1504
1504
|
},
|
1505
1505
|
_walk: function(visitor) {
|
1506
1506
|
return visitor._visit(this, function() {
|
@@ -1539,7 +1539,7 @@ var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props)
|
|
1539
1539
|
|
1540
1540
|
var AST_Export = DEFNODE(
|
1541
1541
|
"Export",
|
1542
|
-
"exported_definition exported_value is_default exported_names module_name
|
1542
|
+
"exported_definition exported_value is_default exported_names module_name attributes",
|
1543
1543
|
function AST_Export(props) {
|
1544
1544
|
if (props) {
|
1545
1545
|
this.exported_definition = props.exported_definition;
|
@@ -1547,7 +1547,7 @@ var AST_Export = DEFNODE(
|
|
1547
1547
|
this.is_default = props.is_default;
|
1548
1548
|
this.exported_names = props.exported_names;
|
1549
1549
|
this.module_name = props.module_name;
|
1550
|
-
this.
|
1550
|
+
this.attributes = props.attributes;
|
1551
1551
|
this.start = props.start;
|
1552
1552
|
this.end = props.end;
|
1553
1553
|
}
|
@@ -1562,7 +1562,7 @@ var AST_Export = DEFNODE(
|
|
1562
1562
|
exported_names: "[AST_NameMapping*?] List of exported names",
|
1563
1563
|
module_name: "[AST_String?] Name of the file to load exports from",
|
1564
1564
|
is_default: "[Boolean] Whether this is the default exported value of this module",
|
1565
|
-
|
1565
|
+
attributes: "[AST_Object?] The import attributes"
|
1566
1566
|
},
|
1567
1567
|
_walk: function (visitor) {
|
1568
1568
|
return visitor._visit(this, function () {
|
package/lib/mozilla-ast.js
CHANGED
@@ -181,23 +181,23 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
181
181
|
return body;
|
182
182
|
};
|
183
183
|
|
184
|
-
|
185
|
-
if (
|
184
|
+
function import_attributes_from_moz(attributes) {
|
185
|
+
if (attributes && attributes.length > 0) {
|
186
186
|
return new AST_Object({
|
187
|
-
start: my_start_token(
|
188
|
-
end: my_end_token(
|
189
|
-
properties:
|
187
|
+
start: my_start_token(attributes),
|
188
|
+
end: my_end_token(attributes),
|
189
|
+
properties: attributes.map((attr) =>
|
190
190
|
new AST_ObjectKeyVal({
|
191
|
-
start: my_start_token(
|
192
|
-
end: my_end_token(
|
193
|
-
key:
|
194
|
-
value: from_moz(
|
191
|
+
start: my_start_token(attr),
|
192
|
+
end: my_end_token(attr),
|
193
|
+
key: attr.key.name || attr.key.value,
|
194
|
+
value: from_moz(attr.value)
|
195
195
|
})
|
196
196
|
)
|
197
197
|
});
|
198
198
|
}
|
199
199
|
return null;
|
200
|
-
}
|
200
|
+
}
|
201
201
|
|
202
202
|
var MOZ_TO_ME = {
|
203
203
|
Program: function(M) {
|
@@ -569,7 +569,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
569
569
|
imported_name: imported_name,
|
570
570
|
imported_names : imported_names,
|
571
571
|
module_name : from_moz(M.source),
|
572
|
-
|
572
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
573
573
|
});
|
574
574
|
},
|
575
575
|
|
@@ -596,6 +596,10 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
596
596
|
},
|
597
597
|
|
598
598
|
ImportExpression: function(M) {
|
599
|
+
const args = [from_moz(M.source)];
|
600
|
+
if (M.options) {
|
601
|
+
args.push(from_moz(M.options));
|
602
|
+
}
|
599
603
|
return new AST_Call({
|
600
604
|
start: my_start_token(M),
|
601
605
|
end: my_end_token(M),
|
@@ -604,7 +608,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
604
608
|
name: "import"
|
605
609
|
}),
|
606
610
|
optional: false,
|
607
|
-
args
|
611
|
+
args
|
608
612
|
});
|
609
613
|
},
|
610
614
|
|
@@ -622,7 +626,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
622
626
|
})
|
623
627
|
],
|
624
628
|
module_name: from_moz(M.source),
|
625
|
-
|
629
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
626
630
|
});
|
627
631
|
},
|
628
632
|
|
@@ -633,7 +637,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
633
637
|
exported_definition: from_moz(M.declaration),
|
634
638
|
exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : null,
|
635
639
|
module_name: from_moz(M.source),
|
636
|
-
|
640
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions)
|
637
641
|
});
|
638
642
|
},
|
639
643
|
|
@@ -1220,10 +1224,11 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1220
1224
|
});
|
1221
1225
|
def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
|
1222
1226
|
if (M.expression instanceof AST_SymbolRef && M.expression.name === "import") {
|
1223
|
-
const [source] = M.args.map(to_moz);
|
1227
|
+
const [source, options] = M.args.map(to_moz);
|
1224
1228
|
return {
|
1225
1229
|
type: "ImportExpression",
|
1226
1230
|
source,
|
1231
|
+
options
|
1227
1232
|
};
|
1228
1233
|
}
|
1229
1234
|
|
@@ -1384,22 +1389,22 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1384
1389
|
};
|
1385
1390
|
});
|
1386
1391
|
|
1387
|
-
|
1388
|
-
const
|
1389
|
-
if (
|
1390
|
-
for (const { key, value } of
|
1392
|
+
function import_attributes_to_moz(attribute) {
|
1393
|
+
const import_attributes = [];
|
1394
|
+
if (attribute) {
|
1395
|
+
for (const { key, value } of attribute.properties) {
|
1391
1396
|
const key_moz = is_basic_identifier_string(key)
|
1392
1397
|
? { type: "Identifier", name: key }
|
1393
1398
|
: { type: "Literal", value: key, raw: JSON.stringify(key) };
|
1394
|
-
|
1399
|
+
import_attributes.push({
|
1395
1400
|
type: "ImportAttribute",
|
1396
1401
|
key: key_moz,
|
1397
1402
|
value: to_moz(value)
|
1398
1403
|
});
|
1399
1404
|
}
|
1400
1405
|
}
|
1401
|
-
return
|
1402
|
-
}
|
1406
|
+
return import_attributes;
|
1407
|
+
}
|
1403
1408
|
|
1404
1409
|
def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
|
1405
1410
|
if (M.exported_names) {
|
@@ -1414,7 +1419,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1414
1419
|
type: "ExportAllDeclaration",
|
1415
1420
|
source: to_moz(M.module_name),
|
1416
1421
|
exported: exported,
|
1417
|
-
|
1422
|
+
attributes: import_attributes_to_moz(M.attributes)
|
1418
1423
|
};
|
1419
1424
|
}
|
1420
1425
|
return {
|
@@ -1428,7 +1433,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1428
1433
|
}),
|
1429
1434
|
declaration: to_moz(M.exported_definition),
|
1430
1435
|
source: to_moz(M.module_name),
|
1431
|
-
|
1436
|
+
attributes: import_attributes_to_moz(M.attributes)
|
1432
1437
|
};
|
1433
1438
|
}
|
1434
1439
|
return {
|
@@ -1466,7 +1471,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1466
1471
|
type: "ImportDeclaration",
|
1467
1472
|
specifiers: specifiers,
|
1468
1473
|
source: to_moz(M.module_name),
|
1469
|
-
|
1474
|
+
attributes: import_attributes_to_moz(M.attributes)
|
1470
1475
|
};
|
1471
1476
|
});
|
1472
1477
|
|
package/lib/output.js
CHANGED
@@ -1792,9 +1792,9 @@ function OutputStream(options) {
|
|
1792
1792
|
output.space();
|
1793
1793
|
}
|
1794
1794
|
self.module_name.print(output);
|
1795
|
-
if (self.
|
1796
|
-
output.print("
|
1797
|
-
self.
|
1795
|
+
if (self.attributes) {
|
1796
|
+
output.print("with");
|
1797
|
+
self.attributes.print(output);
|
1798
1798
|
}
|
1799
1799
|
output.semicolon();
|
1800
1800
|
});
|
@@ -1888,9 +1888,9 @@ function OutputStream(options) {
|
|
1888
1888
|
output.space();
|
1889
1889
|
self.module_name.print(output);
|
1890
1890
|
}
|
1891
|
-
if (self.
|
1892
|
-
output.print("
|
1893
|
-
self.
|
1891
|
+
if (self.attributes) {
|
1892
|
+
output.print("with");
|
1893
|
+
self.attributes.print(output);
|
1894
1894
|
}
|
1895
1895
|
if (self.exported_value
|
1896
1896
|
&& !(self.exported_value instanceof AST_Defun ||
|
package/lib/parse.js
CHANGED
@@ -2726,8 +2726,11 @@ function parse($TEXT, options) {
|
|
2726
2726
|
return new AST_ClassStaticBlock({ start, body, end: prev() });
|
2727
2727
|
}
|
2728
2728
|
|
2729
|
-
function
|
2730
|
-
if (
|
2729
|
+
function maybe_import_attributes() {
|
2730
|
+
if (
|
2731
|
+
(is("keyword", "with") || is("name", "assert"))
|
2732
|
+
&& !has_newline_before(S.token)
|
2733
|
+
) {
|
2731
2734
|
next();
|
2732
2735
|
return object_or_destructuring_();
|
2733
2736
|
}
|
@@ -2758,7 +2761,7 @@ function parse($TEXT, options) {
|
|
2758
2761
|
}
|
2759
2762
|
next();
|
2760
2763
|
|
2761
|
-
const
|
2764
|
+
const attributes = maybe_import_attributes();
|
2762
2765
|
|
2763
2766
|
return new AST_Import({
|
2764
2767
|
start,
|
@@ -2770,7 +2773,7 @@ function parse($TEXT, options) {
|
|
2770
2773
|
quote: mod_str.quote,
|
2771
2774
|
end: mod_str,
|
2772
2775
|
}),
|
2773
|
-
|
2776
|
+
attributes,
|
2774
2777
|
end: S.token,
|
2775
2778
|
});
|
2776
2779
|
}
|
@@ -2903,7 +2906,7 @@ function parse($TEXT, options) {
|
|
2903
2906
|
}
|
2904
2907
|
next();
|
2905
2908
|
|
2906
|
-
const
|
2909
|
+
const attributes = maybe_import_attributes();
|
2907
2910
|
|
2908
2911
|
return new AST_Export({
|
2909
2912
|
start: start,
|
@@ -2916,7 +2919,7 @@ function parse($TEXT, options) {
|
|
2916
2919
|
end: mod_str,
|
2917
2920
|
}),
|
2918
2921
|
end: prev(),
|
2919
|
-
|
2922
|
+
attributes
|
2920
2923
|
});
|
2921
2924
|
} else {
|
2922
2925
|
return new AST_Export({
|
@@ -2962,7 +2965,7 @@ function parse($TEXT, options) {
|
|
2962
2965
|
exported_value: exported_value,
|
2963
2966
|
exported_definition: exported_definition,
|
2964
2967
|
end: prev(),
|
2965
|
-
|
2968
|
+
attributes: null
|
2966
2969
|
});
|
2967
2970
|
}
|
2968
2971
|
|