rollup 2.53.3 → 2.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/dist/bin/rollup +15 -8
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +183 -155
- package/dist/es/shared/watch.js +10 -6
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +7 -5
- package/dist/shared/loadConfigFile.js +8 -4
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +183 -155
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +5 -3
- package/package.json +1 -1
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.56.0
|
|
4
|
+
Thu, 05 Aug 2021 05:18:15 GMT - commit ffd5cad3339c8d42bff3e9ae7c6c8ef12fced50a
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -19,7 +19,7 @@ function _interopNamespaceDefaultOnly(e) {
|
|
|
19
19
|
return {__proto__: null, 'default': e};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
var version$1 = "2.
|
|
22
|
+
var version$1 = "2.56.0";
|
|
23
23
|
|
|
24
24
|
function ensureArray(items) {
|
|
25
25
|
if (Array.isArray(items)) {
|
|
@@ -1982,6 +1982,8 @@ Bundle$1.prototype.trimEnd = function trimEnd (charType) {
|
|
|
1982
1982
|
return this;
|
|
1983
1983
|
};
|
|
1984
1984
|
|
|
1985
|
+
var MagicString$1 = MagicString;
|
|
1986
|
+
|
|
1985
1987
|
function relative(from, to) {
|
|
1986
1988
|
const fromParts = from.split(/[/\\]/).filter(Boolean);
|
|
1987
1989
|
const toParts = to.split(/[/\\]/).filter(Boolean);
|
|
@@ -3164,35 +3166,54 @@ function removeLineBreaks(code, start, end) {
|
|
|
3164
3166
|
}
|
|
3165
3167
|
}
|
|
3166
3168
|
|
|
3167
|
-
function getSystemExportStatement(exportedVariables,
|
|
3168
|
-
const _ =
|
|
3169
|
+
function getSystemExportStatement(exportedVariables, { compact, exportNamesByVariable }, modifier = '') {
|
|
3170
|
+
const _ = compact ? '' : ' ';
|
|
3169
3171
|
if (exportedVariables.length === 1 &&
|
|
3170
|
-
|
|
3172
|
+
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
3171
3173
|
const variable = exportedVariables[0];
|
|
3172
|
-
return `exports('${
|
|
3174
|
+
return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName()}${modifier})`;
|
|
3173
3175
|
}
|
|
3174
3176
|
else {
|
|
3175
3177
|
return `exports({${_}${exportedVariables
|
|
3176
3178
|
.map(variable => {
|
|
3177
|
-
return
|
|
3179
|
+
return exportNamesByVariable
|
|
3178
3180
|
.get(variable)
|
|
3179
|
-
.map(exportName => `${exportName}:${_}${variable.getName()}`)
|
|
3181
|
+
.map(exportName => `${exportName}:${_}${variable.getName()}${modifier}`)
|
|
3180
3182
|
.join(`,${_}`);
|
|
3181
3183
|
})
|
|
3182
3184
|
.join(`,${_}`)}${_}})`;
|
|
3183
3185
|
}
|
|
3184
3186
|
}
|
|
3185
|
-
function
|
|
3187
|
+
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { compact, exportNamesByVariable }) {
|
|
3188
|
+
const _ = compact ? '' : ' ';
|
|
3189
|
+
code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
|
|
3190
|
+
code.appendLeft(expressionEnd, ')');
|
|
3191
|
+
}
|
|
3192
|
+
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
3186
3193
|
const _ = options.compact ? '' : ' ';
|
|
3187
3194
|
const s = options.compact ? '' : ';';
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3195
|
+
code.prependRight(expressionStart, `function${_}(v)${_}{${_}return ${getSystemExportStatement(exportedVariables, options)},${_}v${s}${_}}(`);
|
|
3196
|
+
code.appendLeft(expressionEnd, ')');
|
|
3197
|
+
if (needsParens) {
|
|
3198
|
+
code.prependRight(expressionStart, '(');
|
|
3199
|
+
code.appendLeft(expressionEnd, ')');
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
|
|
3203
|
+
const _ = options.compact ? '' : ' ';
|
|
3204
|
+
code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName()}`);
|
|
3205
|
+
if (needsParens) {
|
|
3206
|
+
code.prependRight(expressionStart, '(');
|
|
3207
|
+
code.appendLeft(expressionEnd, ')');
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
|
|
3211
|
+
const _ = options.compact ? '' : ' ';
|
|
3212
|
+
code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
|
|
3213
|
+
if (needsParens) {
|
|
3214
|
+
code.prependRight(expressionStart, '(');
|
|
3215
|
+
code.appendLeft(expressionEnd, ')');
|
|
3216
|
+
}
|
|
3196
3217
|
}
|
|
3197
3218
|
|
|
3198
3219
|
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
|
@@ -3389,8 +3410,6 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
3389
3410
|
return members[memberName].returns;
|
|
3390
3411
|
}
|
|
3391
3412
|
|
|
3392
|
-
// To avoid infinite recursions
|
|
3393
|
-
const MAX_PATH_DEPTH = 7;
|
|
3394
3413
|
class LocalVariable extends Variable {
|
|
3395
3414
|
constructor(name, declarator, init, context) {
|
|
3396
3415
|
super(name);
|
|
@@ -3419,8 +3438,7 @@ class LocalVariable extends Variable {
|
|
|
3419
3438
|
}
|
|
3420
3439
|
deoptimizePath(path) {
|
|
3421
3440
|
var _a, _b;
|
|
3422
|
-
if (
|
|
3423
|
-
this.isReassigned ||
|
|
3441
|
+
if (this.isReassigned ||
|
|
3424
3442
|
this.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
3425
3443
|
return;
|
|
3426
3444
|
}
|
|
@@ -3440,13 +3458,13 @@ class LocalVariable extends Variable {
|
|
|
3440
3458
|
}
|
|
3441
3459
|
}
|
|
3442
3460
|
deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
|
|
3443
|
-
if (this.isReassigned || !this.init
|
|
3461
|
+
if (this.isReassigned || !this.init) {
|
|
3444
3462
|
return thisParameter.deoptimizePath(UNKNOWN_PATH);
|
|
3445
3463
|
}
|
|
3446
3464
|
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker), undefined);
|
|
3447
3465
|
}
|
|
3448
3466
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
3449
|
-
if (this.isReassigned || !this.init
|
|
3467
|
+
if (this.isReassigned || !this.init) {
|
|
3450
3468
|
return UnknownValue;
|
|
3451
3469
|
}
|
|
3452
3470
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
@@ -3455,7 +3473,7 @@ class LocalVariable extends Variable {
|
|
|
3455
3473
|
}, UnknownValue);
|
|
3456
3474
|
}
|
|
3457
3475
|
getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
|
|
3458
|
-
if (this.isReassigned || !this.init
|
|
3476
|
+
if (this.isReassigned || !this.init) {
|
|
3459
3477
|
return UNKNOWN_EXPRESSION;
|
|
3460
3478
|
}
|
|
3461
3479
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
@@ -3464,14 +3482,14 @@ class LocalVariable extends Variable {
|
|
|
3464
3482
|
}, UNKNOWN_EXPRESSION);
|
|
3465
3483
|
}
|
|
3466
3484
|
hasEffectsWhenAccessedAtPath(path, context) {
|
|
3467
|
-
if (this.isReassigned
|
|
3485
|
+
if (this.isReassigned)
|
|
3468
3486
|
return true;
|
|
3469
3487
|
return (this.init &&
|
|
3470
3488
|
!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
3471
3489
|
this.init.hasEffectsWhenAccessedAtPath(path, context));
|
|
3472
3490
|
}
|
|
3473
3491
|
hasEffectsWhenAssignedAtPath(path, context) {
|
|
3474
|
-
if (this.included
|
|
3492
|
+
if (this.included)
|
|
3475
3493
|
return true;
|
|
3476
3494
|
if (path.length === 0)
|
|
3477
3495
|
return false;
|
|
@@ -3482,7 +3500,7 @@ class LocalVariable extends Variable {
|
|
|
3482
3500
|
this.init.hasEffectsWhenAssignedAtPath(path, context));
|
|
3483
3501
|
}
|
|
3484
3502
|
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
3485
|
-
if (
|
|
3503
|
+
if (this.isReassigned)
|
|
3486
3504
|
return true;
|
|
3487
3505
|
return (this.init &&
|
|
3488
3506
|
!(callOptions.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, callOptions, this) &&
|
|
@@ -4657,6 +4675,32 @@ class Identifier extends NodeBase {
|
|
|
4657
4675
|
includeCallArguments(context, args) {
|
|
4658
4676
|
this.getVariableRespectingTDZ().includeCallArguments(context, args);
|
|
4659
4677
|
}
|
|
4678
|
+
isPossibleTDZ() {
|
|
4679
|
+
// return cached value to avoid issues with the next tree-shaking pass
|
|
4680
|
+
if (this.isTDZAccess !== null)
|
|
4681
|
+
return this.isTDZAccess;
|
|
4682
|
+
if (!(this.variable instanceof LocalVariable) ||
|
|
4683
|
+
!this.variable.kind ||
|
|
4684
|
+
!(this.variable.kind in tdzVariableKinds)) {
|
|
4685
|
+
return (this.isTDZAccess = false);
|
|
4686
|
+
}
|
|
4687
|
+
let decl_id;
|
|
4688
|
+
if (this.variable.declarations &&
|
|
4689
|
+
this.variable.declarations.length === 1 &&
|
|
4690
|
+
(decl_id = this.variable.declarations[0]) &&
|
|
4691
|
+
this.start < decl_id.start &&
|
|
4692
|
+
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
|
|
4693
|
+
// a variable accessed before its declaration
|
|
4694
|
+
// in the same function or at top level of module
|
|
4695
|
+
return (this.isTDZAccess = true);
|
|
4696
|
+
}
|
|
4697
|
+
if (!this.variable.initReached) {
|
|
4698
|
+
// Either a const/let TDZ violation or
|
|
4699
|
+
// var use before declaration was encountered.
|
|
4700
|
+
return (this.isTDZAccess = true);
|
|
4701
|
+
}
|
|
4702
|
+
return (this.isTDZAccess = false);
|
|
4703
|
+
}
|
|
4660
4704
|
markDeclarationReached() {
|
|
4661
4705
|
this.variable.initReached = true;
|
|
4662
4706
|
}
|
|
@@ -4699,32 +4743,6 @@ class Identifier extends NodeBase {
|
|
|
4699
4743
|
}
|
|
4700
4744
|
return this.variable;
|
|
4701
4745
|
}
|
|
4702
|
-
isPossibleTDZ() {
|
|
4703
|
-
// return cached value to avoid issues with the next tree-shaking pass
|
|
4704
|
-
if (this.isTDZAccess !== null)
|
|
4705
|
-
return this.isTDZAccess;
|
|
4706
|
-
if (!(this.variable instanceof LocalVariable) ||
|
|
4707
|
-
!this.variable.kind ||
|
|
4708
|
-
!(this.variable.kind in tdzVariableKinds)) {
|
|
4709
|
-
return (this.isTDZAccess = false);
|
|
4710
|
-
}
|
|
4711
|
-
let decl_id;
|
|
4712
|
-
if (this.variable.declarations &&
|
|
4713
|
-
this.variable.declarations.length === 1 &&
|
|
4714
|
-
(decl_id = this.variable.declarations[0]) &&
|
|
4715
|
-
this.start < decl_id.start &&
|
|
4716
|
-
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
|
|
4717
|
-
// a variable accessed before its declaration
|
|
4718
|
-
// in the same function or at top level of module
|
|
4719
|
-
return (this.isTDZAccess = true);
|
|
4720
|
-
}
|
|
4721
|
-
if (!this.variable.initReached) {
|
|
4722
|
-
// Either a const/let TDZ violation or
|
|
4723
|
-
// var use before declaration was encountered.
|
|
4724
|
-
return (this.isTDZAccess = true);
|
|
4725
|
-
}
|
|
4726
|
-
return (this.isTDZAccess = false);
|
|
4727
|
-
}
|
|
4728
4746
|
}
|
|
4729
4747
|
function closestParentFunctionOrProgram(node) {
|
|
4730
4748
|
while (node && !/^Program|Function/.test(node.type)) {
|
|
@@ -5193,7 +5211,7 @@ class ObjectMember extends ExpressionEntity {
|
|
|
5193
5211
|
this.object.deoptimizePath([this.key, ...path]);
|
|
5194
5212
|
}
|
|
5195
5213
|
deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
|
|
5196
|
-
this.object.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
|
|
5214
|
+
this.object.deoptimizeThisOnEventAtPath(event, [this.key, ...path], thisParameter, recursionTracker);
|
|
5197
5215
|
}
|
|
5198
5216
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5199
5217
|
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
@@ -6131,7 +6149,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
6131
6149
|
let isInDeclaration = false;
|
|
6132
6150
|
let hasRenderedContent = false;
|
|
6133
6151
|
let separatorString = '', leadingString, nextSeparatorString;
|
|
6134
|
-
const
|
|
6152
|
+
const aggregatedSystemExports = [];
|
|
6153
|
+
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
6135
6154
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
6136
6155
|
if (!node.included) {
|
|
6137
6156
|
code.remove(start, end);
|
|
@@ -6148,21 +6167,9 @@ class VariableDeclaration extends NodeBase {
|
|
|
6148
6167
|
isInDeclaration = false;
|
|
6149
6168
|
}
|
|
6150
6169
|
else {
|
|
6151
|
-
if (
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
}
|
|
6155
|
-
else {
|
|
6156
|
-
const exportNames = options.exportNamesByVariable.get(node.id.variable);
|
|
6157
|
-
if (exportNames) {
|
|
6158
|
-
const _ = options.compact ? '' : ' ';
|
|
6159
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
6160
|
-
code.prependLeft(findNonWhiteSpace(code.original, operatorPos + 1), exportNames.length === 1
|
|
6161
|
-
? `exports('${exportNames[0]}',${_}`
|
|
6162
|
-
: getSystemExportFunctionLeft([node.id.variable], false, options));
|
|
6163
|
-
nextSeparatorString += ')';
|
|
6164
|
-
}
|
|
6165
|
-
}
|
|
6170
|
+
if (singleSystemExport && singleSystemExport === node.id.variable) {
|
|
6171
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
6172
|
+
renderSystemExportExpression(singleSystemExport, findNonWhiteSpace(code.original, operatorPos + 1), separator === null ? contentEnd : separator, code, options);
|
|
6166
6173
|
}
|
|
6167
6174
|
if (isInDeclaration) {
|
|
6168
6175
|
separatorString += ',';
|
|
@@ -6189,9 +6196,34 @@ class VariableDeclaration extends NodeBase {
|
|
|
6189
6196
|
lastSeparatorPos = separator;
|
|
6190
6197
|
separatorString = nextSeparatorString;
|
|
6191
6198
|
}
|
|
6192
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd,
|
|
6199
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, isNoStatement);
|
|
6193
6200
|
}
|
|
6194
6201
|
}
|
|
6202
|
+
function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
|
|
6203
|
+
var _a;
|
|
6204
|
+
let singleSystemExport = null;
|
|
6205
|
+
if (options.format === 'system') {
|
|
6206
|
+
for (const { node } of separatedNodes) {
|
|
6207
|
+
if (node.id instanceof Identifier &&
|
|
6208
|
+
node.init &&
|
|
6209
|
+
aggregatedSystemExports.length === 0 &&
|
|
6210
|
+
((_a = options.exportNamesByVariable.get(node.id.variable)) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
6211
|
+
singleSystemExport = node.id.variable;
|
|
6212
|
+
aggregatedSystemExports.push(singleSystemExport);
|
|
6213
|
+
}
|
|
6214
|
+
else {
|
|
6215
|
+
node.id.addExportedVariables(aggregatedSystemExports, options.exportNamesByVariable);
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6218
|
+
if (aggregatedSystemExports.length > 1) {
|
|
6219
|
+
singleSystemExport = null;
|
|
6220
|
+
}
|
|
6221
|
+
else if (singleSystemExport) {
|
|
6222
|
+
aggregatedSystemExports.length = 0;
|
|
6223
|
+
}
|
|
6224
|
+
}
|
|
6225
|
+
return singleSystemExport;
|
|
6226
|
+
}
|
|
6195
6227
|
|
|
6196
6228
|
const NEW_ARRAY_PROPERTIES = [
|
|
6197
6229
|
{ key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
|
|
@@ -6644,7 +6676,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
6644
6676
|
}
|
|
6645
6677
|
this.right.include(context, includeChildrenRecursively);
|
|
6646
6678
|
}
|
|
6647
|
-
render(code, options, { preventASI, renderedParentType } = BLANK) {
|
|
6679
|
+
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
6648
6680
|
if (this.left.included) {
|
|
6649
6681
|
this.left.render(code, options);
|
|
6650
6682
|
this.right.render(code, options);
|
|
@@ -6656,26 +6688,27 @@ class AssignmentExpression extends NodeBase {
|
|
|
6656
6688
|
removeLineBreaks(code, inclusionStart, this.right.start);
|
|
6657
6689
|
}
|
|
6658
6690
|
this.right.render(code, options, {
|
|
6659
|
-
renderedParentType: renderedParentType || this.parent.type
|
|
6691
|
+
renderedParentType: renderedParentType || renderedSurroundingElement || this.parent.type
|
|
6660
6692
|
});
|
|
6661
6693
|
}
|
|
6662
6694
|
if (options.format === 'system') {
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
const
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6695
|
+
if (this.left instanceof Identifier) {
|
|
6696
|
+
const variable = this.left.variable;
|
|
6697
|
+
const exportNames = options.exportNamesByVariable.get(variable);
|
|
6698
|
+
if (exportNames) {
|
|
6699
|
+
if (exportNames.length === 1) {
|
|
6700
|
+
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
6701
|
+
}
|
|
6702
|
+
else {
|
|
6703
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6672
6706
|
}
|
|
6673
6707
|
else {
|
|
6674
6708
|
const systemPatternExports = [];
|
|
6675
6709
|
this.left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
6676
6710
|
if (systemPatternExports.length > 0) {
|
|
6677
|
-
|
|
6678
|
-
code.appendLeft(this.end, '))');
|
|
6711
|
+
renderSystemExportFunction(systemPatternExports, this.start, this.end, (renderedParentType || renderedSurroundingElement) === ExpressionStatement$1, code, options);
|
|
6679
6712
|
}
|
|
6680
6713
|
}
|
|
6681
6714
|
}
|
|
@@ -6838,6 +6871,8 @@ class BreakStatement extends NodeBase {
|
|
|
6838
6871
|
}
|
|
6839
6872
|
}
|
|
6840
6873
|
|
|
6874
|
+
// To avoid infinite recursions
|
|
6875
|
+
const MAX_PATH_DEPTH = 7;
|
|
6841
6876
|
function getResolvablePropertyKey(memberExpression) {
|
|
6842
6877
|
return memberExpression.computed
|
|
6843
6878
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -6919,7 +6954,9 @@ class MemberExpression extends NodeBase {
|
|
|
6919
6954
|
this.variable.deoptimizePath(path);
|
|
6920
6955
|
}
|
|
6921
6956
|
else if (!this.replacement) {
|
|
6922
|
-
|
|
6957
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
6958
|
+
this.object.deoptimizePath([this.getPropertyKey(), ...path]);
|
|
6959
|
+
}
|
|
6923
6960
|
}
|
|
6924
6961
|
}
|
|
6925
6962
|
deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
|
|
@@ -6927,7 +6964,12 @@ class MemberExpression extends NodeBase {
|
|
|
6927
6964
|
this.variable.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
|
|
6928
6965
|
}
|
|
6929
6966
|
else if (!this.replacement) {
|
|
6930
|
-
|
|
6967
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
6968
|
+
this.object.deoptimizeThisOnEventAtPath(event, [this.getPropertyKey(), ...path], thisParameter, recursionTracker);
|
|
6969
|
+
}
|
|
6970
|
+
else {
|
|
6971
|
+
thisParameter.deoptimizePath(UNKNOWN_PATH);
|
|
6972
|
+
}
|
|
6931
6973
|
}
|
|
6932
6974
|
}
|
|
6933
6975
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6938,7 +6980,10 @@ class MemberExpression extends NodeBase {
|
|
|
6938
6980
|
return UnknownValue;
|
|
6939
6981
|
}
|
|
6940
6982
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6941
|
-
|
|
6983
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
6984
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
6985
|
+
}
|
|
6986
|
+
return UnknownValue;
|
|
6942
6987
|
}
|
|
6943
6988
|
getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
|
|
6944
6989
|
if (this.variable !== null) {
|
|
@@ -6948,7 +6993,10 @@ class MemberExpression extends NodeBase {
|
|
|
6948
6993
|
return UNKNOWN_EXPRESSION;
|
|
6949
6994
|
}
|
|
6950
6995
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6951
|
-
|
|
6996
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
6997
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], callOptions, recursionTracker, origin);
|
|
6998
|
+
}
|
|
6999
|
+
return UNKNOWN_EXPRESSION;
|
|
6952
7000
|
}
|
|
6953
7001
|
hasEffects(context) {
|
|
6954
7002
|
if (!this.deoptimized)
|
|
@@ -6972,7 +7020,10 @@ class MemberExpression extends NodeBase {
|
|
|
6972
7020
|
if (this.replacement) {
|
|
6973
7021
|
return true;
|
|
6974
7022
|
}
|
|
6975
|
-
|
|
7023
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
7024
|
+
return this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey(), ...path], context);
|
|
7025
|
+
}
|
|
7026
|
+
return true;
|
|
6976
7027
|
}
|
|
6977
7028
|
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6978
7029
|
if (this.variable !== null) {
|
|
@@ -6981,7 +7032,10 @@ class MemberExpression extends NodeBase {
|
|
|
6981
7032
|
if (this.replacement) {
|
|
6982
7033
|
return true;
|
|
6983
7034
|
}
|
|
6984
|
-
|
|
7035
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
7036
|
+
return this.object.hasEffectsWhenAssignedAtPath([this.getPropertyKey(), ...path], context);
|
|
7037
|
+
}
|
|
7038
|
+
return true;
|
|
6985
7039
|
}
|
|
6986
7040
|
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6987
7041
|
if (this.variable !== null) {
|
|
@@ -6990,7 +7044,10 @@ class MemberExpression extends NodeBase {
|
|
|
6990
7044
|
if (this.replacement) {
|
|
6991
7045
|
return true;
|
|
6992
7046
|
}
|
|
6993
|
-
|
|
7047
|
+
if (path.length < MAX_PATH_DEPTH) {
|
|
7048
|
+
return this.object.hasEffectsWhenCalledAtPath([this.getPropertyKey(), ...path], callOptions, context);
|
|
7049
|
+
}
|
|
7050
|
+
return true;
|
|
6994
7051
|
}
|
|
6995
7052
|
include(context, includeChildrenRecursively) {
|
|
6996
7053
|
if (!this.deoptimized)
|
|
@@ -8104,12 +8161,12 @@ class ImportExpression extends NodeBase {
|
|
|
8104
8161
|
if (this.inlineNamespace) {
|
|
8105
8162
|
const _ = options.compact ? '' : ' ';
|
|
8106
8163
|
const s = options.compact ? '' : ';';
|
|
8107
|
-
code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})
|
|
8164
|
+
code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})`, { contentOnly: true });
|
|
8108
8165
|
return;
|
|
8109
8166
|
}
|
|
8110
8167
|
if (this.mechanism) {
|
|
8111
|
-
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
|
|
8112
|
-
code.overwrite(this.end - 1, this.end, this.mechanism.right);
|
|
8168
|
+
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
|
|
8169
|
+
code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
|
|
8113
8170
|
}
|
|
8114
8171
|
this.source.render(code, options);
|
|
8115
8172
|
}
|
|
@@ -8537,7 +8594,7 @@ const accessedFileUrlGlobals = {
|
|
|
8537
8594
|
umd: ['document', 'require', 'URL']
|
|
8538
8595
|
};
|
|
8539
8596
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
|
8540
|
-
const getRelativeUrlFromDocument = (relativePath) => getResolveUrl(`'${relativePath}', document.currentScript && document.currentScript.src || document.baseURI`);
|
|
8597
|
+
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${relativePath}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
|
8541
8598
|
const getGenericImportMetaMechanism = (getUrl) => (prop, chunkId) => {
|
|
8542
8599
|
const urlMechanism = getUrl(chunkId);
|
|
8543
8600
|
return prop === null
|
|
@@ -8546,7 +8603,7 @@ const getGenericImportMetaMechanism = (getUrl) => (prop, chunkId) => {
|
|
|
8546
8603
|
? urlMechanism
|
|
8547
8604
|
: 'undefined';
|
|
8548
8605
|
};
|
|
8549
|
-
const getUrlFromDocument = (chunkId) => `(document.currentScript && document.currentScript.src || new URL('${chunkId}', document.baseURI).href)`;
|
|
8606
|
+
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(document.currentScript && document.currentScript.src || new URL('${chunkId}', document.baseURI).href)`;
|
|
8550
8607
|
const relativeUrlMechanisms = {
|
|
8551
8608
|
amd: relativePath => {
|
|
8552
8609
|
if (relativePath[0] !== '.')
|
|
@@ -8557,14 +8614,14 @@ const relativeUrlMechanisms = {
|
|
|
8557
8614
|
es: relativePath => getResolveUrl(`'${relativePath}', import.meta.url`),
|
|
8558
8615
|
iife: relativePath => getRelativeUrlFromDocument(relativePath),
|
|
8559
8616
|
system: relativePath => getResolveUrl(`'${relativePath}', module.meta.url`),
|
|
8560
|
-
umd: relativePath => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath)})`
|
|
8617
|
+
umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath, true)})`
|
|
8561
8618
|
};
|
|
8562
8619
|
const importMetaMechanisms = {
|
|
8563
8620
|
amd: getGenericImportMetaMechanism(() => getResolveUrl(`module.uri, document.baseURI`)),
|
|
8564
8621
|
cjs: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId)})`),
|
|
8565
8622
|
iife: getGenericImportMetaMechanism(chunkId => getUrlFromDocument(chunkId)),
|
|
8566
8623
|
system: prop => (prop === null ? `module.meta` : `module.meta.${prop}`),
|
|
8567
|
-
umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId)})`)
|
|
8624
|
+
umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId, true)})`)
|
|
8568
8625
|
};
|
|
8569
8626
|
|
|
8570
8627
|
class NewExpression extends NodeBase {
|
|
@@ -9116,7 +9173,8 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
9116
9173
|
getDirectOriginalVariable() {
|
|
9117
9174
|
return this.originalId &&
|
|
9118
9175
|
(this.hasId ||
|
|
9119
|
-
!(this.originalId.
|
|
9176
|
+
!(this.originalId.isPossibleTDZ() ||
|
|
9177
|
+
this.originalId.variable.isReassigned ||
|
|
9120
9178
|
this.originalId.variable instanceof UndefinedVariable ||
|
|
9121
9179
|
// this avoids a circular dependency
|
|
9122
9180
|
'syntheticNamespace' in this.originalId.variable))
|
|
@@ -9357,31 +9415,19 @@ class UpdateExpression extends NodeBase {
|
|
|
9357
9415
|
if (options.format === 'system') {
|
|
9358
9416
|
const variable = this.argument.variable;
|
|
9359
9417
|
const exportNames = options.exportNamesByVariable.get(variable);
|
|
9360
|
-
if (exportNames
|
|
9418
|
+
if (exportNames) {
|
|
9361
9419
|
const _ = options.compact ? '' : ' ';
|
|
9362
|
-
const name = variable.getName();
|
|
9363
9420
|
if (this.prefix) {
|
|
9364
9421
|
if (exportNames.length === 1) {
|
|
9365
|
-
|
|
9422
|
+
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
9366
9423
|
}
|
|
9367
9424
|
else {
|
|
9368
|
-
|
|
9425
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
9369
9426
|
}
|
|
9370
9427
|
}
|
|
9371
|
-
else if (exportNames.length > 1) {
|
|
9372
|
-
code.overwrite(this.start, this.end, `(${getSystemExportFunctionLeft([variable], false, options)}${this.operator}${name}))`);
|
|
9373
|
-
}
|
|
9374
9428
|
else {
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
case '++':
|
|
9378
|
-
op = `${name}${_}+${_}1`;
|
|
9379
|
-
break;
|
|
9380
|
-
case '--':
|
|
9381
|
-
op = `${name}${_}-${_}1`;
|
|
9382
|
-
break;
|
|
9383
|
-
}
|
|
9384
|
-
code.overwrite(this.start, this.end, `(exports('${exportNames[0]}',${_}${op}),${_}${name}${this.operator})`);
|
|
9429
|
+
const operator = this.operator[0];
|
|
9430
|
+
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options, `${_}${operator}${_}1`);
|
|
9385
9431
|
}
|
|
9386
9432
|
}
|
|
9387
9433
|
}
|
|
@@ -10330,7 +10376,7 @@ class Module {
|
|
|
10330
10376
|
// By default, `id` is the file name. Custom resolvers and loaders
|
|
10331
10377
|
// can change that, but it makes sense to use it for the source file name
|
|
10332
10378
|
const fileName = this.id;
|
|
10333
|
-
this.magicString = new MagicString(code, {
|
|
10379
|
+
this.magicString = new MagicString$1(code, {
|
|
10334
10380
|
filename: (this.excludeFromSourcemap ? null : fileName),
|
|
10335
10381
|
indentExclusionRanges: []
|
|
10336
10382
|
});
|
|
@@ -10764,9 +10810,9 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, comp
|
|
|
10764
10810
|
}
|
|
10765
10811
|
}
|
|
10766
10812
|
}
|
|
10767
|
-
for (const
|
|
10768
|
-
const lhs = `exports
|
|
10769
|
-
const rhs =
|
|
10813
|
+
for (const { exported, local } of exports) {
|
|
10814
|
+
const lhs = `exports${RESERVED_NAMES[exported] ? `['${exported}']` : `.${exported}`}`;
|
|
10815
|
+
const rhs = local;
|
|
10770
10816
|
if (lhs !== rhs) {
|
|
10771
10817
|
if (exportBlock)
|
|
10772
10818
|
exportBlock += n;
|
|
@@ -10950,7 +10996,7 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
10950
10996
|
return;
|
|
10951
10997
|
warn({
|
|
10952
10998
|
code: 'MISSING_NODE_BUILTINS',
|
|
10953
|
-
message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/
|
|
10999
|
+
message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node`,
|
|
10954
11000
|
modules: externalBuiltins
|
|
10955
11001
|
});
|
|
10956
11002
|
}
|
|
@@ -11133,17 +11179,12 @@ function getExportBlock(exports, _, varOrConst) {
|
|
|
11133
11179
|
const exportBlock = [];
|
|
11134
11180
|
const exportDeclaration = [];
|
|
11135
11181
|
for (const specifier of exports) {
|
|
11136
|
-
if (specifier.
|
|
11137
|
-
exportBlock.push(
|
|
11138
|
-
}
|
|
11139
|
-
else {
|
|
11140
|
-
if (specifier.expression) {
|
|
11141
|
-
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
11142
|
-
}
|
|
11143
|
-
exportDeclaration.push(specifier.exported === specifier.local
|
|
11144
|
-
? specifier.local
|
|
11145
|
-
: `${specifier.local} as ${specifier.exported}`);
|
|
11182
|
+
if (specifier.expression) {
|
|
11183
|
+
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
11146
11184
|
}
|
|
11185
|
+
exportDeclaration.push(specifier.exported === specifier.local
|
|
11186
|
+
? specifier.local
|
|
11187
|
+
: `${specifier.local} as ${specifier.exported}`);
|
|
11147
11188
|
}
|
|
11148
11189
|
if (exportDeclaration.length) {
|
|
11149
11190
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
@@ -11261,13 +11302,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
11261
11302
|
|
|
11262
11303
|
function getStarExcludes({ dependencies, exports }) {
|
|
11263
11304
|
const starExcludes = new Set(exports.map(expt => expt.exported));
|
|
11264
|
-
|
|
11265
|
-
starExcludes.add('default');
|
|
11266
|
-
// also include reexport names
|
|
11305
|
+
starExcludes.add('default');
|
|
11267
11306
|
for (const { reexports } of dependencies) {
|
|
11268
11307
|
if (reexports) {
|
|
11269
11308
|
for (const reexport of reexports) {
|
|
11270
|
-
if (reexport.imported !== '*'
|
|
11309
|
+
if (reexport.imported !== '*')
|
|
11271
11310
|
starExcludes.add(reexport.reexported);
|
|
11272
11311
|
}
|
|
11273
11312
|
}
|
|
@@ -11291,9 +11330,7 @@ function getExportsBlock(exports, _, t, n) {
|
|
|
11291
11330
|
exports.map(({ name, value }) => `${t}${t}${t}${t}${name}:${_}${value}`).join(`,${n}`) +
|
|
11292
11331
|
`${n}${t}${t}${t}});${n}${n}`);
|
|
11293
11332
|
}
|
|
11294
|
-
const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports
|
|
11295
|
-
.filter(expt => expt.hoisted || expt.uninitialized)
|
|
11296
|
-
.map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), _, t, n);
|
|
11333
|
+
const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports.filter(expt => expt.hoisted).map(expt => ({ name: expt.exported, value: expt.local })), _, t, n);
|
|
11297
11334
|
const getMissingExportsBlock = (exports, _, t, n) => getExportsBlock(exports
|
|
11298
11335
|
.filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE)
|
|
11299
11336
|
.map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), _, t, n);
|
|
@@ -11334,10 +11371,8 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
11334
11371
|
if (!starExcludes) {
|
|
11335
11372
|
starExcludes = getStarExcludes({ dependencies, exports });
|
|
11336
11373
|
}
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
createdSetter = true;
|
|
11340
|
-
}
|
|
11374
|
+
createdSetter = true;
|
|
11375
|
+
setter.push(`${varOrConst} _setter${_}=${_}{};`);
|
|
11341
11376
|
setter.push(`for${_}(var _$p${_}in${_}module)${_}{`);
|
|
11342
11377
|
setter.push(`${t}if${_}(!_starExcludes[_$p])${_}_setter[_$p]${_}=${_}module[_$p];`);
|
|
11343
11378
|
setter.push('}');
|
|
@@ -12367,7 +12402,7 @@ class Chunk {
|
|
|
12367
12402
|
if (namespace.renderFirst())
|
|
12368
12403
|
hoistedSource += n + rendered;
|
|
12369
12404
|
else
|
|
12370
|
-
magicString.addSource(new MagicString(rendered));
|
|
12405
|
+
magicString.addSource(new MagicString$1(rendered));
|
|
12371
12406
|
}
|
|
12372
12407
|
}
|
|
12373
12408
|
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
@@ -12680,12 +12715,8 @@ class Chunk {
|
|
|
12680
12715
|
}
|
|
12681
12716
|
let expression = null;
|
|
12682
12717
|
let hoisted = false;
|
|
12683
|
-
let uninitialized = false;
|
|
12684
12718
|
let local = variable.getName();
|
|
12685
12719
|
if (variable instanceof LocalVariable) {
|
|
12686
|
-
if (variable.init === UNDEFINED_EXPRESSION) {
|
|
12687
|
-
uninitialized = true;
|
|
12688
|
-
}
|
|
12689
12720
|
for (const declaration of variable.declarations) {
|
|
12690
12721
|
if (declaration.parent instanceof FunctionDeclaration ||
|
|
12691
12722
|
(declaration instanceof ExportDefaultDeclaration &&
|
|
@@ -12697,7 +12728,7 @@ class Chunk {
|
|
|
12697
12728
|
}
|
|
12698
12729
|
else if (variable instanceof SyntheticNamedExportVariable) {
|
|
12699
12730
|
expression = local;
|
|
12700
|
-
if (format === 'es'
|
|
12731
|
+
if (format === 'es') {
|
|
12701
12732
|
local = variable.renderName;
|
|
12702
12733
|
}
|
|
12703
12734
|
}
|
|
@@ -12705,8 +12736,7 @@ class Chunk {
|
|
|
12705
12736
|
exported: exportName,
|
|
12706
12737
|
expression,
|
|
12707
12738
|
hoisted,
|
|
12708
|
-
local
|
|
12709
|
-
uninitialized
|
|
12739
|
+
local
|
|
12710
12740
|
});
|
|
12711
12741
|
}
|
|
12712
12742
|
return exports;
|
|
@@ -19499,7 +19529,7 @@ function transform(source, module, pluginDriver, warn) {
|
|
|
19499
19529
|
getCombinedSourcemap() {
|
|
19500
19530
|
const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
|
|
19501
19531
|
if (!combinedMap) {
|
|
19502
|
-
const magicString = new MagicString(originalCode);
|
|
19532
|
+
const magicString = new MagicString$1(originalCode);
|
|
19503
19533
|
return magicString.generateMap({ hires: true, includeContent: true, source: id });
|
|
19504
19534
|
}
|
|
19505
19535
|
if (originalSourcemap !== combinedMap) {
|
|
@@ -19650,12 +19680,10 @@ class ModuleLoader {
|
|
|
19650
19680
|
}));
|
|
19651
19681
|
}
|
|
19652
19682
|
async addModuleSource(id, importer, module) {
|
|
19653
|
-
var _a;
|
|
19654
19683
|
timeStart('load modules', 3);
|
|
19655
19684
|
let source;
|
|
19656
19685
|
try {
|
|
19657
|
-
source =
|
|
19658
|
-
(_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await this.readQueue.run(async () => readFile(id)));
|
|
19686
|
+
source = await this.readQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id)); });
|
|
19659
19687
|
}
|
|
19660
19688
|
catch (err) {
|
|
19661
19689
|
timeEnd('load modules', 3);
|