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.browser.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:44 GMT-0400 (EDT) - commit 6f3f349afff179d3ea85764390fe74d38544a88b
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
14
|
+
(factory((global.rollup = global.rollup || {})));
|
|
15
15
|
}(this, (function (exports) { 'use strict';
|
|
16
16
|
|
|
17
17
|
var DEBUG = false;
|
|
@@ -219,7 +219,14 @@ function validateKeys ( actualKeys, allowedKeys ) {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
function error ( props ) {
|
|
222
|
-
|
|
222
|
+
// use the same constructor as props (if it's an error object)
|
|
223
|
+
// so that err.name is preserved etc
|
|
224
|
+
// (Object.keys below does not update these values because they
|
|
225
|
+
// are properties on the prototype chain)
|
|
226
|
+
// basically if props is a SyntaxError it will not be overriden as a generic Error
|
|
227
|
+
var constructor = Error;
|
|
228
|
+
if (props instanceof Error) { constructor = props.constructor; }
|
|
229
|
+
var err = new constructor( props.message );
|
|
223
230
|
|
|
224
231
|
Object.keys( props ).forEach( function (key) {
|
|
225
232
|
err[ key ] = props[ key ];
|
|
@@ -1907,7 +1914,7 @@ function isIdentifierChar(code, astral) {
|
|
|
1907
1914
|
// continue jumps to that label.
|
|
1908
1915
|
|
|
1909
1916
|
var TokenType = function TokenType(label, conf) {
|
|
1910
|
-
if ( conf === void 0 ) conf = {};
|
|
1917
|
+
if ( conf === void 0 ) { conf = {}; }
|
|
1911
1918
|
|
|
1912
1919
|
this.label = label;
|
|
1913
1920
|
this.keyword = conf.keyword;
|
|
@@ -1933,7 +1940,7 @@ var keywords$1 = {};
|
|
|
1933
1940
|
|
|
1934
1941
|
// Succinct definitions of keyword token types
|
|
1935
1942
|
function kw(name, options) {
|
|
1936
|
-
if ( options === void 0 ) options = {};
|
|
1943
|
+
if ( options === void 0 ) { options = {}; }
|
|
1937
1944
|
|
|
1938
1945
|
options.keyword = name;
|
|
1939
1946
|
return keywords$1[name] = new TokenType(name, options)
|
|
@@ -1960,6 +1967,7 @@ var types = {
|
|
|
1960
1967
|
question: new TokenType("?", beforeExpr),
|
|
1961
1968
|
arrow: new TokenType("=>", beforeExpr),
|
|
1962
1969
|
template: new TokenType("template"),
|
|
1970
|
+
invalidTemplate: new TokenType("invalidTemplate"),
|
|
1963
1971
|
ellipsis: new TokenType("...", beforeExpr),
|
|
1964
1972
|
backQuote: new TokenType("`", startsExpr),
|
|
1965
1973
|
dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
|
|
@@ -2020,7 +2028,7 @@ var types = {
|
|
|
2020
2028
|
_new: kw("new", {beforeExpr: true, startsExpr: true}),
|
|
2021
2029
|
_this: kw("this", startsExpr),
|
|
2022
2030
|
_super: kw("super", startsExpr),
|
|
2023
|
-
_class: kw("class"),
|
|
2031
|
+
_class: kw("class", startsExpr),
|
|
2024
2032
|
_extends: kw("extends", beforeExpr),
|
|
2025
2033
|
_export: kw("export"),
|
|
2026
2034
|
_import: kw("import"),
|
|
@@ -2228,7 +2236,7 @@ function pushComment(options, array) {
|
|
|
2228
2236
|
var plugins = {};
|
|
2229
2237
|
|
|
2230
2238
|
function keywordRegexp(words) {
|
|
2231
|
-
return new RegExp("^(" + words.replace(/ /g, "|") + ")$")
|
|
2239
|
+
return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
|
|
2232
2240
|
}
|
|
2233
2241
|
|
|
2234
2242
|
var Parser = function Parser(options, input, startPos) {
|
|
@@ -2429,9 +2437,13 @@ pp.unexpected = function(pos) {
|
|
|
2429
2437
|
this.raise(pos != null ? pos : this.start, "Unexpected token");
|
|
2430
2438
|
};
|
|
2431
2439
|
|
|
2432
|
-
|
|
2433
|
-
this.shorthandAssign =
|
|
2434
|
-
|
|
2440
|
+
function DestructuringErrors() {
|
|
2441
|
+
this.shorthandAssign =
|
|
2442
|
+
this.trailingComma =
|
|
2443
|
+
this.parenthesizedAssign =
|
|
2444
|
+
this.parenthesizedBind =
|
|
2445
|
+
-1;
|
|
2446
|
+
}
|
|
2435
2447
|
|
|
2436
2448
|
pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
2437
2449
|
if (!refDestructuringErrors) { return }
|
|
@@ -2814,14 +2826,19 @@ pp$1.parseEmptyStatement = function(node) {
|
|
|
2814
2826
|
pp$1.parseLabeledStatement = function(node, maybeName, expr) {
|
|
2815
2827
|
var this$1 = this;
|
|
2816
2828
|
|
|
2817
|
-
for (var i = 0; i <
|
|
2818
|
-
{
|
|
2829
|
+
for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1)
|
|
2830
|
+
{
|
|
2831
|
+
var label = list[i$1];
|
|
2832
|
+
|
|
2833
|
+
if (label.name === maybeName)
|
|
2834
|
+
{ this$1.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
|
2835
|
+
} }
|
|
2819
2836
|
var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
|
|
2820
|
-
for (var i
|
|
2821
|
-
var label = this$1.labels[i
|
|
2822
|
-
if (label.statementStart == node.start) {
|
|
2823
|
-
label.statementStart = this$1.start;
|
|
2824
|
-
label.kind = kind;
|
|
2837
|
+
for (var i = this.labels.length - 1; i >= 0; i--) {
|
|
2838
|
+
var label$1 = this$1.labels[i];
|
|
2839
|
+
if (label$1.statementStart == node.start) {
|
|
2840
|
+
label$1.statementStart = this$1.start;
|
|
2841
|
+
label$1.kind = kind;
|
|
2825
2842
|
} else { break }
|
|
2826
2843
|
}
|
|
2827
2844
|
this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
|
|
@@ -2847,7 +2864,7 @@ pp$1.parseExpressionStatement = function(node, expr) {
|
|
|
2847
2864
|
|
|
2848
2865
|
pp$1.parseBlock = function(createNewLexicalScope) {
|
|
2849
2866
|
var this$1 = this;
|
|
2850
|
-
if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
|
|
2867
|
+
if ( createNewLexicalScope === void 0 ) { createNewLexicalScope = true; }
|
|
2851
2868
|
|
|
2852
2869
|
var node = this.startNode();
|
|
2853
2870
|
node.body = [];
|
|
@@ -2969,7 +2986,7 @@ pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {
|
|
|
2969
2986
|
|
|
2970
2987
|
pp$1.parseFunctionParams = function(node) {
|
|
2971
2988
|
this.expect(types.parenL);
|
|
2972
|
-
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8
|
|
2989
|
+
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
|
|
2973
2990
|
this.checkYieldAwaitInDefaultParams();
|
|
2974
2991
|
};
|
|
2975
2992
|
|
|
@@ -3103,10 +3120,10 @@ pp$1.parseExport = function(node, exports) {
|
|
|
3103
3120
|
node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
|
|
3104
3121
|
} else {
|
|
3105
3122
|
// check for keywords used as local names
|
|
3106
|
-
for (var i = 0; i <
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3123
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
3124
|
+
var spec = list[i];
|
|
3125
|
+
|
|
3126
|
+
this$1.checkUnreserved(spec.local);
|
|
3110
3127
|
}
|
|
3111
3128
|
|
|
3112
3129
|
node.source = null;
|
|
@@ -3130,12 +3147,17 @@ pp$1.checkPatternExport = function(exports, pat) {
|
|
|
3130
3147
|
if (type == "Identifier")
|
|
3131
3148
|
{ this.checkExport(exports, pat.name, pat.start); }
|
|
3132
3149
|
else if (type == "ObjectPattern")
|
|
3133
|
-
{ for (var i = 0; i <
|
|
3134
|
-
{
|
|
3150
|
+
{ for (var i = 0, list = pat.properties; i < list.length; i += 1)
|
|
3151
|
+
{
|
|
3152
|
+
var prop = list[i];
|
|
3153
|
+
|
|
3154
|
+
this$1.checkPatternExport(exports, prop.value);
|
|
3155
|
+
} }
|
|
3135
3156
|
else if (type == "ArrayPattern")
|
|
3136
|
-
{ for (var i$1 = 0; i$1 <
|
|
3137
|
-
var elt =
|
|
3138
|
-
|
|
3157
|
+
{ for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
3158
|
+
var elt = list$1[i$1];
|
|
3159
|
+
|
|
3160
|
+
if (elt) { this$1.checkPatternExport(exports, elt); }
|
|
3139
3161
|
} }
|
|
3140
3162
|
else if (type == "AssignmentPattern")
|
|
3141
3163
|
{ this.checkPatternExport(exports, pat.left); }
|
|
@@ -3147,8 +3169,12 @@ pp$1.checkVariableExport = function(exports, decls) {
|
|
|
3147
3169
|
var this$1 = this;
|
|
3148
3170
|
|
|
3149
3171
|
if (!exports) { return }
|
|
3150
|
-
for (var i = 0; i <
|
|
3151
|
-
{
|
|
3172
|
+
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
3173
|
+
{
|
|
3174
|
+
var decl = list[i];
|
|
3175
|
+
|
|
3176
|
+
this$1.checkPatternExport(exports, decl.id);
|
|
3177
|
+
}
|
|
3152
3178
|
};
|
|
3153
3179
|
|
|
3154
3180
|
pp$1.shouldParseExportStatement = function() {
|
|
@@ -3235,9 +3261,8 @@ pp$1.parseImportSpecifiers = function() {
|
|
|
3235
3261
|
if (this$1.eatContextual("as")) {
|
|
3236
3262
|
node$2.local = this$1.parseIdent();
|
|
3237
3263
|
} else {
|
|
3264
|
+
this$1.checkUnreserved(node$2.imported);
|
|
3238
3265
|
node$2.local = node$2.imported;
|
|
3239
|
-
if (this$1.isKeyword(node$2.local.name)) { this$1.unexpected(node$2.local.start); }
|
|
3240
|
-
if (this$1.reservedWordsStrict.test(node$2.local.name)) { this$1.raiseRecoverable(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved"); }
|
|
3241
3266
|
}
|
|
3242
3267
|
this$1.checkLVal(node$2.local, "let");
|
|
3243
3268
|
nodes.push(this$1.finishNode(node$2, "ImportSpecifier"));
|
|
@@ -3266,9 +3291,10 @@ pp$2.toAssignable = function(node, isBinding) {
|
|
|
3266
3291
|
|
|
3267
3292
|
case "ObjectExpression":
|
|
3268
3293
|
node.type = "ObjectPattern";
|
|
3269
|
-
for (var i = 0; i <
|
|
3270
|
-
var prop =
|
|
3271
|
-
|
|
3294
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
3295
|
+
var prop = list[i];
|
|
3296
|
+
|
|
3297
|
+
if (prop.kind !== "init") { this$1.raise(prop.key.start, "Object pattern can't contain getter or setter"); }
|
|
3272
3298
|
this$1.toAssignable(prop.value, isBinding);
|
|
3273
3299
|
}
|
|
3274
3300
|
break
|
|
@@ -3293,7 +3319,7 @@ pp$2.toAssignable = function(node, isBinding) {
|
|
|
3293
3319
|
break
|
|
3294
3320
|
|
|
3295
3321
|
case "ParenthesizedExpression":
|
|
3296
|
-
|
|
3322
|
+
this.toAssignable(node.expression, isBinding);
|
|
3297
3323
|
break
|
|
3298
3324
|
|
|
3299
3325
|
case "MemberExpression":
|
|
@@ -3320,12 +3346,10 @@ pp$2.toAssignableList = function(exprList, isBinding) {
|
|
|
3320
3346
|
last.type = "RestElement";
|
|
3321
3347
|
var arg = last.argument;
|
|
3322
3348
|
this.toAssignable(arg, isBinding);
|
|
3323
|
-
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
|
|
3324
|
-
{ this.unexpected(arg.start); }
|
|
3325
3349
|
--end;
|
|
3326
3350
|
}
|
|
3327
3351
|
|
|
3328
|
-
if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
|
|
3352
|
+
if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
|
|
3329
3353
|
{ this.unexpected(last.argument.start); }
|
|
3330
3354
|
}
|
|
3331
3355
|
for (var i = 0; i < end; i++) {
|
|
@@ -3344,13 +3368,15 @@ pp$2.parseSpread = function(refDestructuringErrors) {
|
|
|
3344
3368
|
return this.finishNode(node, "SpreadElement")
|
|
3345
3369
|
};
|
|
3346
3370
|
|
|
3347
|
-
pp$2.
|
|
3371
|
+
pp$2.parseRestBinding = function() {
|
|
3348
3372
|
var node = this.startNode();
|
|
3349
3373
|
this.next();
|
|
3350
3374
|
|
|
3351
3375
|
// RestElement inside of a function parameter must be an identifier
|
|
3352
|
-
if (
|
|
3353
|
-
|
|
3376
|
+
if (this.options.ecmaVersion === 6 && this.type !== types.name)
|
|
3377
|
+
{ this.unexpected(); }
|
|
3378
|
+
|
|
3379
|
+
node.argument = this.parseBindingAtom();
|
|
3354
3380
|
|
|
3355
3381
|
return this.finishNode(node, "RestElement")
|
|
3356
3382
|
};
|
|
@@ -3377,7 +3403,7 @@ pp$2.parseBindingAtom = function() {
|
|
|
3377
3403
|
}
|
|
3378
3404
|
};
|
|
3379
3405
|
|
|
3380
|
-
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma
|
|
3406
|
+
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
3381
3407
|
var this$1 = this;
|
|
3382
3408
|
|
|
3383
3409
|
var elts = [], first = true;
|
|
@@ -3389,7 +3415,7 @@ pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNon
|
|
|
3389
3415
|
} else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
|
|
3390
3416
|
break
|
|
3391
3417
|
} else if (this$1.type === types.ellipsis) {
|
|
3392
|
-
var rest = this$1.
|
|
3418
|
+
var rest = this$1.parseRestBinding();
|
|
3393
3419
|
this$1.parseBindingListItem(rest);
|
|
3394
3420
|
elts.push(rest);
|
|
3395
3421
|
if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
|
|
@@ -3458,14 +3484,19 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) {
|
|
|
3458
3484
|
break
|
|
3459
3485
|
|
|
3460
3486
|
case "ObjectPattern":
|
|
3461
|
-
for (var i = 0; i <
|
|
3462
|
-
{
|
|
3487
|
+
for (var i = 0, list = expr.properties; i < list.length; i += 1)
|
|
3488
|
+
{
|
|
3489
|
+
var prop = list[i];
|
|
3490
|
+
|
|
3491
|
+
this$1.checkLVal(prop.value, bindingType, checkClashes);
|
|
3492
|
+
}
|
|
3463
3493
|
break
|
|
3464
3494
|
|
|
3465
3495
|
case "ArrayPattern":
|
|
3466
|
-
for (var i$1 = 0; i$1 <
|
|
3467
|
-
var elem =
|
|
3468
|
-
|
|
3496
|
+
for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
|
|
3497
|
+
var elem = list$1[i$1];
|
|
3498
|
+
|
|
3499
|
+
if (elem) { this$1.checkLVal(elem, bindingType, checkClashes); }
|
|
3469
3500
|
}
|
|
3470
3501
|
break
|
|
3471
3502
|
|
|
@@ -3767,7 +3798,7 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
|
|
|
3767
3798
|
} else if (this$1.type === types.backQuote) {
|
|
3768
3799
|
var node$2 = this$1.startNodeAt(startPos, startLoc);
|
|
3769
3800
|
node$2.tag = base;
|
|
3770
|
-
node$2.quasi = this$1.parseTemplate();
|
|
3801
|
+
node$2.quasi = this$1.parseTemplate({isTagged: true});
|
|
3771
3802
|
base = this$1.finishNode(node$2, "TaggedTemplateExpression");
|
|
3772
3803
|
} else {
|
|
3773
3804
|
return base
|
|
@@ -3898,7 +3929,7 @@ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
|
|
|
3898
3929
|
break
|
|
3899
3930
|
} else if (this$1.type === types.ellipsis) {
|
|
3900
3931
|
spreadStart = this$1.start;
|
|
3901
|
-
exprList.push(this$1.parseParenItem(this$1.
|
|
3932
|
+
exprList.push(this$1.parseParenItem(this$1.parseRestBinding()));
|
|
3902
3933
|
if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
|
|
3903
3934
|
break
|
|
3904
3935
|
} else {
|
|
@@ -3983,30 +4014,44 @@ pp$3.parseNew = function() {
|
|
|
3983
4014
|
|
|
3984
4015
|
// Parse template expression.
|
|
3985
4016
|
|
|
3986
|
-
pp$3.parseTemplateElement = function() {
|
|
4017
|
+
pp$3.parseTemplateElement = function(ref) {
|
|
4018
|
+
var isTagged = ref.isTagged;
|
|
4019
|
+
|
|
3987
4020
|
var elem = this.startNode();
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
4021
|
+
if (this.type === types.invalidTemplate) {
|
|
4022
|
+
if (!isTagged) {
|
|
4023
|
+
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
|
|
4024
|
+
}
|
|
4025
|
+
elem.value = {
|
|
4026
|
+
raw: this.value,
|
|
4027
|
+
cooked: null
|
|
4028
|
+
};
|
|
4029
|
+
} else {
|
|
4030
|
+
elem.value = {
|
|
4031
|
+
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
|
|
4032
|
+
cooked: this.value
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
3992
4035
|
this.next();
|
|
3993
4036
|
elem.tail = this.type === types.backQuote;
|
|
3994
4037
|
return this.finishNode(elem, "TemplateElement")
|
|
3995
4038
|
};
|
|
3996
4039
|
|
|
3997
|
-
pp$3.parseTemplate = function() {
|
|
4040
|
+
pp$3.parseTemplate = function(ref) {
|
|
3998
4041
|
var this$1 = this;
|
|
4042
|
+
if ( ref === void 0 ) { ref = {}; }
|
|
4043
|
+
var isTagged = ref.isTagged; if ( isTagged === void 0 ) { isTagged = false; }
|
|
3999
4044
|
|
|
4000
4045
|
var node = this.startNode();
|
|
4001
4046
|
this.next();
|
|
4002
4047
|
node.expressions = [];
|
|
4003
|
-
var curElt = this.parseTemplateElement();
|
|
4048
|
+
var curElt = this.parseTemplateElement({isTagged: isTagged});
|
|
4004
4049
|
node.quasis = [curElt];
|
|
4005
4050
|
while (!curElt.tail) {
|
|
4006
4051
|
this$1.expect(types.dollarBraceL);
|
|
4007
4052
|
node.expressions.push(this$1.parseExpression());
|
|
4008
4053
|
this$1.expect(types.braceR);
|
|
4009
|
-
node.quasis.push(curElt = this$1.parseTemplateElement());
|
|
4054
|
+
node.quasis.push(curElt = this$1.parseTemplateElement({isTagged: isTagged}));
|
|
4010
4055
|
}
|
|
4011
4056
|
this.next();
|
|
4012
4057
|
return this.finishNode(node, "TemplateLiteral")
|
|
@@ -4014,6 +4059,12 @@ pp$3.parseTemplate = function() {
|
|
|
4014
4059
|
|
|
4015
4060
|
// Parse an object literal or binding pattern.
|
|
4016
4061
|
|
|
4062
|
+
pp$3.isAsyncProp = function(prop) {
|
|
4063
|
+
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
|
|
4064
|
+
(this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) &&
|
|
4065
|
+
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
|
|
4066
|
+
};
|
|
4067
|
+
|
|
4017
4068
|
pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
|
4018
4069
|
var this$1 = this;
|
|
4019
4070
|
|
|
@@ -4038,9 +4089,7 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
|
|
4038
4089
|
{ isGenerator = this$1.eat(types.star); }
|
|
4039
4090
|
}
|
|
4040
4091
|
this$1.parsePropertyName(prop);
|
|
4041
|
-
if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator &&
|
|
4042
|
-
prop.key.type === "Identifier" && prop.key.name === "async" && this$1.type !== types.parenL &&
|
|
4043
|
-
this$1.type !== types.colon && !this$1.canInsertSemicolon()) {
|
|
4092
|
+
if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && this$1.isAsyncProp(prop)) {
|
|
4044
4093
|
isAsync = true;
|
|
4045
4094
|
this$1.parsePropertyName(prop, refDestructuringErrors);
|
|
4046
4095
|
} else {
|
|
@@ -4084,11 +4133,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
4084
4133
|
{ this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
|
|
4085
4134
|
}
|
|
4086
4135
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
|
4087
|
-
|
|
4088
|
-
(this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) ||
|
|
4089
|
-
(this.inGenerator && prop.key.name == "yield") ||
|
|
4090
|
-
(this.inAsync && prop.key.name == "await"))
|
|
4091
|
-
{ this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property"); }
|
|
4136
|
+
this.checkUnreserved(prop.key);
|
|
4092
4137
|
prop.kind = "init";
|
|
4093
4138
|
if (isPattern) {
|
|
4094
4139
|
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
|
@@ -4232,8 +4277,12 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) {
|
|
|
4232
4277
|
};
|
|
4233
4278
|
|
|
4234
4279
|
pp$3.isSimpleParamList = function(params) {
|
|
4235
|
-
for (var i = 0; i <
|
|
4236
|
-
{
|
|
4280
|
+
for (var i = 0, list = params; i < list.length; i += 1)
|
|
4281
|
+
{
|
|
4282
|
+
var param = list[i];
|
|
4283
|
+
|
|
4284
|
+
if (param.type !== "Identifier") { return false
|
|
4285
|
+
} }
|
|
4237
4286
|
return true
|
|
4238
4287
|
};
|
|
4239
4288
|
|
|
@@ -4244,7 +4293,12 @@ pp$3.checkParams = function(node, allowDuplicates) {
|
|
|
4244
4293
|
var this$1 = this;
|
|
4245
4294
|
|
|
4246
4295
|
var nameHash = {};
|
|
4247
|
-
for (var i = 0
|
|
4296
|
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
4297
|
+
{
|
|
4298
|
+
var param = list[i];
|
|
4299
|
+
|
|
4300
|
+
this$1.checkLVal(param, "var", allowDuplicates ? null : nameHash);
|
|
4301
|
+
}
|
|
4248
4302
|
};
|
|
4249
4303
|
|
|
4250
4304
|
// Parses a comma-separated list of expressions, and returns them as
|
|
@@ -4282,26 +4336,38 @@ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestruct
|
|
|
4282
4336
|
// when parsing properties), it will also convert keywords into
|
|
4283
4337
|
// identifiers.
|
|
4284
4338
|
|
|
4285
|
-
pp$3.
|
|
4339
|
+
pp$3.checkUnreserved = function(ref) {
|
|
4340
|
+
var start = ref.start;
|
|
4341
|
+
var end = ref.end;
|
|
4342
|
+
var name = ref.name;
|
|
4343
|
+
|
|
4344
|
+
if (this.inGenerator && name === "yield")
|
|
4345
|
+
{ this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); }
|
|
4346
|
+
if (this.inAsync && name === "await")
|
|
4347
|
+
{ this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function"); }
|
|
4348
|
+
if (this.isKeyword(name))
|
|
4349
|
+
{ this.raise(start, ("Unexpected keyword '" + name + "'")); }
|
|
4350
|
+
if (this.options.ecmaVersion < 6 &&
|
|
4351
|
+
this.input.slice(start, end).indexOf("\\") != -1) { return }
|
|
4352
|
+
var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
|
|
4353
|
+
if (re.test(name))
|
|
4354
|
+
{ this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); }
|
|
4355
|
+
};
|
|
4356
|
+
|
|
4357
|
+
pp$3.parseIdent = function(liberal, isBinding) {
|
|
4286
4358
|
var node = this.startNode();
|
|
4287
4359
|
if (liberal && this.options.allowReserved == "never") { liberal = false; }
|
|
4288
4360
|
if (this.type === types.name) {
|
|
4289
|
-
if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) &&
|
|
4290
|
-
(this.options.ecmaVersion >= 6 ||
|
|
4291
|
-
this.input.slice(this.start, this.end).indexOf("\\") == -1))
|
|
4292
|
-
{ this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved"); }
|
|
4293
|
-
if (this.inGenerator && this.value === "yield")
|
|
4294
|
-
{ this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator"); }
|
|
4295
|
-
if (this.inAsync && this.value === "await")
|
|
4296
|
-
{ this.raiseRecoverable(this.start, "Can not use 'await' as identifier inside an async function"); }
|
|
4297
4361
|
node.name = this.value;
|
|
4298
|
-
} else if (
|
|
4362
|
+
} else if (this.type.keyword) {
|
|
4299
4363
|
node.name = this.type.keyword;
|
|
4300
4364
|
} else {
|
|
4301
4365
|
this.unexpected();
|
|
4302
4366
|
}
|
|
4303
4367
|
this.next();
|
|
4304
|
-
|
|
4368
|
+
this.finishNode(node, "Identifier");
|
|
4369
|
+
if (!liberal) { this.checkUnreserved(node); }
|
|
4370
|
+
return node
|
|
4305
4371
|
};
|
|
4306
4372
|
|
|
4307
4373
|
// Parses yield expression inside generator.
|
|
@@ -4358,11 +4424,14 @@ var pp$5 = Parser.prototype;
|
|
|
4358
4424
|
|
|
4359
4425
|
// Object.assign polyfill
|
|
4360
4426
|
var assign$1 = Object.assign || function(target) {
|
|
4427
|
+
var arguments$1 = arguments;
|
|
4428
|
+
|
|
4361
4429
|
var sources = [], len = arguments.length - 1;
|
|
4362
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
4430
|
+
while ( len-- > 0 ) { sources[ len ] = arguments$1[ len + 1 ]; }
|
|
4431
|
+
|
|
4432
|
+
for (var i = 0, list = sources; i < list.length; i += 1) {
|
|
4433
|
+
var source = list[i];
|
|
4363
4434
|
|
|
4364
|
-
for (var i = 0; i < sources.length; i++) {
|
|
4365
|
-
var source = sources[i];
|
|
4366
4435
|
for (var key in source) {
|
|
4367
4436
|
if (has(source, key)) {
|
|
4368
4437
|
target[key] = source[key];
|
|
@@ -4491,10 +4560,11 @@ var TokContext = function TokContext(token, isExpr, preserveSpace, override, gen
|
|
|
4491
4560
|
var types$1 = {
|
|
4492
4561
|
b_stat: new TokContext("{", false),
|
|
4493
4562
|
b_expr: new TokContext("{", true),
|
|
4494
|
-
b_tmpl: new TokContext("${",
|
|
4563
|
+
b_tmpl: new TokContext("${", false),
|
|
4495
4564
|
p_stat: new TokContext("(", false),
|
|
4496
4565
|
p_expr: new TokContext("(", true),
|
|
4497
|
-
q_tmpl: new TokContext("`", true, true, function (p) { return p.
|
|
4566
|
+
q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
|
|
4567
|
+
f_stat: new TokContext("function", false),
|
|
4498
4568
|
f_expr: new TokContext("function", true),
|
|
4499
4569
|
f_expr_gen: new TokContext("function", true, false, null, true),
|
|
4500
4570
|
f_gen: new TokContext("function", false, false, null, true)
|
|
@@ -4507,25 +4577,34 @@ pp$7.initialContext = function() {
|
|
|
4507
4577
|
};
|
|
4508
4578
|
|
|
4509
4579
|
pp$7.braceIsBlock = function(prevType) {
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4580
|
+
var parent = this.curContext();
|
|
4581
|
+
if (parent === types$1.f_expr || parent === types$1.f_stat)
|
|
4582
|
+
{ return true }
|
|
4583
|
+
if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
|
|
4584
|
+
{ return !parent.isExpr }
|
|
4585
|
+
|
|
4586
|
+
// The check for `tt.name && exprAllowed` detects whether we are
|
|
4587
|
+
// after a `yield` or `of` construct. See the `updateContext` for
|
|
4588
|
+
// `tt.name`.
|
|
4589
|
+
if (prevType === types._return || prevType == types.name && this.exprAllowed)
|
|
4516
4590
|
{ return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
|
|
4517
4591
|
if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType == types.arrow)
|
|
4518
4592
|
{ return true }
|
|
4519
4593
|
if (prevType == types.braceL)
|
|
4520
|
-
{ return
|
|
4594
|
+
{ return parent === types$1.b_stat }
|
|
4595
|
+
if (prevType == types._var || prevType == types.name)
|
|
4596
|
+
{ return false }
|
|
4521
4597
|
return !this.exprAllowed
|
|
4522
4598
|
};
|
|
4523
4599
|
|
|
4524
4600
|
pp$7.inGeneratorContext = function() {
|
|
4525
4601
|
var this$1 = this;
|
|
4526
4602
|
|
|
4527
|
-
for (var i = this.context.length - 1; i >=
|
|
4528
|
-
|
|
4603
|
+
for (var i = this.context.length - 1; i >= 1; i--) {
|
|
4604
|
+
var context = this$1.context[i];
|
|
4605
|
+
if (context.token === "function")
|
|
4606
|
+
{ return context.generator }
|
|
4607
|
+
}
|
|
4529
4608
|
return false
|
|
4530
4609
|
};
|
|
4531
4610
|
|
|
@@ -4546,15 +4625,11 @@ types.parenR.updateContext = types.braceR.updateContext = function() {
|
|
|
4546
4625
|
this.exprAllowed = true;
|
|
4547
4626
|
return
|
|
4548
4627
|
}
|
|
4549
|
-
var out = this.context.pop()
|
|
4550
|
-
if (out === types$1.b_stat &&
|
|
4551
|
-
this.context.pop();
|
|
4552
|
-
this.exprAllowed = false;
|
|
4553
|
-
} else if (out === types$1.b_tmpl) {
|
|
4554
|
-
this.exprAllowed = true;
|
|
4555
|
-
} else {
|
|
4556
|
-
this.exprAllowed = !out.isExpr;
|
|
4628
|
+
var out = this.context.pop();
|
|
4629
|
+
if (out === types$1.b_stat && this.curContext().token === "function") {
|
|
4630
|
+
out = this.context.pop();
|
|
4557
4631
|
}
|
|
4632
|
+
this.exprAllowed = !out.isExpr;
|
|
4558
4633
|
};
|
|
4559
4634
|
|
|
4560
4635
|
types.braceL.updateContext = function(prevType) {
|
|
@@ -4577,10 +4652,12 @@ types.incDec.updateContext = function() {
|
|
|
4577
4652
|
// tokExprAllowed stays unchanged
|
|
4578
4653
|
};
|
|
4579
4654
|
|
|
4580
|
-
types._function.updateContext = function(prevType) {
|
|
4655
|
+
types._function.updateContext = types._class.updateContext = function(prevType) {
|
|
4581
4656
|
if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else &&
|
|
4582
4657
|
!((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
|
|
4583
4658
|
{ this.context.push(types$1.f_expr); }
|
|
4659
|
+
else
|
|
4660
|
+
{ this.context.push(types$1.f_stat); }
|
|
4584
4661
|
this.exprAllowed = false;
|
|
4585
4662
|
};
|
|
4586
4663
|
|
|
@@ -4594,10 +4671,11 @@ types.backQuote.updateContext = function() {
|
|
|
4594
4671
|
|
|
4595
4672
|
types.star.updateContext = function(prevType) {
|
|
4596
4673
|
if (prevType == types._function) {
|
|
4597
|
-
|
|
4598
|
-
|
|
4674
|
+
var index = this.context.length - 1;
|
|
4675
|
+
if (this.context[index] === types$1.f_expr)
|
|
4676
|
+
{ this.context[index] = types$1.f_expr_gen; }
|
|
4599
4677
|
else
|
|
4600
|
-
{ this.context
|
|
4678
|
+
{ this.context[index] = types$1.f_gen; }
|
|
4601
4679
|
}
|
|
4602
4680
|
this.exprAllowed = true;
|
|
4603
4681
|
};
|
|
@@ -4732,9 +4810,8 @@ pp$8.skipLineComment = function(startSkip) {
|
|
|
4732
4810
|
var start = this.pos;
|
|
4733
4811
|
var startLoc = this.options.onComment && this.curPosition();
|
|
4734
4812
|
var ch = this.input.charCodeAt(this.pos += startSkip);
|
|
4735
|
-
while (this.pos < this.input.length && ch
|
|
4736
|
-
++this$1.pos;
|
|
4737
|
-
ch = this$1.input.charCodeAt(this$1.pos);
|
|
4813
|
+
while (this.pos < this.input.length && !isNewLine(ch)) {
|
|
4814
|
+
ch = this$1.input.charCodeAt(++this$1.pos);
|
|
4738
4815
|
}
|
|
4739
4816
|
if (this.options.onComment)
|
|
4740
4817
|
{ this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
|
|
@@ -4863,7 +4940,7 @@ pp$8.readToken_plus_min = function(code) { // '+-'
|
|
|
4863
4940
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4864
4941
|
if (next === code) {
|
|
4865
4942
|
if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
|
|
4866
|
-
lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
|
|
4943
|
+
(this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
|
|
4867
4944
|
// A `-->` line comment
|
|
4868
4945
|
this.skipLineComment(3);
|
|
4869
4946
|
this.skipSpace();
|
|
@@ -5116,7 +5193,8 @@ pp$8.readNumber = function(startsWithDot) {
|
|
|
5116
5193
|
var str = this.input.slice(start, this.pos), val;
|
|
5117
5194
|
if (isFloat) { val = parseFloat(str); }
|
|
5118
5195
|
else if (!octal || str.length === 1) { val = parseInt(str, 10); }
|
|
5119
|
-
else if (
|
|
5196
|
+
else if (this.strict) { this.raise(start, "Invalid number"); }
|
|
5197
|
+
else if (/[89]/.test(str)) { val = parseInt(str, 10); }
|
|
5120
5198
|
else { val = parseInt(str, 8); }
|
|
5121
5199
|
return this.finishToken(types.num, val)
|
|
5122
5200
|
};
|
|
@@ -5126,12 +5204,12 @@ pp$8.readNumber = function(startsWithDot) {
|
|
|
5126
5204
|
pp$8.readCodePoint = function() {
|
|
5127
5205
|
var ch = this.input.charCodeAt(this.pos), code;
|
|
5128
5206
|
|
|
5129
|
-
if (ch === 123) {
|
|
5207
|
+
if (ch === 123) { // '{'
|
|
5130
5208
|
if (this.options.ecmaVersion < 6) { this.unexpected(); }
|
|
5131
5209
|
var codePos = ++this.pos;
|
|
5132
5210
|
code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
|
|
5133
5211
|
++this.pos;
|
|
5134
|
-
if (code > 0x10FFFF) { this.
|
|
5212
|
+
if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
|
|
5135
5213
|
} else {
|
|
5136
5214
|
code = this.readHexChar(4);
|
|
5137
5215
|
}
|
|
@@ -5168,6 +5246,31 @@ pp$8.readString = function(quote) {
|
|
|
5168
5246
|
|
|
5169
5247
|
// Reads template string tokens.
|
|
5170
5248
|
|
|
5249
|
+
var INVALID_TEMPLATE_ESCAPE_ERROR = {};
|
|
5250
|
+
|
|
5251
|
+
pp$8.tryReadTemplateToken = function() {
|
|
5252
|
+
this.inTemplateElement = true;
|
|
5253
|
+
try {
|
|
5254
|
+
this.readTmplToken();
|
|
5255
|
+
} catch (err) {
|
|
5256
|
+
if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
|
|
5257
|
+
this.readInvalidTemplateToken();
|
|
5258
|
+
} else {
|
|
5259
|
+
throw err
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
|
|
5263
|
+
this.inTemplateElement = false;
|
|
5264
|
+
};
|
|
5265
|
+
|
|
5266
|
+
pp$8.invalidStringToken = function(position, message) {
|
|
5267
|
+
if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
|
|
5268
|
+
throw INVALID_TEMPLATE_ESCAPE_ERROR
|
|
5269
|
+
} else {
|
|
5270
|
+
this.raise(position, message);
|
|
5271
|
+
}
|
|
5272
|
+
};
|
|
5273
|
+
|
|
5171
5274
|
pp$8.readTmplToken = function() {
|
|
5172
5275
|
var this$1 = this;
|
|
5173
5276
|
|
|
@@ -5176,7 +5279,7 @@ pp$8.readTmplToken = function() {
|
|
|
5176
5279
|
if (this$1.pos >= this$1.input.length) { this$1.raise(this$1.start, "Unterminated template"); }
|
|
5177
5280
|
var ch = this$1.input.charCodeAt(this$1.pos);
|
|
5178
5281
|
if (ch === 96 || ch === 36 && this$1.input.charCodeAt(this$1.pos + 1) === 123) { // '`', '${'
|
|
5179
|
-
if (this$1.pos === this$1.start && this$1.type === types.template) {
|
|
5282
|
+
if (this$1.pos === this$1.start && (this$1.type === types.template || this$1.type === types.invalidTemplate)) {
|
|
5180
5283
|
if (ch === 36) {
|
|
5181
5284
|
this$1.pos += 2;
|
|
5182
5285
|
return this$1.finishToken(types.dollarBraceL)
|
|
@@ -5216,6 +5319,31 @@ pp$8.readTmplToken = function() {
|
|
|
5216
5319
|
}
|
|
5217
5320
|
};
|
|
5218
5321
|
|
|
5322
|
+
// Reads a template token to search for the end, without validating any escape sequences
|
|
5323
|
+
pp$8.readInvalidTemplateToken = function() {
|
|
5324
|
+
var this$1 = this;
|
|
5325
|
+
|
|
5326
|
+
for (; this.pos < this.input.length; this.pos++) {
|
|
5327
|
+
switch (this$1.input[this$1.pos]) {
|
|
5328
|
+
case "\\":
|
|
5329
|
+
++this$1.pos;
|
|
5330
|
+
break
|
|
5331
|
+
|
|
5332
|
+
case "$":
|
|
5333
|
+
if (this$1.input[this$1.pos + 1] !== "{") {
|
|
5334
|
+
break
|
|
5335
|
+
}
|
|
5336
|
+
// falls through
|
|
5337
|
+
|
|
5338
|
+
case "`":
|
|
5339
|
+
return this$1.finishToken(types.invalidTemplate, this$1.input.slice(this$1.start, this$1.pos))
|
|
5340
|
+
|
|
5341
|
+
// no default
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
this.raise(this.start, "Unterminated template");
|
|
5345
|
+
};
|
|
5346
|
+
|
|
5219
5347
|
// Used to read escaped characters
|
|
5220
5348
|
|
|
5221
5349
|
pp$8.readEscapedChar = function(inTemplate) {
|
|
@@ -5243,7 +5371,7 @@ pp$8.readEscapedChar = function(inTemplate) {
|
|
|
5243
5371
|
octal = parseInt(octalStr, 8);
|
|
5244
5372
|
}
|
|
5245
5373
|
if (octalStr !== "0" && (this.strict || inTemplate)) {
|
|
5246
|
-
this.
|
|
5374
|
+
this.invalidStringToken(this.pos - 2, "Octal literal in strict mode");
|
|
5247
5375
|
}
|
|
5248
5376
|
this.pos += octalStr.length - 1;
|
|
5249
5377
|
return String.fromCharCode(octal)
|
|
@@ -5257,7 +5385,7 @@ pp$8.readEscapedChar = function(inTemplate) {
|
|
|
5257
5385
|
pp$8.readHexChar = function(len) {
|
|
5258
5386
|
var codePos = this.pos;
|
|
5259
5387
|
var n = this.readInt(16, len);
|
|
5260
|
-
if (n === null) { this.
|
|
5388
|
+
if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
|
|
5261
5389
|
return n
|
|
5262
5390
|
};
|
|
5263
5391
|
|
|
@@ -5282,11 +5410,11 @@ pp$8.readWord1 = function() {
|
|
|
5282
5410
|
word += this$1.input.slice(chunkStart, this$1.pos);
|
|
5283
5411
|
var escStart = this$1.pos;
|
|
5284
5412
|
if (this$1.input.charCodeAt(++this$1.pos) != 117) // "u"
|
|
5285
|
-
{ this$1.
|
|
5413
|
+
{ this$1.invalidStringToken(this$1.pos, "Expecting Unicode escape sequence \\uXXXX"); }
|
|
5286
5414
|
++this$1.pos;
|
|
5287
5415
|
var esc = this$1.readCodePoint();
|
|
5288
5416
|
if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
|
|
5289
|
-
{ this$1.
|
|
5417
|
+
{ this$1.invalidStringToken(escStart, "Invalid Unicode escape"); }
|
|
5290
5418
|
word += codePointToString(esc);
|
|
5291
5419
|
chunkStart = this$1.pos;
|
|
5292
5420
|
} else {
|
|
@@ -5310,29 +5438,6 @@ pp$8.readWord = function() {
|
|
|
5310
5438
|
return this.finishToken(type, word)
|
|
5311
5439
|
};
|
|
5312
5440
|
|
|
5313
|
-
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
|
5314
|
-
//
|
|
5315
|
-
// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
|
|
5316
|
-
// various contributors and released under an MIT license.
|
|
5317
|
-
//
|
|
5318
|
-
// Git repositories for Acorn are available at
|
|
5319
|
-
//
|
|
5320
|
-
// http://marijnhaverbeke.nl/git/acorn
|
|
5321
|
-
// https://github.com/ternjs/acorn.git
|
|
5322
|
-
//
|
|
5323
|
-
// Please use the [github bug tracker][ghbt] to report issues.
|
|
5324
|
-
//
|
|
5325
|
-
// [ghbt]: https://github.com/ternjs/acorn/issues
|
|
5326
|
-
//
|
|
5327
|
-
// This file defines the main parser interface. The library also comes
|
|
5328
|
-
// with a [error-tolerant parser][dammit] and an
|
|
5329
|
-
// [abstract syntax tree walker][walk], defined in other files.
|
|
5330
|
-
//
|
|
5331
|
-
// [dammit]: acorn_loose.js
|
|
5332
|
-
// [walk]: util/walk.js
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
5441
|
// The main exported interface (under `self.acorn` when in the
|
|
5337
5442
|
// browser) is a `parse` function that takes a code string and
|
|
5338
5443
|
// returns an abstract syntax tree as specified by [Mozilla parser
|
|
@@ -5344,22 +5449,6 @@ function parse(input, options) {
|
|
|
5344
5449
|
return new Parser(options, input).parse()
|
|
5345
5450
|
}
|
|
5346
5451
|
|
|
5347
|
-
// This function tries to parse a single expression at a given
|
|
5348
|
-
// offset in a string. Useful for parsing mixed-language formats
|
|
5349
|
-
// that embed JavaScript expressions.
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
// Acorn is organized as a tokenizer and a recursive-descent parser.
|
|
5354
|
-
// The `tokenizer` export provides an interface to the tokenizer.
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
// This is a terrible kludge to support the existing, pre-ES6
|
|
5359
|
-
// interface where the loose parser module retroactively adds exports
|
|
5360
|
-
// to this module.
|
|
5361
|
-
// eslint-disable-line camelcase
|
|
5362
|
-
|
|
5363
5452
|
function getLocator$1(source, options) {
|
|
5364
5453
|
if (options === void 0) { options = {}; }
|
|
5365
5454
|
var offsetLine = options.offsetLine || 0;
|
|
@@ -6181,33 +6270,35 @@ var BlockStatement = (function (Statement$$1) {
|
|
|
6181
6270
|
return BlockStatement;
|
|
6182
6271
|
}(Statement));
|
|
6183
6272
|
|
|
6184
|
-
function isReference (
|
|
6185
|
-
if (
|
|
6186
|
-
return !node.computed && isReference(
|
|
6273
|
+
function isReference (node, parent) {
|
|
6274
|
+
if (node.type === 'MemberExpression') {
|
|
6275
|
+
return !node.computed && isReference(node.object, node);
|
|
6187
6276
|
}
|
|
6188
6277
|
|
|
6189
|
-
if (
|
|
6278
|
+
if (node.type === 'Identifier') {
|
|
6190
6279
|
// the only time we could have an identifier node without a parent is
|
|
6191
6280
|
// if it's the entire body of a function without a block statement –
|
|
6192
6281
|
// i.e. an arrow function expression like `a => a`
|
|
6193
|
-
if (
|
|
6282
|
+
if (!parent) return true;
|
|
6194
6283
|
|
|
6195
6284
|
// TODO is this right?
|
|
6196
|
-
if (
|
|
6285
|
+
if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
|
|
6197
6286
|
return parent.computed || node === parent.object;
|
|
6198
6287
|
}
|
|
6199
6288
|
|
|
6200
6289
|
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
6201
|
-
if (
|
|
6290
|
+
if (parent.type === 'Property') return parent.computed || node === parent.value;
|
|
6202
6291
|
|
|
6203
6292
|
// disregard the `bar` in `class Foo { bar () {...} }`
|
|
6204
|
-
if (
|
|
6293
|
+
if (parent.type === 'MethodDefinition') return false;
|
|
6205
6294
|
|
|
6206
6295
|
// disregard the `bar` in `export { foo as bar }`
|
|
6207
|
-
if (
|
|
6296
|
+
if (parent.type === 'ExportSpecifier' && node !== parent.local) return false;
|
|
6208
6297
|
|
|
6209
6298
|
return true;
|
|
6210
6299
|
}
|
|
6300
|
+
|
|
6301
|
+
return false;
|
|
6211
6302
|
}
|
|
6212
6303
|
|
|
6213
6304
|
function flatten ( node ) {
|
|
@@ -7238,7 +7329,7 @@ var IfStatement = (function (Statement$$1) {
|
|
|
7238
7329
|
}
|
|
7239
7330
|
|
|
7240
7331
|
else if ( statementsWithIfStatements.has( this.parent.type ) ) {
|
|
7241
|
-
code.
|
|
7332
|
+
code.prependRight( this.start, '{}' );
|
|
7242
7333
|
}
|
|
7243
7334
|
}
|
|
7244
7335
|
}
|
|
@@ -9230,12 +9321,20 @@ function transform ( bundle, source, id, plugins ) {
|
|
|
9230
9321
|
if ( !object.code ) { object.code = code; }
|
|
9231
9322
|
|
|
9232
9323
|
if ( pos !== undefined ) {
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9324
|
+
if ( pos.line !== undefined && pos.column !== undefined ) {
|
|
9325
|
+
var line = pos.line;
|
|
9326
|
+
var column = pos.column;
|
|
9327
|
+
object.loc = { file: id, line: line, column: column };
|
|
9328
|
+
object.frame = getCodeFrame( previous, line, column );
|
|
9329
|
+
}
|
|
9330
|
+
else {
|
|
9331
|
+
object.pos = pos;
|
|
9332
|
+
var ref = locate( previous, pos, { offsetLine: 1 });
|
|
9333
|
+
var line$1 = ref.line;
|
|
9334
|
+
var column$1 = ref.column;
|
|
9335
|
+
object.loc = { file: id, line: line$1, column: column$1 };
|
|
9336
|
+
object.frame = getCodeFrame( previous, line$1, column$1 );
|
|
9337
|
+
}
|
|
9239
9338
|
}
|
|
9240
9339
|
|
|
9241
9340
|
return object;
|
|
@@ -9566,7 +9665,7 @@ var BundleScope = (function (Scope$$1) {
|
|
|
9566
9665
|
return BundleScope;
|
|
9567
9666
|
}(Scope));
|
|
9568
9667
|
|
|
9569
|
-
var Bundle
|
|
9668
|
+
var Bundle = function Bundle ( options ) {
|
|
9570
9669
|
var this$1 = this;
|
|
9571
9670
|
|
|
9572
9671
|
this.cachedModules = new Map();
|
|
@@ -9616,10 +9715,11 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9616
9715
|
this.hasLoaders = loaders.length !== 0;
|
|
9617
9716
|
this.load = first( loaders.concat( load ) );
|
|
9618
9717
|
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9718
|
+
var optionsPaths = options.paths;
|
|
9719
|
+
this.getPath = typeof optionsPaths === 'function' ?
|
|
9720
|
+
( function (id) { return optionsPaths( id ) || this$1.getPathRelativeToEntryDirname( id ); } ) :
|
|
9721
|
+
optionsPaths ?
|
|
9722
|
+
( function (id) { return optionsPaths.hasOwnProperty( id ) ? optionsPaths[ id ] : this$1.getPathRelativeToEntryDirname( id ); } ) :
|
|
9623
9723
|
function (id) { return this$1.getPathRelativeToEntryDirname( id ); };
|
|
9624
9724
|
|
|
9625
9725
|
this.scope = new BundleScope();
|
|
@@ -9634,12 +9734,13 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9634
9734
|
|
|
9635
9735
|
this.context = String( options.context );
|
|
9636
9736
|
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9737
|
+
var optionsModuleContext = options.moduleContext;
|
|
9738
|
+
if ( typeof optionsModuleContext === 'function' ) {
|
|
9739
|
+
this.getModuleContext = function (id) { return optionsModuleContext( id ) || this$1.context; };
|
|
9740
|
+
} else if ( typeof optionsModuleContext === 'object' ) {
|
|
9640
9741
|
var moduleContext = new Map();
|
|
9641
|
-
Object.keys(
|
|
9642
|
-
moduleContext.set( resolve( key ),
|
|
9742
|
+
Object.keys( optionsModuleContext ).forEach( function (key) {
|
|
9743
|
+
moduleContext.set( resolve( key ), optionsModuleContext[ key ] );
|
|
9643
9744
|
});
|
|
9644
9745
|
this.getModuleContext = function (id) { return moduleContext.get( id ) || this$1.context; };
|
|
9645
9746
|
} else {
|
|
@@ -9662,7 +9763,7 @@ var Bundle$$1 = function Bundle$$1 ( options ) {
|
|
|
9662
9763
|
this.dependentExpressions = [];
|
|
9663
9764
|
};
|
|
9664
9765
|
|
|
9665
|
-
Bundle
|
|
9766
|
+
Bundle.prototype.build = function build () {
|
|
9666
9767
|
var this$1 = this;
|
|
9667
9768
|
|
|
9668
9769
|
// Phase 1 – discovery. We load the entry module and find which
|
|
@@ -9670,6 +9771,13 @@ Bundle$$1.prototype.build = function build () {
|
|
|
9670
9771
|
// of the entry module's dependencies
|
|
9671
9772
|
return this.resolveId( this.entry, undefined )
|
|
9672
9773
|
.then( function (id) {
|
|
9774
|
+
if ( id === false ) {
|
|
9775
|
+
error({
|
|
9776
|
+
code: 'UNRESOLVED_ENTRY',
|
|
9777
|
+
message: "Entry module cannot be external"
|
|
9778
|
+
});
|
|
9779
|
+
}
|
|
9780
|
+
|
|
9673
9781
|
if ( id == null ) {
|
|
9674
9782
|
error({
|
|
9675
9783
|
code: 'UNRESOLVED_ENTRY',
|
|
@@ -9776,7 +9884,7 @@ Bundle$$1.prototype.build = function build () {
|
|
|
9776
9884
|
});
|
|
9777
9885
|
};
|
|
9778
9886
|
|
|
9779
|
-
Bundle
|
|
9887
|
+
Bundle.prototype.deconflict = function deconflict () {
|
|
9780
9888
|
var used = blank();
|
|
9781
9889
|
|
|
9782
9890
|
// ensure no conflicts with globals
|
|
@@ -9826,7 +9934,7 @@ Bundle$$1.prototype.deconflict = function deconflict () {
|
|
|
9826
9934
|
this.scope.deshadow( toDeshadow );
|
|
9827
9935
|
};
|
|
9828
9936
|
|
|
9829
|
-
Bundle
|
|
9937
|
+
Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
|
|
9830
9938
|
var this$1 = this;
|
|
9831
9939
|
|
|
9832
9940
|
// short-circuit cycles
|
|
@@ -9914,7 +10022,7 @@ Bundle$$1.prototype.fetchModule = function fetchModule ( id, importer ) {
|
|
|
9914
10022
|
});
|
|
9915
10023
|
};
|
|
9916
10024
|
|
|
9917
|
-
Bundle
|
|
10025
|
+
Bundle.prototype.fetchAllDependencies = function fetchAllDependencies ( module ) {
|
|
9918
10026
|
var this$1 = this;
|
|
9919
10027
|
|
|
9920
10028
|
return mapSequence( module.sources, function (source) {
|
|
@@ -9982,7 +10090,7 @@ Bundle$$1.prototype.fetchAllDependencies = function fetchAllDependencies ( modul
|
|
|
9982
10090
|
});
|
|
9983
10091
|
};
|
|
9984
10092
|
|
|
9985
|
-
Bundle
|
|
10093
|
+
Bundle.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEntryDirname ( resolvedId ) {
|
|
9986
10094
|
if ( isRelative( resolvedId ) || isAbsolute( resolvedId ) ) {
|
|
9987
10095
|
var entryDirname = dirname( this.entryId );
|
|
9988
10096
|
var relativeToEntry = normalize( relative( entryDirname, resolvedId ) );
|
|
@@ -9993,7 +10101,7 @@ Bundle$$1.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEn
|
|
|
9993
10101
|
return resolvedId;
|
|
9994
10102
|
};
|
|
9995
10103
|
|
|
9996
|
-
Bundle
|
|
10104
|
+
Bundle.prototype.render = function render ( options ) {
|
|
9997
10105
|
var this$1 = this;
|
|
9998
10106
|
if ( options === void 0 ) options = {};
|
|
9999
10107
|
|
|
@@ -10112,7 +10220,7 @@ Bundle$$1.prototype.render = function render ( options ) {
|
|
|
10112
10220
|
return { code: code, map: map };
|
|
10113
10221
|
};
|
|
10114
10222
|
|
|
10115
|
-
Bundle
|
|
10223
|
+
Bundle.prototype.sort = function sort () {
|
|
10116
10224
|
var this$1 = this;
|
|
10117
10225
|
|
|
10118
10226
|
var hasCycles;
|
|
@@ -10200,7 +10308,7 @@ Bundle$$1.prototype.sort = function sort () {
|
|
|
10200
10308
|
return ordered;
|
|
10201
10309
|
};
|
|
10202
10310
|
|
|
10203
|
-
Bundle
|
|
10311
|
+
Bundle.prototype.warn = function warn ( warning ) {
|
|
10204
10312
|
warning.toString = function () {
|
|
10205
10313
|
var str = '';
|
|
10206
10314
|
|
|
@@ -10214,7 +10322,7 @@ Bundle$$1.prototype.warn = function warn ( warning ) {
|
|
|
10214
10322
|
this.onwarn( warning );
|
|
10215
10323
|
};
|
|
10216
10324
|
|
|
10217
|
-
var VERSION = '0.43.
|
|
10325
|
+
var VERSION = '0.43.1';
|
|
10218
10326
|
|
|
10219
10327
|
var ALLOWED_KEYS = [
|
|
10220
10328
|
'acorn',
|
|
@@ -10250,15 +10358,7 @@ var ALLOWED_KEYS = [
|
|
|
10250
10358
|
'watch'
|
|
10251
10359
|
];
|
|
10252
10360
|
|
|
10253
|
-
function
|
|
10254
|
-
if ( !options ) {
|
|
10255
|
-
throw new Error( 'You must supply an options object to rollup' );
|
|
10256
|
-
}
|
|
10257
|
-
|
|
10258
|
-
if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
|
|
10259
|
-
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' );
|
|
10260
|
-
}
|
|
10261
|
-
|
|
10361
|
+
function checkAmd ( options ) {
|
|
10262
10362
|
if ( options.moduleId ) {
|
|
10263
10363
|
if ( options.amd ) { throw new Error( 'Cannot have both options.amd and options.moduleId' ); }
|
|
10264
10364
|
|
|
@@ -10272,6 +10372,18 @@ function checkOptions ( options ) {
|
|
|
10272
10372
|
console.warn( msg ); // eslint-disable-line no-console
|
|
10273
10373
|
}
|
|
10274
10374
|
}
|
|
10375
|
+
}
|
|
10376
|
+
|
|
10377
|
+
function checkOptions ( options ) {
|
|
10378
|
+
if ( !options ) {
|
|
10379
|
+
throw new Error( 'You must supply an options object to rollup' );
|
|
10380
|
+
}
|
|
10381
|
+
|
|
10382
|
+
if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
|
|
10383
|
+
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' );
|
|
10384
|
+
}
|
|
10385
|
+
|
|
10386
|
+
checkAmd (options);
|
|
10275
10387
|
|
|
10276
10388
|
var err = validateKeys( keys(options), ALLOWED_KEYS );
|
|
10277
10389
|
if ( err ) { throw err; }
|
|
@@ -10280,7 +10392,7 @@ function checkOptions ( options ) {
|
|
|
10280
10392
|
function rollup ( options ) {
|
|
10281
10393
|
try {
|
|
10282
10394
|
checkOptions( options );
|
|
10283
|
-
var bundle = new Bundle
|
|
10395
|
+
var bundle = new Bundle( options );
|
|
10284
10396
|
|
|
10285
10397
|
timeStart( '--BUILD--' );
|
|
10286
10398
|
|
|
@@ -10300,6 +10412,8 @@ function rollup ( options ) {
|
|
|
10300
10412
|
options.format = 'es';
|
|
10301
10413
|
}
|
|
10302
10414
|
|
|
10415
|
+
checkAmd( options );
|
|
10416
|
+
|
|
10303
10417
|
timeStart( '--GENERATE--' );
|
|
10304
10418
|
|
|
10305
10419
|
var rendered = bundle.render( options );
|