rollup 2.55.0 → 2.56.2
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 +41 -0
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +175 -173
- package/dist/es/shared/watch.js +2 -2
- 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 +2 -2
- package/dist/shared/loadConfigFile.js +7 -3
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +175 -173
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.56.2
|
|
4
|
+
Tue, 10 Aug 2021 05:26:43 GMT - commit 2f74020e2c2988e670a2744d4b6c0607ab997e2c
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -13,7 +13,7 @@ import { createHash as createHash$1 } from 'crypto';
|
|
|
13
13
|
import fs, { lstatSync, realpathSync, readdirSync } from 'fs';
|
|
14
14
|
import { EventEmitter } from 'events';
|
|
15
15
|
|
|
16
|
-
var version$1 = "2.
|
|
16
|
+
var version$1 = "2.56.2";
|
|
17
17
|
|
|
18
18
|
var charToInteger = {};
|
|
19
19
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -2705,35 +2705,54 @@ function removeLineBreaks(code, start, end) {
|
|
|
2705
2705
|
}
|
|
2706
2706
|
}
|
|
2707
2707
|
|
|
2708
|
-
function getSystemExportStatement(exportedVariables,
|
|
2709
|
-
const _ =
|
|
2708
|
+
function getSystemExportStatement(exportedVariables, { compact, exportNamesByVariable }, modifier = '') {
|
|
2709
|
+
const _ = compact ? '' : ' ';
|
|
2710
2710
|
if (exportedVariables.length === 1 &&
|
|
2711
|
-
|
|
2711
|
+
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
2712
2712
|
const variable = exportedVariables[0];
|
|
2713
|
-
return `exports('${
|
|
2713
|
+
return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName()}${modifier})`;
|
|
2714
2714
|
}
|
|
2715
2715
|
else {
|
|
2716
2716
|
return `exports({${_}${exportedVariables
|
|
2717
2717
|
.map(variable => {
|
|
2718
|
-
return
|
|
2718
|
+
return exportNamesByVariable
|
|
2719
2719
|
.get(variable)
|
|
2720
|
-
.map(exportName => `${exportName}:${_}${variable.getName()}`)
|
|
2720
|
+
.map(exportName => `${exportName}:${_}${variable.getName()}${modifier}`)
|
|
2721
2721
|
.join(`,${_}`);
|
|
2722
2722
|
})
|
|
2723
2723
|
.join(`,${_}`)}${_}})`;
|
|
2724
2724
|
}
|
|
2725
2725
|
}
|
|
2726
|
-
function
|
|
2726
|
+
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { compact, exportNamesByVariable }) {
|
|
2727
|
+
const _ = compact ? '' : ' ';
|
|
2728
|
+
code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
|
|
2729
|
+
code.appendLeft(expressionEnd, ')');
|
|
2730
|
+
}
|
|
2731
|
+
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
2727
2732
|
const _ = options.compact ? '' : ' ';
|
|
2728
2733
|
const s = options.compact ? '' : ';';
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2734
|
+
code.prependRight(expressionStart, `function${_}(v)${_}{${_}return ${getSystemExportStatement(exportedVariables, options)},${_}v${s}${_}}(`);
|
|
2735
|
+
code.appendLeft(expressionEnd, ')');
|
|
2736
|
+
if (needsParens) {
|
|
2737
|
+
code.prependRight(expressionStart, '(');
|
|
2738
|
+
code.appendLeft(expressionEnd, ')');
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
|
|
2742
|
+
const _ = options.compact ? '' : ' ';
|
|
2743
|
+
code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName()}`);
|
|
2744
|
+
if (needsParens) {
|
|
2745
|
+
code.prependRight(expressionStart, '(');
|
|
2746
|
+
code.appendLeft(expressionEnd, ')');
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
|
|
2750
|
+
const _ = options.compact ? '' : ' ';
|
|
2751
|
+
code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
|
|
2752
|
+
if (needsParens) {
|
|
2753
|
+
code.prependRight(expressionStart, '(');
|
|
2754
|
+
code.appendLeft(expressionEnd, ')');
|
|
2755
|
+
}
|
|
2737
2756
|
}
|
|
2738
2757
|
|
|
2739
2758
|
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
|
@@ -5429,8 +5448,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
5429
5448
|
else {
|
|
5430
5449
|
code.remove(this.start, declarationStart);
|
|
5431
5450
|
this.declaration.render(code, options, {
|
|
5432
|
-
|
|
5433
|
-
renderedParentType: ExpressionStatement$1
|
|
5451
|
+
renderedSurroundingElement: ExpressionStatement$1
|
|
5434
5452
|
});
|
|
5435
5453
|
if (code.original[this.end - 1] !== ';') {
|
|
5436
5454
|
code.appendLeft(this.end, ';');
|
|
@@ -5669,12 +5687,14 @@ class VariableDeclaration extends NodeBase {
|
|
|
5669
5687
|
let isInDeclaration = false;
|
|
5670
5688
|
let hasRenderedContent = false;
|
|
5671
5689
|
let separatorString = '', leadingString, nextSeparatorString;
|
|
5672
|
-
const
|
|
5690
|
+
const aggregatedSystemExports = [];
|
|
5691
|
+
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
5673
5692
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
5674
5693
|
if (!node.included) {
|
|
5675
5694
|
code.remove(start, end);
|
|
5676
5695
|
continue;
|
|
5677
5696
|
}
|
|
5697
|
+
node.render(code, options);
|
|
5678
5698
|
leadingString = '';
|
|
5679
5699
|
nextSeparatorString = '';
|
|
5680
5700
|
if (!node.id.included ||
|
|
@@ -5686,21 +5706,9 @@ class VariableDeclaration extends NodeBase {
|
|
|
5686
5706
|
isInDeclaration = false;
|
|
5687
5707
|
}
|
|
5688
5708
|
else {
|
|
5689
|
-
if (
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
}
|
|
5693
|
-
else {
|
|
5694
|
-
const exportNames = options.exportNamesByVariable.get(node.id.variable);
|
|
5695
|
-
if (exportNames) {
|
|
5696
|
-
const _ = options.compact ? '' : ' ';
|
|
5697
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
5698
|
-
code.prependLeft(findNonWhiteSpace(code.original, operatorPos + 1), exportNames.length === 1
|
|
5699
|
-
? `exports('${exportNames[0]}',${_}`
|
|
5700
|
-
: getSystemExportFunctionLeft([node.id.variable], false, options));
|
|
5701
|
-
nextSeparatorString += ')';
|
|
5702
|
-
}
|
|
5703
|
-
}
|
|
5709
|
+
if (singleSystemExport && singleSystemExport === node.id.variable) {
|
|
5710
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
5711
|
+
renderSystemExportExpression(singleSystemExport, findNonWhiteSpace(code.original, operatorPos + 1), separator === null ? contentEnd : separator, code, options);
|
|
5704
5712
|
}
|
|
5705
5713
|
if (isInDeclaration) {
|
|
5706
5714
|
separatorString += ',';
|
|
@@ -5720,16 +5728,40 @@ class VariableDeclaration extends NodeBase {
|
|
|
5720
5728
|
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
5721
5729
|
code.appendLeft(renderedContentEnd, leadingString);
|
|
5722
5730
|
}
|
|
5723
|
-
node.render(code, options);
|
|
5724
5731
|
actualContentEnd = contentEnd;
|
|
5725
5732
|
renderedContentEnd = end;
|
|
5726
5733
|
hasRenderedContent = true;
|
|
5727
5734
|
lastSeparatorPos = separator;
|
|
5728
5735
|
separatorString = nextSeparatorString;
|
|
5729
5736
|
}
|
|
5730
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd,
|
|
5737
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, isNoStatement);
|
|
5731
5738
|
}
|
|
5732
5739
|
}
|
|
5740
|
+
function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
|
|
5741
|
+
var _a;
|
|
5742
|
+
let singleSystemExport = null;
|
|
5743
|
+
if (options.format === 'system') {
|
|
5744
|
+
for (const { node } of separatedNodes) {
|
|
5745
|
+
if (node.id instanceof Identifier &&
|
|
5746
|
+
node.init &&
|
|
5747
|
+
aggregatedSystemExports.length === 0 &&
|
|
5748
|
+
((_a = options.exportNamesByVariable.get(node.id.variable)) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
5749
|
+
singleSystemExport = node.id.variable;
|
|
5750
|
+
aggregatedSystemExports.push(singleSystemExport);
|
|
5751
|
+
}
|
|
5752
|
+
else {
|
|
5753
|
+
node.id.addExportedVariables(aggregatedSystemExports, options.exportNamesByVariable);
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5756
|
+
if (aggregatedSystemExports.length > 1) {
|
|
5757
|
+
singleSystemExport = null;
|
|
5758
|
+
}
|
|
5759
|
+
else if (singleSystemExport) {
|
|
5760
|
+
aggregatedSystemExports.length = 0;
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
return singleSystemExport;
|
|
5764
|
+
}
|
|
5733
5765
|
|
|
5734
5766
|
const NEW_ARRAY_PROPERTIES = [
|
|
5735
5767
|
{ key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
|
|
@@ -6152,6 +6184,47 @@ class ArrowFunctionExpression extends NodeBase {
|
|
|
6152
6184
|
}
|
|
6153
6185
|
ArrowFunctionExpression.prototype.preventChildBlockScope = true;
|
|
6154
6186
|
|
|
6187
|
+
class ObjectPattern extends NodeBase {
|
|
6188
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
6189
|
+
for (const property of this.properties) {
|
|
6190
|
+
if (property.type === Property$1) {
|
|
6191
|
+
property.value.addExportedVariables(variables, exportNamesByVariable);
|
|
6192
|
+
}
|
|
6193
|
+
else {
|
|
6194
|
+
property.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
declare(kind, init) {
|
|
6199
|
+
const variables = [];
|
|
6200
|
+
for (const property of this.properties) {
|
|
6201
|
+
variables.push(...property.declare(kind, init));
|
|
6202
|
+
}
|
|
6203
|
+
return variables;
|
|
6204
|
+
}
|
|
6205
|
+
deoptimizePath(path) {
|
|
6206
|
+
if (path.length === 0) {
|
|
6207
|
+
for (const property of this.properties) {
|
|
6208
|
+
property.deoptimizePath(path);
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6213
|
+
if (path.length > 0)
|
|
6214
|
+
return true;
|
|
6215
|
+
for (const property of this.properties) {
|
|
6216
|
+
if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
|
|
6217
|
+
return true;
|
|
6218
|
+
}
|
|
6219
|
+
return false;
|
|
6220
|
+
}
|
|
6221
|
+
markDeclarationReached() {
|
|
6222
|
+
for (const property of this.properties) {
|
|
6223
|
+
property.markDeclarationReached();
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6155
6228
|
class AssignmentExpression extends NodeBase {
|
|
6156
6229
|
constructor() {
|
|
6157
6230
|
super(...arguments);
|
|
@@ -6182,7 +6255,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
6182
6255
|
}
|
|
6183
6256
|
this.right.include(context, includeChildrenRecursively);
|
|
6184
6257
|
}
|
|
6185
|
-
render(code, options, { preventASI, renderedParentType } = BLANK) {
|
|
6258
|
+
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
6186
6259
|
if (this.left.included) {
|
|
6187
6260
|
this.left.render(code, options);
|
|
6188
6261
|
this.right.render(code, options);
|
|
@@ -6194,29 +6267,40 @@ class AssignmentExpression extends NodeBase {
|
|
|
6194
6267
|
removeLineBreaks(code, inclusionStart, this.right.start);
|
|
6195
6268
|
}
|
|
6196
6269
|
this.right.render(code, options, {
|
|
6197
|
-
renderedParentType: renderedParentType || this.parent.type
|
|
6270
|
+
renderedParentType: renderedParentType || this.parent.type,
|
|
6271
|
+
renderedSurroundingElement: renderedSurroundingElement || this.parent.type
|
|
6198
6272
|
});
|
|
6199
6273
|
}
|
|
6200
6274
|
if (options.format === 'system') {
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
const
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6275
|
+
if (this.left instanceof Identifier) {
|
|
6276
|
+
const variable = this.left.variable;
|
|
6277
|
+
const exportNames = options.exportNamesByVariable.get(variable);
|
|
6278
|
+
if (exportNames) {
|
|
6279
|
+
if (exportNames.length === 1) {
|
|
6280
|
+
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
6281
|
+
}
|
|
6282
|
+
else {
|
|
6283
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
6284
|
+
}
|
|
6285
|
+
return;
|
|
6286
|
+
}
|
|
6210
6287
|
}
|
|
6211
6288
|
else {
|
|
6212
6289
|
const systemPatternExports = [];
|
|
6213
6290
|
this.left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
6214
6291
|
if (systemPatternExports.length > 0) {
|
|
6215
|
-
|
|
6216
|
-
|
|
6292
|
+
renderSystemExportFunction(systemPatternExports, this.start, this.end, renderedSurroundingElement === ExpressionStatement$1, code, options);
|
|
6293
|
+
return;
|
|
6217
6294
|
}
|
|
6218
6295
|
}
|
|
6219
6296
|
}
|
|
6297
|
+
if (this.left.included &&
|
|
6298
|
+
this.left instanceof ObjectPattern &&
|
|
6299
|
+
(renderedSurroundingElement === ExpressionStatement$1 ||
|
|
6300
|
+
renderedSurroundingElement === ArrowFunctionExpression$1)) {
|
|
6301
|
+
code.appendRight(this.start, '(');
|
|
6302
|
+
code.prependLeft(this.end, ')');
|
|
6303
|
+
}
|
|
6220
6304
|
}
|
|
6221
6305
|
applyDeoptimizations() {
|
|
6222
6306
|
this.deoptimized = true;
|
|
@@ -6343,10 +6427,8 @@ class BinaryExpression extends NodeBase {
|
|
|
6343
6427
|
hasEffectsWhenAccessedAtPath(path) {
|
|
6344
6428
|
return path.length > 1;
|
|
6345
6429
|
}
|
|
6346
|
-
render(code, options, {
|
|
6347
|
-
this.left.render(code, options, {
|
|
6348
|
-
renderedSurroundingElement: renderedParentType || renderedSurroundingElement
|
|
6349
|
-
});
|
|
6430
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
6431
|
+
this.left.render(code, options, { renderedSurroundingElement });
|
|
6350
6432
|
this.right.render(code, options);
|
|
6351
6433
|
}
|
|
6352
6434
|
}
|
|
@@ -6591,8 +6673,7 @@ class MemberExpression extends NodeBase {
|
|
|
6591
6673
|
if (renderedParentType && isCalleeOfRenderedParent) {
|
|
6592
6674
|
code.appendRight(this.start, '0, ');
|
|
6593
6675
|
}
|
|
6594
|
-
|
|
6595
|
-
this.object.render(code, options, surroundingElement ? { renderedSurroundingElement: surroundingElement } : BLANK);
|
|
6676
|
+
this.object.render(code, options, { renderedSurroundingElement });
|
|
6596
6677
|
this.property.render(code, options);
|
|
6597
6678
|
}
|
|
6598
6679
|
}
|
|
@@ -6797,11 +6878,10 @@ class CallExpression extends NodeBase {
|
|
|
6797
6878
|
returnExpression.include(context, false);
|
|
6798
6879
|
}
|
|
6799
6880
|
}
|
|
6800
|
-
render(code, options, {
|
|
6801
|
-
const surroundingELement = renderedParentType || renderedSurroundingElement;
|
|
6881
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
6802
6882
|
this.callee.render(code, options, {
|
|
6803
6883
|
isCalleeOfRenderedParent: true,
|
|
6804
|
-
renderedSurroundingElement
|
|
6884
|
+
renderedSurroundingElement
|
|
6805
6885
|
});
|
|
6806
6886
|
if (this.arguments.length > 0) {
|
|
6807
6887
|
if (this.arguments[this.arguments.length - 1].included) {
|
|
@@ -6916,10 +6996,9 @@ class ClassBody extends NodeBase {
|
|
|
6916
6996
|
}
|
|
6917
6997
|
|
|
6918
6998
|
class ClassExpression extends ClassNode {
|
|
6919
|
-
render(code, options, {
|
|
6999
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
6920
7000
|
super.render(code, options);
|
|
6921
|
-
|
|
6922
|
-
if (surroundingElement === ExpressionStatement$1) {
|
|
7001
|
+
if (renderedSurroundingElement === ExpressionStatement$1) {
|
|
6923
7002
|
code.appendRight(this.start, '(');
|
|
6924
7003
|
code.prependLeft(this.end, ')');
|
|
6925
7004
|
}
|
|
@@ -7093,15 +7172,12 @@ class ConditionalExpression extends NodeBase {
|
|
|
7093
7172
|
usedBranch.render(code, options, {
|
|
7094
7173
|
isCalleeOfRenderedParent,
|
|
7095
7174
|
preventASI: true,
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
: { renderedParentType: renderedParentType || this.parent.type })
|
|
7175
|
+
renderedParentType: renderedParentType || this.parent.type,
|
|
7176
|
+
renderedSurroundingElement: renderedSurroundingElement || this.parent.type
|
|
7099
7177
|
});
|
|
7100
7178
|
}
|
|
7101
7179
|
else {
|
|
7102
|
-
this.test.render(code, options, {
|
|
7103
|
-
renderedSurroundingElement: renderedParentType || renderedSurroundingElement
|
|
7104
|
-
});
|
|
7180
|
+
this.test.render(code, options, { renderedSurroundingElement });
|
|
7105
7181
|
this.consequent.render(code, options);
|
|
7106
7182
|
this.alternate.render(code, options);
|
|
7107
7183
|
}
|
|
@@ -7335,10 +7411,9 @@ class ForStatement extends NodeBase {
|
|
|
7335
7411
|
}
|
|
7336
7412
|
|
|
7337
7413
|
class FunctionExpression extends FunctionNode {
|
|
7338
|
-
render(code, options, {
|
|
7414
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
7339
7415
|
super.render(code, options);
|
|
7340
|
-
|
|
7341
|
-
if (surroundingElement === ExpressionStatement$1) {
|
|
7416
|
+
if (renderedSurroundingElement === ExpressionStatement$1) {
|
|
7342
7417
|
code.appendRight(this.start, '(');
|
|
7343
7418
|
code.prependLeft(this.end, ')');
|
|
7344
7419
|
}
|
|
@@ -7666,12 +7741,12 @@ class ImportExpression extends NodeBase {
|
|
|
7666
7741
|
if (this.inlineNamespace) {
|
|
7667
7742
|
const _ = options.compact ? '' : ' ';
|
|
7668
7743
|
const s = options.compact ? '' : ';';
|
|
7669
|
-
code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})
|
|
7744
|
+
code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})`, { contentOnly: true });
|
|
7670
7745
|
return;
|
|
7671
7746
|
}
|
|
7672
7747
|
if (this.mechanism) {
|
|
7673
|
-
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
|
|
7674
|
-
code.overwrite(this.end - 1, this.end, this.mechanism.right);
|
|
7748
|
+
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
|
|
7749
|
+
code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
|
|
7675
7750
|
}
|
|
7676
7751
|
this.source.render(code, options);
|
|
7677
7752
|
}
|
|
@@ -7932,15 +8007,14 @@ class LogicalExpression extends NodeBase {
|
|
|
7932
8007
|
this.getUsedBranch().render(code, options, {
|
|
7933
8008
|
isCalleeOfRenderedParent,
|
|
7934
8009
|
preventASI,
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
: { renderedParentType: renderedParentType || this.parent.type })
|
|
8010
|
+
renderedParentType: renderedParentType || this.parent.type,
|
|
8011
|
+
renderedSurroundingElement: renderedSurroundingElement || this.parent.type
|
|
7938
8012
|
});
|
|
7939
8013
|
}
|
|
7940
8014
|
else {
|
|
7941
8015
|
this.left.render(code, options, {
|
|
7942
8016
|
preventASI,
|
|
7943
|
-
renderedSurroundingElement
|
|
8017
|
+
renderedSurroundingElement
|
|
7944
8018
|
});
|
|
7945
8019
|
this.right.render(code, options);
|
|
7946
8020
|
}
|
|
@@ -8575,11 +8649,10 @@ class ObjectExpression extends NodeBase {
|
|
|
8575
8649
|
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
8576
8650
|
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
8577
8651
|
}
|
|
8578
|
-
render(code, options, {
|
|
8652
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
8579
8653
|
super.render(code, options);
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
surroundingElement === ArrowFunctionExpression$1) {
|
|
8654
|
+
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
8655
|
+
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
8583
8656
|
code.appendRight(this.start, '(');
|
|
8584
8657
|
code.prependLeft(this.end, ')');
|
|
8585
8658
|
}
|
|
@@ -8625,47 +8698,6 @@ class ObjectExpression extends NodeBase {
|
|
|
8625
8698
|
}
|
|
8626
8699
|
}
|
|
8627
8700
|
|
|
8628
|
-
class ObjectPattern extends NodeBase {
|
|
8629
|
-
addExportedVariables(variables, exportNamesByVariable) {
|
|
8630
|
-
for (const property of this.properties) {
|
|
8631
|
-
if (property.type === Property$1) {
|
|
8632
|
-
property.value.addExportedVariables(variables, exportNamesByVariable);
|
|
8633
|
-
}
|
|
8634
|
-
else {
|
|
8635
|
-
property.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
8636
|
-
}
|
|
8637
|
-
}
|
|
8638
|
-
}
|
|
8639
|
-
declare(kind, init) {
|
|
8640
|
-
const variables = [];
|
|
8641
|
-
for (const property of this.properties) {
|
|
8642
|
-
variables.push(...property.declare(kind, init));
|
|
8643
|
-
}
|
|
8644
|
-
return variables;
|
|
8645
|
-
}
|
|
8646
|
-
deoptimizePath(path) {
|
|
8647
|
-
if (path.length === 0) {
|
|
8648
|
-
for (const property of this.properties) {
|
|
8649
|
-
property.deoptimizePath(path);
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
}
|
|
8653
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8654
|
-
if (path.length > 0)
|
|
8655
|
-
return true;
|
|
8656
|
-
for (const property of this.properties) {
|
|
8657
|
-
if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
|
|
8658
|
-
return true;
|
|
8659
|
-
}
|
|
8660
|
-
return false;
|
|
8661
|
-
}
|
|
8662
|
-
markDeclarationReached() {
|
|
8663
|
-
for (const property of this.properties) {
|
|
8664
|
-
property.markDeclarationReached();
|
|
8665
|
-
}
|
|
8666
|
-
}
|
|
8667
|
-
}
|
|
8668
|
-
|
|
8669
8701
|
class PrivateIdentifier extends NodeBase {
|
|
8670
8702
|
}
|
|
8671
8703
|
|
|
@@ -8820,17 +8852,12 @@ class SequenceExpression extends NodeBase {
|
|
|
8820
8852
|
removeLineBreaks(code, start, node.start);
|
|
8821
8853
|
}
|
|
8822
8854
|
if (includedNodes === 1) {
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
}
|
|
8829
|
-
else {
|
|
8830
|
-
node.render(code, options, {
|
|
8831
|
-
renderedSurroundingElement: renderedParentType || this.parent.type
|
|
8832
|
-
});
|
|
8833
|
-
}
|
|
8855
|
+
const parentType = renderedParentType || this.parent.type;
|
|
8856
|
+
node.render(code, options, {
|
|
8857
|
+
isCalleeOfRenderedParent: isCalleeOfRenderedParent && node === lastNode,
|
|
8858
|
+
renderedParentType: parentType,
|
|
8859
|
+
renderedSurroundingElement: parentType
|
|
8860
|
+
});
|
|
8834
8861
|
}
|
|
8835
8862
|
else {
|
|
8836
8863
|
node.render(code, options);
|
|
@@ -9299,31 +9326,19 @@ class UpdateExpression extends NodeBase {
|
|
|
9299
9326
|
if (options.format === 'system') {
|
|
9300
9327
|
const variable = this.argument.variable;
|
|
9301
9328
|
const exportNames = options.exportNamesByVariable.get(variable);
|
|
9302
|
-
if (exportNames
|
|
9329
|
+
if (exportNames) {
|
|
9303
9330
|
const _ = options.compact ? '' : ' ';
|
|
9304
|
-
const name = variable.getName();
|
|
9305
9331
|
if (this.prefix) {
|
|
9306
9332
|
if (exportNames.length === 1) {
|
|
9307
|
-
|
|
9333
|
+
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
9308
9334
|
}
|
|
9309
9335
|
else {
|
|
9310
|
-
|
|
9336
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
9311
9337
|
}
|
|
9312
9338
|
}
|
|
9313
|
-
else if (exportNames.length > 1) {
|
|
9314
|
-
code.overwrite(this.start, this.end, `(${getSystemExportFunctionLeft([variable], false, options)}${this.operator}${name}))`);
|
|
9315
|
-
}
|
|
9316
9339
|
else {
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
case '++':
|
|
9320
|
-
op = `${name}${_}+${_}1`;
|
|
9321
|
-
break;
|
|
9322
|
-
case '--':
|
|
9323
|
-
op = `${name}${_}-${_}1`;
|
|
9324
|
-
break;
|
|
9325
|
-
}
|
|
9326
|
-
code.overwrite(this.start, this.end, `(exports('${exportNames[0]}',${_}${op}),${_}${name}${this.operator})`);
|
|
9340
|
+
const operator = this.operator[0];
|
|
9341
|
+
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options, `${_}${operator}${_}1`);
|
|
9327
9342
|
}
|
|
9328
9343
|
}
|
|
9329
9344
|
}
|
|
@@ -9371,7 +9386,7 @@ class VariableDeclarator extends NodeBase {
|
|
|
9371
9386
|
code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
9372
9387
|
}
|
|
9373
9388
|
if (this.init) {
|
|
9374
|
-
this.init.render(code, options, renderId ? BLANK : {
|
|
9389
|
+
this.init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
9375
9390
|
}
|
|
9376
9391
|
else if (this.id instanceof Identifier &&
|
|
9377
9392
|
isReassignedExportsMember(this.id.variable, options.exportNamesByVariable)) {
|
|
@@ -11198,13 +11213,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
11198
11213
|
|
|
11199
11214
|
function getStarExcludes({ dependencies, exports }) {
|
|
11200
11215
|
const starExcludes = new Set(exports.map(expt => expt.exported));
|
|
11201
|
-
|
|
11202
|
-
starExcludes.add('default');
|
|
11203
|
-
// also include reexport names
|
|
11216
|
+
starExcludes.add('default');
|
|
11204
11217
|
for (const { reexports } of dependencies) {
|
|
11205
11218
|
if (reexports) {
|
|
11206
11219
|
for (const reexport of reexports) {
|
|
11207
|
-
if (reexport.imported !== '*'
|
|
11220
|
+
if (reexport.imported !== '*')
|
|
11208
11221
|
starExcludes.add(reexport.reexported);
|
|
11209
11222
|
}
|
|
11210
11223
|
}
|
|
@@ -11228,9 +11241,7 @@ function getExportsBlock(exports, _, t, n) {
|
|
|
11228
11241
|
exports.map(({ name, value }) => `${t}${t}${t}${t}${name}:${_}${value}`).join(`,${n}`) +
|
|
11229
11242
|
`${n}${t}${t}${t}});${n}${n}`);
|
|
11230
11243
|
}
|
|
11231
|
-
const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports
|
|
11232
|
-
.filter(expt => expt.hoisted || expt.uninitialized)
|
|
11233
|
-
.map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), _, t, n);
|
|
11244
|
+
const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports.filter(expt => expt.hoisted).map(expt => ({ name: expt.exported, value: expt.local })), _, t, n);
|
|
11234
11245
|
const getMissingExportsBlock = (exports, _, t, n) => getExportsBlock(exports
|
|
11235
11246
|
.filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE)
|
|
11236
11247
|
.map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), _, t, n);
|
|
@@ -11271,10 +11282,8 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
11271
11282
|
if (!starExcludes) {
|
|
11272
11283
|
starExcludes = getStarExcludes({ dependencies, exports });
|
|
11273
11284
|
}
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
createdSetter = true;
|
|
11277
|
-
}
|
|
11285
|
+
createdSetter = true;
|
|
11286
|
+
setter.push(`${varOrConst} _setter${_}=${_}{};`);
|
|
11278
11287
|
setter.push(`for${_}(var _$p${_}in${_}module)${_}{`);
|
|
11279
11288
|
setter.push(`${t}if${_}(!_starExcludes[_$p])${_}_setter[_$p]${_}=${_}module[_$p];`);
|
|
11280
11289
|
setter.push('}');
|
|
@@ -12617,12 +12626,8 @@ class Chunk {
|
|
|
12617
12626
|
}
|
|
12618
12627
|
let expression = null;
|
|
12619
12628
|
let hoisted = false;
|
|
12620
|
-
let uninitialized = false;
|
|
12621
12629
|
let local = variable.getName();
|
|
12622
12630
|
if (variable instanceof LocalVariable) {
|
|
12623
|
-
if (variable.init === UNDEFINED_EXPRESSION) {
|
|
12624
|
-
uninitialized = true;
|
|
12625
|
-
}
|
|
12626
12631
|
for (const declaration of variable.declarations) {
|
|
12627
12632
|
if (declaration.parent instanceof FunctionDeclaration ||
|
|
12628
12633
|
(declaration instanceof ExportDefaultDeclaration &&
|
|
@@ -12642,8 +12647,7 @@ class Chunk {
|
|
|
12642
12647
|
exported: exportName,
|
|
12643
12648
|
expression,
|
|
12644
12649
|
hoisted,
|
|
12645
|
-
local
|
|
12646
|
-
uninitialized
|
|
12650
|
+
local
|
|
12647
12651
|
});
|
|
12648
12652
|
}
|
|
12649
12653
|
return exports;
|
|
@@ -19587,12 +19591,10 @@ class ModuleLoader {
|
|
|
19587
19591
|
}));
|
|
19588
19592
|
}
|
|
19589
19593
|
async addModuleSource(id, importer, module) {
|
|
19590
|
-
var _a;
|
|
19591
19594
|
timeStart('load modules', 3);
|
|
19592
19595
|
let source;
|
|
19593
19596
|
try {
|
|
19594
|
-
source =
|
|
19595
|
-
(_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await this.readQueue.run(async () => readFile(id)));
|
|
19597
|
+
source = await this.readQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id)); });
|
|
19596
19598
|
}
|
|
19597
19599
|
catch (err) {
|
|
19598
19600
|
timeEnd('load modules', 3);
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED