rollup 0.43.0 → 0.43.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 +9 -1
- package/bin/rollup +6 -3
- package/dist/rollup.browser.js +320 -206
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.es.js +317 -203
- package/dist/rollup.es.js.map +1 -1
- package/dist/rollup.js +317 -203
- package/dist/rollup.js.map +1 -1
- package/package.json +9 -5
package/dist/rollup.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rollup.js v0.43.
|
|
3
|
-
|
|
2
|
+
Rollup.js v0.43.1
|
|
3
|
+
Sun Jul 09 2017 19:16:27 GMT-0400 (EDT) - commit 6f3f349afff179d3ea85764390fe74d38544a88b
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
@@ -164,7 +164,14 @@ function validateKeys ( actualKeys, allowedKeys ) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
function error ( props ) {
|
|
167
|
-
|
|
167
|
+
// use the same constructor as props (if it's an error object)
|
|
168
|
+
// so that err.name is preserved etc
|
|
169
|
+
// (Object.keys below does not update these values because they
|
|
170
|
+
// are properties on the prototype chain)
|
|
171
|
+
// basically if props is a SyntaxError it will not be overriden as a generic Error
|
|
172
|
+
var constructor = Error;
|
|
173
|
+
if (props instanceof Error) { constructor = props.constructor; }
|
|
174
|
+
var err = new constructor( props.message );
|
|
168
175
|
|
|
169
176
|
Object.keys( props ).forEach( function (key) {
|
|
170
177
|
err[ key ] = props[ key ];
|
|
@@ -1852,7 +1859,7 @@ function isIdentifierChar(code, astral) {
|
|
|
1852
1859
|
// continue jumps to that label.
|
|
1853
1860
|
|
|
1854
1861
|
var TokenType = function TokenType(label, conf) {
|
|
1855
|
-
if ( conf === void 0 ) conf = {};
|
|
1862
|
+
if ( conf === void 0 ) { conf = {}; }
|
|
1856
1863
|
|
|
1857
1864
|
this.label = label;
|
|
1858
1865
|
this.keyword = conf.keyword;
|
|
@@ -1878,7 +1885,7 @@ var keywords$1 = {};
|
|
|
1878
1885
|
|
|
1879
1886
|
// Succinct definitions of keyword token types
|
|
1880
1887
|
function kw(name, options) {
|
|
1881
|
-
if ( options === void 0 ) options = {};
|
|
1888
|
+
if ( options === void 0 ) { options = {}; }
|
|
1882
1889
|
|
|
1883
1890
|
options.keyword = name;
|
|
1884
1891
|
return keywords$1[name] = new TokenType(name, options)
|
|
@@ -1905,6 +1912,7 @@ var types = {
|
|
|
1905
1912
|
question: new TokenType("?", beforeExpr),
|
|
1906
1913
|
arrow: new TokenType("=>", beforeExpr),
|
|
1907
1914
|
template: new TokenType("template"),
|
|
1915
|
+
invalidTemplate: new TokenType("invalidTemplate"),
|
|
1908
1916
|
ellipsis: new TokenType("...", beforeExpr),
|
|
1909
1917
|
backQuote: new TokenType("`", startsExpr),
|
|
1910
1918
|
dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
|
|
@@ -1965,7 +1973,7 @@ var types = {
|
|
|
1965
1973
|
_new: kw("new", {beforeExpr: true, startsExpr: true}),
|
|
1966
1974
|
_this: kw("this", startsExpr),
|
|
1967
1975
|
_super: kw("super", startsExpr),
|
|
1968
|
-
_class: kw("class"),
|
|
1976
|
+
_class: kw("class", startsExpr),
|
|
1969
1977
|
_extends: kw("extends", beforeExpr),
|
|
1970
1978
|
_export: kw("export"),
|
|
1971
1979
|
_import: kw("import"),
|
|
@@ -2173,7 +2181,7 @@ function pushComment(options, array) {
|
|
|
2173
2181
|
var plugins = {};
|
|
2174
2182
|
|
|
2175
2183
|
function keywordRegexp(words) {
|
|
2176
|
-
return new RegExp("^(" + words.replace(/ /g, "|") + ")$")
|
|
2184
|
+
return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
|
|
2177
2185
|
}
|
|
2178
2186
|
|
|
2179
2187
|
var Parser = function Parser(options, input, startPos) {
|
|
@@ -2374,9 +2382,13 @@ pp.unexpected = function(pos) {
|
|
|
2374
2382
|
this.raise(pos != null ? pos : this.start, "Unexpected token");
|
|
2375
2383
|
};
|
|
2376
2384
|
|
|
2377
|
-
|
|
2378
|
-
this.shorthandAssign =
|
|
2379
|
-
|
|
2385
|
+
function DestructuringErrors() {
|
|
2386
|
+
this.shorthandAssign =
|
|
2387
|
+
this.trailingComma =
|
|
2388
|
+
this.parenthesizedAssign =
|
|
2389
|
+
this.parenthesizedBind =
|
|
2390
|
+
-1;
|
|
2391
|
+
}
|
|
2380
2392
|
|
|
2381
2393
|
pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
2382
2394
|
if (!refDestructuringErrors) { return }
|
|
@@ -2759,14 +2771,19 @@ pp$1.parseEmptyStatement = function(node) {
|
|
|
2759
2771
|
pp$1.parseLabeledStatement = function(node, maybeName, expr) {
|
|
2760
2772
|
var this$1 = this;
|
|
2761
2773
|
|
|
2762
|
-
for (var i = 0; i <
|
|
2763
|
-
{
|
|
2774
|
+
for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1)
|
|
2775
|
+
{
|
|
2776
|
+
var label = list[i$1];
|
|
2777
|
+
|
|
2778
|
+
if (label.name === maybeName)
|
|
2779
|
+
{ this$1.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
|
2780
|
+
} }
|
|
2764
2781
|
var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
|
|
2765
|
-
for (var i
|
|
2766
|
-
var label = this$1.labels[i
|
|
2767
|
-
if (label.statementStart == node.start) {
|
|
2768
|
-
label.statementStart = this$1.start;
|
|
2769
|
-
label.kind = kind;
|
|
2782
|
+
for (var i = this.labels.length - 1; i >= 0; i--) {
|
|
2783
|
+
var label$1 = this$1.labels[i];
|
|
2784
|
+
if (label$1.statementStart == node.start) {
|
|
2785
|
+
label$1.statementStart = this$1.start;
|
|
2786
|
+
label$1.kind = kind;
|
|
2770
2787
|
} else { break }
|
|
2771
2788
|
}
|
|
2772
2789
|
this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
|
|
@@ -2792,7 +2809,7 @@ pp$1.parseExpressionStatement = function(node, expr) {
|
|
|
2792
2809
|
|
|
2793
2810
|
pp$1.parseBlock = function(createNewLexicalScope) {
|
|
2794
2811
|
var this$1 = this;
|
|
2795
|
-
if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
|
|
2812
|
+
if ( createNewLexicalScope === void 0 ) { createNewLexicalScope = true; }
|
|
2796
2813
|
|
|
2797
2814
|
var node = this.startNode();
|
|
2798
2815
|
node.body = [];
|
|
@@ -2914,7 +2931,7 @@ pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {
|
|
|
2914
2931
|
|
|
2915
2932
|
pp$1.parseFunctionParams = function(node) {
|
|
2916
2933
|
this.expect(types.parenL);
|
|
2917
|
-
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8
|
|
2934
|
+
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
|
|
2918
2935
|
this.checkYieldAwaitInDefaultParams();
|
|
2919
2936
|
};
|
|
2920
2937
|
|
|
@@ -3048,10 +3065,10 @@ pp$1.parseExport = function(node, exports) {
|
|
|
3048
3065
|
node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
|
|
3049
3066
|
} else {
|
|
3050
3067
|
// check for keywords used as local names
|
|
3051
|
-
for (var i = 0; i <
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3068
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
3069
|
+
var spec = list[i];
|
|
3070
|
+
|
|
3071
|
+
this$1.checkUnreserved(spec.local);
|
|
3055
3072
|
}
|
|
3056
3073
|
|
|
3057
3074
|
node.source = null;
|
|
@@ -3075,12 +3092,17 @@ pp$1.checkPatternExport = function(exports, pat) {
|
|
|
3075
3092
|
if (type == "Identifier")
|
|
3076
3093
|
{ this.checkExport(exports, pat.name, pat.start); }
|
|
3077
3094
|
else if (type == "ObjectPattern")
|
|
3078
|
-
{ for (var i = 0; i <
|
|
3079
|
-
{
|
|
3095
|
+
{ for (var i = 0, list = pat.properties; i < list.length; i += 1)
|
|
3096
|
+
{
|
|
3097
|
+
var prop = list[i];
|
|
3098
|
+
|
|
3099
|
+
this$1.checkPatternExport(exports, prop.value);
|
|
3100
|
+
} }
|
|
3080
3101
|
else if (type == "ArrayPattern")
|
|
3081
|
-
{ for (var i$1 = 0; i$1 <
|
|
3082
|
-
var elt =
|
|
3083
|
-
|
|
3102
|
+
{ for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
3103
|
+
var elt = list$1[i$1];
|
|
3104
|
+
|
|
3105
|
+
if (elt) { this$1.checkPatternExport(exports, elt); }
|
|
3084
3106
|
} }
|
|
3085
3107
|
else if (type == "AssignmentPattern")
|
|
3086
3108
|
{ this.checkPatternExport(exports, pat.left); }
|
|
@@ -3092,8 +3114,12 @@ pp$1.checkVariableExport = function(exports, decls) {
|
|
|
3092
3114
|
var this$1 = this;
|
|
3093
3115
|
|
|
3094
3116
|
if (!exports) { return }
|
|
3095
|
-
for (var i = 0; i <
|
|
3096
|
-
{
|
|
3117
|
+
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
3118
|
+
{
|
|
3119
|
+
var decl = list[i];
|
|
3120
|
+
|
|
3121
|
+
this$1.checkPatternExport(exports, decl.id);
|
|
3122
|
+
}
|
|
3097
3123
|
};
|
|
3098
3124
|
|
|
3099
3125
|
pp$1.shouldParseExportStatement = function() {
|
|
@@ -3180,9 +3206,8 @@ pp$1.parseImportSpecifiers = function() {
|
|
|
3180
3206
|
if (this$1.eatContextual("as")) {
|
|
3181
3207
|
node$2.local = this$1.parseIdent();
|
|
3182
3208
|
} else {
|
|
3209
|
+
this$1.checkUnreserved(node$2.imported);
|
|
3183
3210
|
node$2.local = node$2.imported;
|
|
3184
|
-
if (this$1.isKeyword(node$2.local.name)) { this$1.unexpected(node$2.local.start); }
|
|
3185
|
-
if (this$1.reservedWordsStrict.test(node$2.local.name)) { this$1.raiseRecoverable(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved"); }
|
|
3186
3211
|
}
|
|
3187
3212
|
this$1.checkLVal(node$2.local, "let");
|
|
3188
3213
|
nodes.push(this$1.finishNode(node$2, "ImportSpecifier"));
|
|
@@ -3211,9 +3236,10 @@ pp$2.toAssignable = function(node, isBinding) {
|
|
|
3211
3236
|
|
|
3212
3237
|
case "ObjectExpression":
|
|
3213
3238
|
node.type = "ObjectPattern";
|
|
3214
|
-
for (var i = 0; i <
|
|
3215
|
-
var prop =
|
|
3216
|
-
|
|
3239
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
3240
|
+
var prop = list[i];
|
|
3241
|
+
|
|
3242
|
+
if (prop.kind !== "init") { this$1.raise(prop.key.start, "Object pattern can't contain getter or setter"); }
|
|
3217
3243
|
this$1.toAssignable(prop.value, isBinding);
|
|
3218
3244
|
}
|
|
3219
3245
|
break
|
|
@@ -3238,7 +3264,7 @@ pp$2.toAssignable = function(node, isBinding) {
|
|
|
3238
3264
|
break
|
|
3239
3265
|
|
|
3240
3266
|
case "ParenthesizedExpression":
|
|
3241
|
-
|
|
3267
|
+
this.toAssignable(node.expression, isBinding);
|
|
3242
3268
|
break
|
|
3243
3269
|
|
|
3244
3270
|
case "MemberExpression":
|
|
@@ -3265,12 +3291,10 @@ pp$2.toAssignableList = function(exprList, isBinding) {
|
|
|
3265
3291
|
last.type = "RestElement";
|
|
3266
3292
|
var arg = last.argument;
|
|
3267
3293
|
this.toAssignable(arg, isBinding);
|
|
3268
|
-
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
|
|
3269
|
-
{ this.unexpected(arg.start); }
|
|
3270
3294
|
--end;
|
|
3271
3295
|
}
|
|
3272
3296
|
|
|
3273
|
-
if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
|
|
3297
|
+
if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
|
|
3274
3298
|
{ this.unexpected(last.argument.start); }
|
|
3275
3299
|
}
|
|
3276
3300
|
for (var i = 0; i < end; i++) {
|
|
@@ -3289,13 +3313,15 @@ pp$2.parseSpread = function(refDestructuringErrors) {
|
|
|
3289
3313
|
return this.finishNode(node, "SpreadElement")
|
|
3290
3314
|
};
|
|
3291
3315
|
|
|
3292
|
-
pp$2.
|
|
3316
|
+
pp$2.parseRestBinding = function() {
|
|
3293
3317
|
var node = this.startNode();
|
|
3294
3318
|
this.next();
|
|
3295
3319
|
|
|
3296
3320
|
// RestElement inside of a function parameter must be an identifier
|
|
3297
|
-
if (
|
|
3298
|
-
|
|
3321
|
+
if (this.options.ecmaVersion === 6 && this.type !== types.name)
|
|
3322
|
+
{ this.unexpected(); }
|
|
3323
|
+
|
|
3324
|
+
node.argument = this.parseBindingAtom();
|
|
3299
3325
|
|
|
3300
3326
|
return this.finishNode(node, "RestElement")
|
|
3301
3327
|
};
|
|
@@ -3322,7 +3348,7 @@ pp$2.parseBindingAtom = function() {
|
|
|
3322
3348
|
}
|
|
3323
3349
|
};
|
|
3324
3350
|
|
|
3325
|
-
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma
|
|
3351
|
+
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
3326
3352
|
var this$1 = this;
|
|
3327
3353
|
|
|
3328
3354
|
var elts = [], first = true;
|
|
@@ -3334,7 +3360,7 @@ pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNon
|
|
|
3334
3360
|
} else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
|
|
3335
3361
|
break
|
|
3336
3362
|
} else if (this$1.type === types.ellipsis) {
|
|
3337
|
-
var rest = this$1.
|
|
3363
|
+
var rest = this$1.parseRestBinding();
|
|
3338
3364
|
this$1.parseBindingListItem(rest);
|
|
3339
3365
|
elts.push(rest);
|
|
3340
3366
|
if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
|
|
@@ -3403,14 +3429,19 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) {
|
|
|
3403
3429
|
break
|
|
3404
3430
|
|
|
3405
3431
|
case "ObjectPattern":
|
|
3406
|
-
for (var i = 0; i <
|
|
3407
|
-
{
|
|
3432
|
+
for (var i = 0, list = expr.properties; i < list.length; i += 1)
|
|
3433
|
+
{
|
|
3434
|
+
var prop = list[i];
|
|
3435
|
+
|
|
3436
|
+
this$1.checkLVal(prop.value, bindingType, checkClashes);
|
|
3437
|
+
}
|
|
3408
3438
|
break
|
|
3409
3439
|
|
|
3410
3440
|
case "ArrayPattern":
|
|
3411
|
-
for (var i$1 = 0; i$1 <
|
|
3412
|
-
var elem =
|
|
3413
|
-
|
|
3441
|
+
for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
|
|
3442
|
+
var elem = list$1[i$1];
|
|
3443
|
+
|
|
3444
|
+
if (elem) { this$1.checkLVal(elem, bindingType, checkClashes); }
|
|
3414
3445
|
}
|
|
3415
3446
|
break
|
|
3416
3447
|
|
|
@@ -3712,7 +3743,7 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
|
|
|
3712
3743
|
} else if (this$1.type === types.backQuote) {
|
|
3713
3744
|
var node$2 = this$1.startNodeAt(startPos, startLoc);
|
|
3714
3745
|
node$2.tag = base;
|
|
3715
|
-
node$2.quasi = this$1.parseTemplate();
|
|
3746
|
+
node$2.quasi = this$1.parseTemplate({isTagged: true});
|
|
3716
3747
|
base = this$1.finishNode(node$2, "TaggedTemplateExpression");
|
|
3717
3748
|
} else {
|
|
3718
3749
|
return base
|
|
@@ -3843,7 +3874,7 @@ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
|
|
|
3843
3874
|
break
|
|
3844
3875
|
} else if (this$1.type === types.ellipsis) {
|
|
3845
3876
|
spreadStart = this$1.start;
|
|
3846
|
-
exprList.push(this$1.parseParenItem(this$1.
|
|
3877
|
+
exprList.push(this$1.parseParenItem(this$1.parseRestBinding()));
|
|
3847
3878
|
if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
|
|
3848
3879
|
break
|
|
3849
3880
|
} else {
|
|
@@ -3928,30 +3959,44 @@ pp$3.parseNew = function() {
|
|
|
3928
3959
|
|
|
3929
3960
|
// Parse template expression.
|
|
3930
3961
|
|
|
3931
|
-
pp$3.parseTemplateElement = function() {
|
|
3962
|
+
pp$3.parseTemplateElement = function(ref) {
|
|
3963
|
+
var isTagged = ref.isTagged;
|
|
3964
|
+
|
|
3932
3965
|
var elem = this.startNode();
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3966
|
+
if (this.type === types.invalidTemplate) {
|
|
3967
|
+
if (!isTagged) {
|
|
3968
|
+
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
|
|
3969
|
+
}
|
|
3970
|
+
elem.value = {
|
|
3971
|
+
raw: this.value,
|
|
3972
|
+
cooked: null
|
|
3973
|
+
};
|
|
3974
|
+
} else {
|
|
3975
|
+
elem.value = {
|
|
3976
|
+
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
|
|
3977
|
+
cooked: this.value
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3937
3980
|
this.next();
|
|
3938
3981
|
elem.tail = this.type === types.backQuote;
|
|
3939
3982
|
return this.finishNode(elem, "TemplateElement")
|
|
3940
3983
|
};
|
|
3941
3984
|
|
|
3942
|
-
pp$3.parseTemplate = function() {
|
|
3985
|
+
pp$3.parseTemplate = function(ref) {
|
|
3943
3986
|
var this$1 = this;
|
|
3987
|
+
if ( ref === void 0 ) { ref = {}; }
|
|
3988
|
+
var isTagged = ref.isTagged; if ( isTagged === void 0 ) { isTagged = false; }
|
|
3944
3989
|
|
|
3945
3990
|
var node = this.startNode();
|
|
3946
3991
|
this.next();
|
|
3947
3992
|
node.expressions = [];
|
|
3948
|
-
var curElt = this.parseTemplateElement();
|
|
3993
|
+
var curElt = this.parseTemplateElement({isTagged: isTagged});
|
|
3949
3994
|
node.quasis = [curElt];
|
|
3950
3995
|
while (!curElt.tail) {
|
|
3951
3996
|
this$1.expect(types.dollarBraceL);
|
|
3952
3997
|
node.expressions.push(this$1.parseExpression());
|
|
3953
3998
|
this$1.expect(types.braceR);
|
|
3954
|
-
node.quasis.push(curElt = this$1.parseTemplateElement());
|
|
3999
|
+
node.quasis.push(curElt = this$1.parseTemplateElement({isTagged: isTagged}));
|
|
3955
4000
|
}
|
|
3956
4001
|
this.next();
|
|
3957
4002
|
return this.finishNode(node, "TemplateLiteral")
|
|
@@ -3959,6 +4004,12 @@ pp$3.parseTemplate = function() {
|
|
|
3959
4004
|
|
|
3960
4005
|
// Parse an object literal or binding pattern.
|
|
3961
4006
|
|
|
4007
|
+
pp$3.isAsyncProp = function(prop) {
|
|
4008
|
+
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
|
|
4009
|
+
(this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) &&
|
|
4010
|
+
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
|
|
4011
|
+
};
|
|
4012
|
+
|
|
3962
4013
|
pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
|
3963
4014
|
var this$1 = this;
|
|
3964
4015
|
|
|
@@ -3983,9 +4034,7 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
|
|
3983
4034
|
{ isGenerator = this$1.eat(types.star); }
|
|
3984
4035
|
}
|
|
3985
4036
|
this$1.parsePropertyName(prop);
|
|
3986
|
-
if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator &&
|
|
3987
|
-
prop.key.type === "Identifier" && prop.key.name === "async" && this$1.type !== types.parenL &&
|
|
3988
|
-
this$1.type !== types.colon && !this$1.canInsertSemicolon()) {
|
|
4037
|
+
if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && this$1.isAsyncProp(prop)) {
|
|
3989
4038
|
isAsync = true;
|
|
3990
4039
|
this$1.parsePropertyName(prop, refDestructuringErrors);
|
|
3991
4040
|
} else {
|
|
@@ -4029,11 +4078,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
4029
4078
|
{ this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
|
|
4030
4079
|
}
|
|
4031
4080
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
|
4032
|
-
|
|
4033
|
-
(this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) ||
|
|
4034
|
-
(this.inGenerator && prop.key.name == "yield") ||
|
|
4035
|
-
(this.inAsync && prop.key.name == "await"))
|
|
4036
|
-
{ this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property"); }
|
|
4081
|
+
this.checkUnreserved(prop.key);
|
|
4037
4082
|
prop.kind = "init";
|
|
4038
4083
|
if (isPattern) {
|
|
4039
4084
|
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
|
@@ -4177,8 +4222,12 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) {
|
|
|
4177
4222
|
};
|
|
4178
4223
|
|
|
4179
4224
|
pp$3.isSimpleParamList = function(params) {
|
|
4180
|
-
for (var i = 0; i <
|
|
4181
|
-
{
|
|
4225
|
+
for (var i = 0, list = params; i < list.length; i += 1)
|
|
4226
|
+
{
|
|
4227
|
+
var param = list[i];
|
|
4228
|
+
|
|
4229
|
+
if (param.type !== "Identifier") { return false
|
|
4230
|
+
} }
|
|
4182
4231
|
return true
|
|
4183
4232
|
};
|
|
4184
4233
|
|
|
@@ -4189,7 +4238,12 @@ pp$3.checkParams = function(node, allowDuplicates) {
|
|
|
4189
4238
|
var this$1 = this;
|
|
4190
4239
|
|
|
4191
4240
|
var nameHash = {};
|
|
4192
|
-
for (var i = 0
|
|
4241
|
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
4242
|
+
{
|
|
4243
|
+
var param = list[i];
|
|
4244
|
+
|
|
4245
|
+
this$1.checkLVal(param, "var", allowDuplicates ? null : nameHash);
|
|
4246
|
+
}
|
|
4193
4247
|
};
|
|
4194
4248
|
|
|
4195
4249
|
// Parses a comma-separated list of expressions, and returns them as
|
|
@@ -4227,26 +4281,38 @@ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestruct
|
|
|
4227
4281
|
// when parsing properties), it will also convert keywords into
|
|
4228
4282
|
// identifiers.
|
|
4229
4283
|
|
|
4230
|
-
pp$3.
|
|
4284
|
+
pp$3.checkUnreserved = function(ref) {
|
|
4285
|
+
var start = ref.start;
|
|
4286
|
+
var end = ref.end;
|
|
4287
|
+
var name = ref.name;
|
|
4288
|
+
|
|
4289
|
+
if (this.inGenerator && name === "yield")
|
|
4290
|
+
{ this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); }
|
|
4291
|
+
if (this.inAsync && name === "await")
|
|
4292
|
+
{ this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function"); }
|
|
4293
|
+
if (this.isKeyword(name))
|
|
4294
|
+
{ this.raise(start, ("Unexpected keyword '" + name + "'")); }
|
|
4295
|
+
if (this.options.ecmaVersion < 6 &&
|
|
4296
|
+
this.input.slice(start, end).indexOf("\\") != -1) { return }
|
|
4297
|
+
var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
|
|
4298
|
+
if (re.test(name))
|
|
4299
|
+
{ this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); }
|
|
4300
|
+
};
|
|
4301
|
+
|
|
4302
|
+
pp$3.parseIdent = function(liberal, isBinding) {
|
|
4231
4303
|
var node = this.startNode();
|
|
4232
4304
|
if (liberal && this.options.allowReserved == "never") { liberal = false; }
|
|
4233
4305
|
if (this.type === types.name) {
|
|
4234
|
-
if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) &&
|
|
4235
|
-
(this.options.ecmaVersion >= 6 ||
|
|
4236
|
-
this.input.slice(this.start, this.end).indexOf("\\") == -1))
|
|
4237
|
-
{ this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved"); }
|
|
4238
|
-
if (this.inGenerator && this.value === "yield")
|
|
4239
|
-
{ this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator"); }
|
|
4240
|
-
if (this.inAsync && this.value === "await")
|
|
4241
|
-
{ this.raiseRecoverable(this.start, "Can not use 'await' as identifier inside an async function"); }
|
|
4242
4306
|
node.name = this.value;
|
|
4243
|
-
} else if (
|
|
4307
|
+
} else if (this.type.keyword) {
|
|
4244
4308
|
node.name = this.type.keyword;
|
|
4245
4309
|
} else {
|
|
4246
4310
|
this.unexpected();
|
|
4247
4311
|
}
|
|
4248
4312
|
this.next();
|
|
4249
|
-
|
|
4313
|
+
this.finishNode(node, "Identifier");
|
|
4314
|
+
if (!liberal) { this.checkUnreserved(node); }
|
|
4315
|
+
return node
|
|
4250
4316
|
};
|
|
4251
4317
|
|
|
4252
4318
|
// Parses yield expression inside generator.
|
|
@@ -4303,11 +4369,14 @@ var pp$5 = Parser.prototype;
|
|
|
4303
4369
|
|
|
4304
4370
|
// Object.assign polyfill
|
|
4305
4371
|
var assign$1 = Object.assign || function(target) {
|
|
4372
|
+
var arguments$1 = arguments;
|
|
4373
|
+
|
|
4306
4374
|
var sources = [], len = arguments.length - 1;
|
|
4307
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
4375
|
+
while ( len-- > 0 ) { sources[ len ] = arguments$1[ len + 1 ]; }
|
|
4376
|
+
|
|
4377
|
+
for (var i = 0, list = sources; i < list.length; i += 1) {
|
|
4378
|
+
var source = list[i];
|
|
4308
4379
|
|
|
4309
|
-
for (var i = 0; i < sources.length; i++) {
|
|
4310
|
-
var source = sources[i];
|
|
4311
4380
|
for (var key in source) {
|
|
4312
4381
|
if (has(source, key)) {
|
|
4313
4382
|
target[key] = source[key];
|
|
@@ -4436,10 +4505,11 @@ var TokContext = function TokContext(token, isExpr, preserveSpace, override, gen
|
|
|
4436
4505
|
var types$1 = {
|
|
4437
4506
|
b_stat: new TokContext("{", false),
|
|
4438
4507
|
b_expr: new TokContext("{", true),
|
|
4439
|
-
b_tmpl: new TokContext("${",
|
|
4508
|
+
b_tmpl: new TokContext("${", false),
|
|
4440
4509
|
p_stat: new TokContext("(", false),
|
|
4441
4510
|
p_expr: new TokContext("(", true),
|
|
4442
|
-
q_tmpl: new TokContext("`", true, true, function (p) { return p.
|
|
4511
|
+
q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
|
|
4512
|
+
f_stat: new TokContext("function", false),
|
|
4443
4513
|
f_expr: new TokContext("function", true),
|
|
4444
4514
|
f_expr_gen: new TokContext("function", true, false, null, true),
|
|
4445
4515
|
f_gen: new TokContext("function", false, false, null, true)
|
|
@@ -4452,25 +4522,34 @@ pp$7.initialContext = function() {
|
|
|
4452
4522
|
};
|
|
4453
4523
|
|
|
4454
4524
|
pp$7.braceIsBlock = function(prevType) {
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4525
|
+
var parent = this.curContext();
|
|
4526
|
+
if (parent === types$1.f_expr || parent === types$1.f_stat)
|
|
4527
|
+
{ return true }
|
|
4528
|
+
if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
|
|
4529
|
+
{ return !parent.isExpr }
|
|
4530
|
+
|
|
4531
|
+
// The check for `tt.name && exprAllowed` detects whether we are
|
|
4532
|
+
// after a `yield` or `of` construct. See the `updateContext` for
|
|
4533
|
+
// `tt.name`.
|
|
4534
|
+
if (prevType === types._return || prevType == types.name && this.exprAllowed)
|
|
4461
4535
|
{ return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
|
|
4462
4536
|
if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType == types.arrow)
|
|
4463
4537
|
{ return true }
|
|
4464
4538
|
if (prevType == types.braceL)
|
|
4465
|
-
{ return
|
|
4539
|
+
{ return parent === types$1.b_stat }
|
|
4540
|
+
if (prevType == types._var || prevType == types.name)
|
|
4541
|
+
{ return false }
|
|
4466
4542
|
return !this.exprAllowed
|
|
4467
4543
|
};
|
|
4468
4544
|
|
|
4469
4545
|
pp$7.inGeneratorContext = function() {
|
|
4470
4546
|
var this$1 = this;
|
|
4471
4547
|
|
|
4472
|
-
for (var i = this.context.length - 1; i >=
|
|
4473
|
-
|
|
4548
|
+
for (var i = this.context.length - 1; i >= 1; i--) {
|
|
4549
|
+
var context = this$1.context[i];
|
|
4550
|
+
if (context.token === "function")
|
|
4551
|
+
{ return context.generator }
|
|
4552
|
+
}
|
|
4474
4553
|
return false
|
|
4475
4554
|
};
|
|
4476
4555
|
|
|
@@ -4491,15 +4570,11 @@ types.parenR.updateContext = types.braceR.updateContext = function() {
|
|
|
4491
4570
|
this.exprAllowed = true;
|
|
4492
4571
|
return
|
|
4493
4572
|
}
|
|
4494
|
-
var out = this.context.pop()
|
|
4495
|
-
if (out === types$1.b_stat &&
|
|
4496
|
-
this.context.pop();
|
|
4497
|
-
this.exprAllowed = false;
|
|
4498
|
-
} else if (out === types$1.b_tmpl) {
|
|
4499
|
-
this.exprAllowed = true;
|
|
4500
|
-
} else {
|
|
4501
|
-
this.exprAllowed = !out.isExpr;
|
|
4573
|
+
var out = this.context.pop();
|
|
4574
|
+
if (out === types$1.b_stat && this.curContext().token === "function") {
|
|
4575
|
+
out = this.context.pop();
|
|
4502
4576
|
}
|
|
4577
|
+
this.exprAllowed = !out.isExpr;
|
|
4503
4578
|
};
|
|
4504
4579
|
|
|
4505
4580
|
types.braceL.updateContext = function(prevType) {
|
|
@@ -4522,10 +4597,12 @@ types.incDec.updateContext = function() {
|
|
|
4522
4597
|
// tokExprAllowed stays unchanged
|
|
4523
4598
|
};
|
|
4524
4599
|
|
|
4525
|
-
types._function.updateContext = function(prevType) {
|
|
4600
|
+
types._function.updateContext = types._class.updateContext = function(prevType) {
|
|
4526
4601
|
if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else &&
|
|
4527
4602
|
!((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
|
|
4528
4603
|
{ this.context.push(types$1.f_expr); }
|
|
4604
|
+
else
|
|
4605
|
+
{ this.context.push(types$1.f_stat); }
|
|
4529
4606
|
this.exprAllowed = false;
|
|
4530
4607
|
};
|
|
4531
4608
|
|
|
@@ -4539,10 +4616,11 @@ types.backQuote.updateContext = function() {
|
|
|
4539
4616
|
|
|
4540
4617
|
types.star.updateContext = function(prevType) {
|
|
4541
4618
|
if (prevType == types._function) {
|
|
4542
|
-
|
|
4543
|
-
|
|
4619
|
+
var index = this.context.length - 1;
|
|
4620
|
+
if (this.context[index] === types$1.f_expr)
|
|
4621
|
+
{ this.context[index] = types$1.f_expr_gen; }
|
|
4544
4622
|
else
|
|
4545
|
-
{ this.context
|
|
4623
|
+
{ this.context[index] = types$1.f_gen; }
|
|
4546
4624
|
}
|
|
4547
4625
|
this.exprAllowed = true;
|
|
4548
4626
|
};
|
|
@@ -4677,9 +4755,8 @@ pp$8.skipLineComment = function(startSkip) {
|
|
|
4677
4755
|
var start = this.pos;
|
|
4678
4756
|
var startLoc = this.options.onComment && this.curPosition();
|
|
4679
4757
|
var ch = this.input.charCodeAt(this.pos += startSkip);
|
|
4680
|
-
while (this.pos < this.input.length && ch
|
|
4681
|
-
++this$1.pos;
|
|
4682
|
-
ch = this$1.input.charCodeAt(this$1.pos);
|
|
4758
|
+
while (this.pos < this.input.length && !isNewLine(ch)) {
|
|
4759
|
+
ch = this$1.input.charCodeAt(++this$1.pos);
|
|
4683
4760
|
}
|
|
4684
4761
|
if (this.options.onComment)
|
|
4685
4762
|
{ this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
|
|
@@ -4808,7 +4885,7 @@ pp$8.readToken_plus_min = function(code) { // '+-'
|
|
|
4808
4885
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4809
4886
|
if (next === code) {
|
|
4810
4887
|
if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
|
|
4811
|
-
lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
|
|
4888
|
+
(this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
|
|
4812
4889
|
// A `-->` line comment
|
|
4813
4890
|
this.skipLineComment(3);
|
|
4814
4891
|
this.skipSpace();
|
|
@@ -5061,7 +5138,8 @@ pp$8.readNumber = function(startsWithDot) {
|
|
|
5061
5138
|
var str = this.input.slice(start, this.pos), val;
|
|
5062
5139
|
if (isFloat) { val = parseFloat(str); }
|
|
5063
5140
|
else if (!octal || str.length === 1) { val = parseInt(str, 10); }
|
|
5064
|
-
else if (
|
|
5141
|
+
else if (this.strict) { this.raise(start, "Invalid number"); }
|
|
5142
|
+
else if (/[89]/.test(str)) { val = parseInt(str, 10); }
|
|
5065
5143
|
else { val = parseInt(str, 8); }
|
|
5066
5144
|
return this.finishToken(types.num, val)
|
|
5067
5145
|
};
|
|
@@ -5071,12 +5149,12 @@ pp$8.readNumber = function(startsWithDot) {
|
|
|
5071
5149
|
pp$8.readCodePoint = function() {
|
|
5072
5150
|
var ch = this.input.charCodeAt(this.pos), code;
|
|
5073
5151
|
|
|
5074
|
-
if (ch === 123) {
|
|
5152
|
+
if (ch === 123) { // '{'
|
|
5075
5153
|
if (this.options.ecmaVersion < 6) { this.unexpected(); }
|
|
5076
5154
|
var codePos = ++this.pos;
|
|
5077
5155
|
code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
|
|
5078
5156
|
++this.pos;
|
|
5079
|
-
if (code > 0x10FFFF) { this.
|
|
5157
|
+
if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
|
|
5080
5158
|
} else {
|
|
5081
5159
|
code = this.readHexChar(4);
|
|
5082
5160
|
}
|
|
@@ -5113,6 +5191,31 @@ pp$8.readString = function(quote) {
|
|
|
5113
5191
|
|
|
5114
5192
|
// Reads template string tokens.
|
|
5115
5193
|
|
|
5194
|
+
var INVALID_TEMPLATE_ESCAPE_ERROR = {};
|
|
5195
|
+
|
|
5196
|
+
pp$8.tryReadTemplateToken = function() {
|
|
5197
|
+
this.inTemplateElement = true;
|
|
5198
|
+
try {
|
|
5199
|
+
this.readTmplToken();
|
|
5200
|
+
} catch (err) {
|
|
5201
|
+
if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
|
|
5202
|
+
this.readInvalidTemplateToken();
|
|
5203
|
+
} else {
|
|
5204
|
+
throw err
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
|
|
5208
|
+
this.inTemplateElement = false;
|
|
5209
|
+
};
|
|
5210
|
+
|
|
5211
|
+
pp$8.invalidStringToken = function(position, message) {
|
|
5212
|
+
if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
|
|
5213
|
+
throw INVALID_TEMPLATE_ESCAPE_ERROR
|
|
5214
|
+
} else {
|
|
5215
|
+
this.raise(position, message);
|
|
5216
|
+
}
|
|
5217
|
+
};
|
|
5218
|
+
|
|
5116
5219
|
pp$8.readTmplToken = function() {
|
|
5117
5220
|
var this$1 = this;
|
|
5118
5221
|
|
|
@@ -5121,7 +5224,7 @@ pp$8.readTmplToken = function() {
|
|
|
5121
5224
|
if (this$1.pos >= this$1.input.length) { this$1.raise(this$1.start, "Unterminated template"); }
|
|
5122
5225
|
var ch = this$1.input.charCodeAt(this$1.pos);
|
|
5123
5226
|
if (ch === 96 || ch === 36 && this$1.input.charCodeAt(this$1.pos + 1) === 123) { // '`', '${'
|
|
5124
|
-
if (this$1.pos === this$1.start && this$1.type === types.template) {
|
|
5227
|
+
if (this$1.pos === this$1.start && (this$1.type === types.template || this$1.type === types.invalidTemplate)) {
|
|
5125
5228
|
if (ch === 36) {
|
|
5126
5229
|
this$1.pos += 2;
|
|
5127
5230
|
return this$1.finishToken(types.dollarBraceL)
|
|
@@ -5161,6 +5264,31 @@ pp$8.readTmplToken = function() {
|
|
|
5161
5264
|
}
|
|
5162
5265
|
};
|
|
5163
5266
|
|
|
5267
|
+
// Reads a template token to search for the end, without validating any escape sequences
|
|
5268
|
+
pp$8.readInvalidTemplateToken = function() {
|
|
5269
|
+
var this$1 = this;
|
|
5270
|
+
|
|
5271
|
+
for (; this.pos < this.input.length; this.pos++) {
|
|
5272
|
+
switch (this$1.input[this$1.pos]) {
|
|
5273
|
+
case "\\":
|
|
5274
|
+
++this$1.pos;
|
|
5275
|
+
break
|
|
5276
|
+
|
|
5277
|
+
case "$":
|
|
5278
|
+
if (this$1.input[this$1.pos + 1] !== "{") {
|
|
5279
|
+
break
|
|
5280
|
+
}
|
|
5281
|
+
// falls through
|
|
5282
|
+
|
|
5283
|
+
case "`":
|
|
5284
|
+
return this$1.finishToken(types.invalidTemplate, this$1.input.slice(this$1.start, this$1.pos))
|
|
5285
|
+
|
|
5286
|
+
// no default
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
this.raise(this.start, "Unterminated template");
|
|
5290
|
+
};
|
|
5291
|
+
|
|
5164
5292
|
// Used to read escaped characters
|
|
5165
5293
|
|
|
5166
5294
|
pp$8.readEscapedChar = function(inTemplate) {
|
|
@@ -5188,7 +5316,7 @@ pp$8.readEscapedChar = function(inTemplate) {
|
|
|
5188
5316
|
octal = parseInt(octalStr, 8);
|
|
5189
5317
|
}
|
|
5190
5318
|
if (octalStr !== "0" && (this.strict || inTemplate)) {
|
|
5191
|
-
this.
|
|
5319
|
+
this.invalidStringToken(this.pos - 2, "Octal literal in strict mode");
|
|
5192
5320
|
}
|
|
5193
5321
|
this.pos += octalStr.length - 1;
|
|
5194
5322
|
return String.fromCharCode(octal)
|
|
@@ -5202,7 +5330,7 @@ pp$8.readEscapedChar = function(inTemplate) {
|
|
|
5202
5330
|
pp$8.readHexChar = function(len) {
|
|
5203
5331
|
var codePos = this.pos;
|
|
5204
5332
|
var n = this.readInt(16, len);
|
|
5205
|
-
if (n === null) { this.
|
|
5333
|
+
if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
|
|
5206
5334
|
return n
|
|
5207
5335
|
};
|
|
5208
5336
|
|
|
@@ -5227,11 +5355,11 @@ pp$8.readWord1 = function() {
|
|
|
5227
5355
|
word += this$1.input.slice(chunkStart, this$1.pos);
|
|
5228
5356
|
var escStart = this$1.pos;
|
|
5229
5357
|
if (this$1.input.charCodeAt(++this$1.pos) != 117) // "u"
|
|
5230
|
-
{ this$1.
|
|
5358
|
+
{ this$1.invalidStringToken(this$1.pos, "Expecting Unicode escape sequence \\uXXXX"); }
|
|
5231
5359
|
++this$1.pos;
|
|
5232
5360
|
var esc = this$1.readCodePoint();
|
|
5233
5361
|
if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
|
|
5234
|
-
{ this$1.
|
|
5362
|
+
{ this$1.invalidStringToken(escStart, "Invalid Unicode escape"); }
|
|
5235
5363
|
word += codePointToString(esc);
|
|
5236
5364
|
chunkStart = this$1.pos;
|
|
5237
5365
|
} else {
|
|
@@ -5255,29 +5383,6 @@ pp$8.readWord = function() {
|
|
|
5255
5383
|
return this.finishToken(type, word)
|
|
5256
5384
|
};
|
|
5257
5385
|
|
|
5258
|
-
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
|
5259
|
-
//
|
|
5260
|
-
// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
|
|
5261
|
-
// various contributors and released under an MIT license.
|
|
5262
|
-
//
|
|
5263
|
-
// Git repositories for Acorn are available at
|
|
5264
|
-
//
|
|
5265
|
-
// http://marijnhaverbeke.nl/git/acorn
|
|
5266
|
-
// https://github.com/ternjs/acorn.git
|
|
5267
|
-
//
|
|
5268
|
-
// Please use the [github bug tracker][ghbt] to report issues.
|
|
5269
|
-
//
|
|
5270
|
-
// [ghbt]: https://github.com/ternjs/acorn/issues
|
|
5271
|
-
//
|
|
5272
|
-
// This file defines the main parser interface. The library also comes
|
|
5273
|
-
// with a [error-tolerant parser][dammit] and an
|
|
5274
|
-
// [abstract syntax tree walker][walk], defined in other files.
|
|
5275
|
-
//
|
|
5276
|
-
// [dammit]: acorn_loose.js
|
|
5277
|
-
// [walk]: util/walk.js
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
5386
|
// The main exported interface (under `self.acorn` when in the
|
|
5282
5387
|
// browser) is a `parse` function that takes a code string and
|
|
5283
5388
|
// returns an abstract syntax tree as specified by [Mozilla parser
|
|
@@ -5289,22 +5394,6 @@ function parse(input, options) {
|
|
|
5289
5394
|
return new Parser(options, input).parse()
|
|
5290
5395
|
}
|
|
5291
5396
|
|
|
5292
|
-
// This function tries to parse a single expression at a given
|
|
5293
|
-
// offset in a string. Useful for parsing mixed-language formats
|
|
5294
|
-
// that embed JavaScript expressions.
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
// Acorn is organized as a tokenizer and a recursive-descent parser.
|
|
5299
|
-
// The `tokenizer` export provides an interface to the tokenizer.
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
// This is a terrible kludge to support the existing, pre-ES6
|
|
5304
|
-
// interface where the loose parser module retroactively adds exports
|
|
5305
|
-
// to this module.
|
|
5306
|
-
// eslint-disable-line camelcase
|
|
5307
|
-
|
|
5308
5397
|
function getLocator$1(source, options) {
|
|
5309
5398
|
if (options === void 0) { options = {}; }
|
|
5310
5399
|
var offsetLine = options.offsetLine || 0;
|
|
@@ -6126,33 +6215,35 @@ var BlockStatement = (function (Statement$$1) {
|
|
|
6126
6215
|
return BlockStatement;
|
|
6127
6216
|
}(Statement));
|
|
6128
6217
|
|
|
6129
|
-
function isReference (
|
|
6130
|
-
if (
|
|
6131
|
-
return !node.computed && isReference(
|
|
6218
|
+
function isReference (node, parent) {
|
|
6219
|
+
if (node.type === 'MemberExpression') {
|
|
6220
|
+
return !node.computed && isReference(node.object, node);
|
|
6132
6221
|
}
|
|
6133
6222
|
|
|
6134
|
-
if (
|
|
6223
|
+
if (node.type === 'Identifier') {
|
|
6135
6224
|
// the only time we could have an identifier node without a parent is
|
|
6136
6225
|
// if it's the entire body of a function without a block statement –
|
|
6137
6226
|
// i.e. an arrow function expression like `a => a`
|
|
6138
|
-
if (
|
|
6227
|
+
if (!parent) return true;
|
|
6139
6228
|
|
|
6140
6229
|
// TODO is this right?
|
|
6141
|
-
if (
|
|
6230
|
+
if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
|
|
6142
6231
|
return parent.computed || node === parent.object;
|
|
6143
6232
|
}
|
|
6144
6233
|
|
|
6145
6234
|
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
6146
|
-
if (
|
|
6235
|
+
if (parent.type === 'Property') return parent.computed || node === parent.value;
|
|
6147
6236
|
|
|
6148
6237
|
// disregard the `bar` in `class Foo { bar () {...} }`
|
|
6149
|
-
if (
|
|
6238
|
+
if (parent.type === 'MethodDefinition') return false;
|
|
6150
6239
|
|
|
6151
6240
|
// disregard the `bar` in `export { foo as bar }`
|
|
6152
|
-
if (
|
|
6241
|
+
if (parent.type === 'ExportSpecifier' && node !== parent.local) return false;
|
|
6153
6242
|
|
|
6154
6243
|
return true;
|
|
6155
6244
|
}
|
|
6245
|
+
|
|
6246
|
+
return false;
|
|
6156
6247
|
}
|
|
6157
6248
|
|
|
6158
6249
|
function flatten ( node ) {
|
|
@@ -7183,7 +7274,7 @@ var IfStatement = (function (Statement$$1) {
|
|
|
7183
7274
|
}
|
|
7184
7275
|
|
|
7185
7276
|
else if ( statementsWithIfStatements.has( this.parent.type ) ) {
|
|
7186
|
-
code.
|
|
7277
|
+
code.prependRight( this.start, '{}' );
|
|
7187
7278
|
}
|
|
7188
7279
|
}
|
|
7189
7280
|
}
|
|
@@ -9175,12 +9266,20 @@ function transform ( bundle, source, id, plugins ) {
|
|
|
9175
9266
|
if ( !object.code ) { object.code = code; }
|
|
9176
9267
|
|
|
9177
9268
|
if ( pos !== undefined ) {
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9269
|
+
if ( pos.line !== undefined && pos.column !== undefined ) {
|
|
9270
|
+
var line = pos.line;
|
|
9271
|
+
var column = pos.column;
|
|
9272
|
+
object.loc = { file: id, line: line, column: column };
|
|
9273
|
+
object.frame = getCodeFrame( previous, line, column );
|
|
9274
|
+
}
|
|
9275
|
+
else {
|
|
9276
|
+
object.pos = pos;
|
|
9277
|
+
var ref = locate( previous, pos, { offsetLine: 1 });
|
|
9278
|
+
var line$1 = ref.line;
|
|
9279
|
+
var column$1 = ref.column;
|
|
9280
|
+
object.loc = { file: id, line: line$1, column: column$1 };
|
|
9281
|
+
object.frame = getCodeFrame( previous, line$1, column$1 );
|
|
9282
|
+
}
|
|
9184
9283
|
}
|
|
9185
9284
|
|
|
9186
9285
|
return object;
|
|
@@ -9511,7 +9610,7 @@ var BundleScope = (function (Scope$$1) {
|
|
|
9511
9610
|
return BundleScope;
|
|
9512
9611
|
}(Scope));
|
|
9513
9612
|
|
|
9514
|
-
var Bundle
|
|
9613
|
+
var Bundle = function Bundle ( options ) {
|
|
9515
9614
|
var this$1 = this;
|
|
9516
9615
|
|
|
9517
9616
|
this.cachedModules = new Map();
|
|
@@ -9561,10 +9660,11 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9561
9660
|
this.hasLoaders = loaders.length !== 0;
|
|
9562
9661
|
this.load = first( loaders.concat( load ) );
|
|
9563
9662
|
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9663
|
+
var optionsPaths = options.paths;
|
|
9664
|
+
this.getPath = typeof optionsPaths === 'function' ?
|
|
9665
|
+
( function (id) { return optionsPaths( id ) || this$1.getPathRelativeToEntryDirname( id ); } ) :
|
|
9666
|
+
optionsPaths ?
|
|
9667
|
+
( function (id) { return optionsPaths.hasOwnProperty( id ) ? optionsPaths[ id ] : this$1.getPathRelativeToEntryDirname( id ); } ) :
|
|
9568
9668
|
function (id) { return this$1.getPathRelativeToEntryDirname( id ); };
|
|
9569
9669
|
|
|
9570
9670
|
this.scope = new BundleScope();
|
|
@@ -9579,12 +9679,13 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9579
9679
|
|
|
9580
9680
|
this.context = String( options.context );
|
|
9581
9681
|
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9682
|
+
var optionsModuleContext = options.moduleContext;
|
|
9683
|
+
if ( typeof optionsModuleContext === 'function' ) {
|
|
9684
|
+
this.getModuleContext = function (id) { return optionsModuleContext( id ) || this$1.context; };
|
|
9685
|
+
} else if ( typeof optionsModuleContext === 'object' ) {
|
|
9585
9686
|
var moduleContext = new Map();
|
|
9586
|
-
Object.keys(
|
|
9587
|
-
moduleContext.set( resolve( key ),
|
|
9687
|
+
Object.keys( optionsModuleContext ).forEach( function (key) {
|
|
9688
|
+
moduleContext.set( resolve( key ), optionsModuleContext[ key ] );
|
|
9588
9689
|
});
|
|
9589
9690
|
this.getModuleContext = function (id) { return moduleContext.get( id ) || this$1.context; };
|
|
9590
9691
|
} else {
|
|
@@ -9607,7 +9708,7 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9607
9708
|
this.dependentExpressions = [];
|
|
9608
9709
|
};
|
|
9609
9710
|
|
|
9610
|
-
Bundle
|
|
9711
|
+
Bundle.prototype.build = function build () {
|
|
9611
9712
|
var this$1 = this;
|
|
9612
9713
|
|
|
9613
9714
|
// Phase 1 – discovery. We load the entry module and find which
|
|
@@ -9615,6 +9716,13 @@ Bundle$$1.prototype.build = function build () {
|
|
|
9615
9716
|
// of the entry module's dependencies
|
|
9616
9717
|
return this.resolveId( this.entry, undefined )
|
|
9617
9718
|
.then( function (id) {
|
|
9719
|
+
if ( id === false ) {
|
|
9720
|
+
error({
|
|
9721
|
+
code: 'UNRESOLVED_ENTRY',
|
|
9722
|
+
message: "Entry module cannot be external"
|
|
9723
|
+
});
|
|
9724
|
+
}
|
|
9725
|
+
|
|
9618
9726
|
if ( id == null ) {
|
|
9619
9727
|
error({
|
|
9620
9728
|
code: 'UNRESOLVED_ENTRY',
|
|
@@ -9721,7 +9829,7 @@ Bundle$$1.prototype.build = function build () {
|
|
|
9721
9829
|
});
|
|
9722
9830
|
};
|
|
9723
9831
|
|
|
9724
|
-
Bundle
|
|
9832
|
+
Bundle.prototype.deconflict = function deconflict () {
|
|
9725
9833
|
var used = blank();
|
|
9726
9834
|
|
|
9727
9835
|
// ensure no conflicts with globals
|
|
@@ -9771,7 +9879,7 @@ Bundle$$1.prototype.deconflict = function deconflict () {
|
|
|
9771
9879
|
this.scope.deshadow( toDeshadow );
|
|
9772
9880
|
};
|
|
9773
9881
|
|
|
9774
|
-
Bundle
|
|
9882
|
+
Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
|
|
9775
9883
|
var this$1 = this;
|
|
9776
9884
|
|
|
9777
9885
|
// short-circuit cycles
|
|
@@ -9859,7 +9967,7 @@ Bundle$$1.prototype.fetchModule = function fetchModule ( id, importer ) {
|
|
|
9859
9967
|
});
|
|
9860
9968
|
};
|
|
9861
9969
|
|
|
9862
|
-
Bundle
|
|
9970
|
+
Bundle.prototype.fetchAllDependencies = function fetchAllDependencies ( module ) {
|
|
9863
9971
|
var this$1 = this;
|
|
9864
9972
|
|
|
9865
9973
|
return mapSequence( module.sources, function (source) {
|
|
@@ -9927,7 +10035,7 @@ Bundle$$1.prototype.fetchAllDependencies = function fetchAllDependencies ( modul
|
|
|
9927
10035
|
});
|
|
9928
10036
|
};
|
|
9929
10037
|
|
|
9930
|
-
Bundle
|
|
10038
|
+
Bundle.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEntryDirname ( resolvedId ) {
|
|
9931
10039
|
if ( isRelative( resolvedId ) || isAbsolute( resolvedId ) ) {
|
|
9932
10040
|
var entryDirname = dirname( this.entryId );
|
|
9933
10041
|
var relativeToEntry = normalize( relative( entryDirname, resolvedId ) );
|
|
@@ -9938,7 +10046,7 @@ Bundle$$1.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEn
|
|
|
9938
10046
|
return resolvedId;
|
|
9939
10047
|
};
|
|
9940
10048
|
|
|
9941
|
-
Bundle
|
|
10049
|
+
Bundle.prototype.render = function render ( options ) {
|
|
9942
10050
|
var this$1 = this;
|
|
9943
10051
|
if ( options === void 0 ) options = {};
|
|
9944
10052
|
|
|
@@ -10057,7 +10165,7 @@ Bundle$$1.prototype.render = function render ( options ) {
|
|
|
10057
10165
|
return { code: code, map: map };
|
|
10058
10166
|
};
|
|
10059
10167
|
|
|
10060
|
-
Bundle
|
|
10168
|
+
Bundle.prototype.sort = function sort () {
|
|
10061
10169
|
var this$1 = this;
|
|
10062
10170
|
|
|
10063
10171
|
var hasCycles;
|
|
@@ -10145,7 +10253,7 @@ Bundle$$1.prototype.sort = function sort () {
|
|
|
10145
10253
|
return ordered;
|
|
10146
10254
|
};
|
|
10147
10255
|
|
|
10148
|
-
Bundle
|
|
10256
|
+
Bundle.prototype.warn = function warn ( warning ) {
|
|
10149
10257
|
warning.toString = function () {
|
|
10150
10258
|
var str = '';
|
|
10151
10259
|
|
|
@@ -10159,7 +10267,7 @@ Bundle$$1.prototype.warn = function warn ( warning ) {
|
|
|
10159
10267
|
this.onwarn( warning );
|
|
10160
10268
|
};
|
|
10161
10269
|
|
|
10162
|
-
var VERSION = '0.43.
|
|
10270
|
+
var VERSION = '0.43.1';
|
|
10163
10271
|
|
|
10164
10272
|
var ALLOWED_KEYS = [
|
|
10165
10273
|
'acorn',
|
|
@@ -10195,15 +10303,7 @@ var ALLOWED_KEYS = [
|
|
|
10195
10303
|
'watch'
|
|
10196
10304
|
];
|
|
10197
10305
|
|
|
10198
|
-
function
|
|
10199
|
-
if ( !options ) {
|
|
10200
|
-
throw new Error( 'You must supply an options object to rollup' );
|
|
10201
|
-
}
|
|
10202
|
-
|
|
10203
|
-
if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
|
|
10204
|
-
throw new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' );
|
|
10205
|
-
}
|
|
10206
|
-
|
|
10306
|
+
function checkAmd ( options ) {
|
|
10207
10307
|
if ( options.moduleId ) {
|
|
10208
10308
|
if ( options.amd ) { throw new Error( 'Cannot have both options.amd and options.moduleId' ); }
|
|
10209
10309
|
|
|
@@ -10217,6 +10317,18 @@ function checkOptions ( options ) {
|
|
|
10217
10317
|
console.warn( msg ); // eslint-disable-line no-console
|
|
10218
10318
|
}
|
|
10219
10319
|
}
|
|
10320
|
+
}
|
|
10321
|
+
|
|
10322
|
+
function checkOptions ( options ) {
|
|
10323
|
+
if ( !options ) {
|
|
10324
|
+
throw new Error( 'You must supply an options object to rollup' );
|
|
10325
|
+
}
|
|
10326
|
+
|
|
10327
|
+
if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
|
|
10328
|
+
throw new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' );
|
|
10329
|
+
}
|
|
10330
|
+
|
|
10331
|
+
checkAmd (options);
|
|
10220
10332
|
|
|
10221
10333
|
var err = validateKeys( keys(options), ALLOWED_KEYS );
|
|
10222
10334
|
if ( err ) { throw err; }
|
|
@@ -10225,7 +10337,7 @@ function checkOptions ( options ) {
|
|
|
10225
10337
|
function rollup ( options ) {
|
|
10226
10338
|
try {
|
|
10227
10339
|
checkOptions( options );
|
|
10228
|
-
var bundle = new Bundle
|
|
10340
|
+
var bundle = new Bundle( options );
|
|
10229
10341
|
|
|
10230
10342
|
timeStart( '--BUILD--' );
|
|
10231
10343
|
|
|
@@ -10245,6 +10357,8 @@ function rollup ( options ) {
|
|
|
10245
10357
|
options.format = 'es';
|
|
10246
10358
|
}
|
|
10247
10359
|
|
|
10360
|
+
checkAmd( options );
|
|
10361
|
+
|
|
10248
10362
|
timeStart( '--GENERATE--' );
|
|
10249
10363
|
|
|
10250
10364
|
var rendered = bundle.render( options );
|