rollup 2.55.1 → 2.56.3

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.55.1
4
- Thu, 29 Jul 2021 15:46:34 GMT - commit 97759be7eacc11c4f7e4fdb9fada077279b363f3
3
+ Rollup.js v2.56.3
4
+ Mon, 23 Aug 2021 05:06:39 GMT - commit c41d17ceedfa6c1d7430da70c6c80d86a91e9434
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.55.1";
22
+ var version$1 = "2.56.3";
23
23
 
24
24
  function ensureArray(items) {
25
25
  if (Array.isArray(items)) {
@@ -3166,35 +3166,54 @@ function removeLineBreaks(code, start, end) {
3166
3166
  }
3167
3167
  }
3168
3168
 
3169
- function getSystemExportStatement(exportedVariables, options) {
3170
- const _ = options.compact ? '' : ' ';
3169
+ function getSystemExportStatement(exportedVariables, { compact, exportNamesByVariable }, modifier = '') {
3170
+ const _ = compact ? '' : ' ';
3171
3171
  if (exportedVariables.length === 1 &&
3172
- options.exportNamesByVariable.get(exportedVariables[0]).length === 1) {
3172
+ exportNamesByVariable.get(exportedVariables[0]).length === 1) {
3173
3173
  const variable = exportedVariables[0];
3174
- return `exports('${options.exportNamesByVariable.get(variable)}',${_}${variable.getName()})`;
3174
+ return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName()}${modifier})`;
3175
3175
  }
3176
3176
  else {
3177
3177
  return `exports({${_}${exportedVariables
3178
3178
  .map(variable => {
3179
- return options.exportNamesByVariable
3179
+ return exportNamesByVariable
3180
3180
  .get(variable)
3181
- .map(exportName => `${exportName}:${_}${variable.getName()}`)
3181
+ .map(exportName => `${exportName}:${_}${variable.getName()}${modifier}`)
3182
3182
  .join(`,${_}`);
3183
3183
  })
3184
3184
  .join(`,${_}`)}${_}})`;
3185
3185
  }
3186
3186
  }
3187
- function getSystemExportFunctionLeft(exportedVariables, setFromExpression, options) {
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) {
3188
3193
  const _ = options.compact ? '' : ' ';
3189
3194
  const s = options.compact ? '' : ';';
3190
- return `function${_}(v)${_}{${_}return exports({${_}${exportedVariables
3191
- .map(variable => {
3192
- return options.exportNamesByVariable
3193
- .get(variable)
3194
- .map(exportName => `${exportName}:${_}${setFromExpression ? variable.getName() : 'v'}`)
3195
- .join(`,${_}`);
3196
- })
3197
- .join(`,${_}`)}${_}}),${_}v${s}${_}}(`;
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
+ }
3198
3217
  }
3199
3218
 
3200
3219
  const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
@@ -5890,8 +5909,7 @@ class ExportDefaultDeclaration extends NodeBase {
5890
5909
  else {
5891
5910
  code.remove(this.start, declarationStart);
5892
5911
  this.declaration.render(code, options, {
5893
- isCalleeOfRenderedParent: false,
5894
- renderedParentType: ExpressionStatement$1
5912
+ renderedSurroundingElement: ExpressionStatement$1
5895
5913
  });
5896
5914
  if (code.original[this.end - 1] !== ';') {
5897
5915
  code.appendLeft(this.end, ';');
@@ -6130,12 +6148,14 @@ class VariableDeclaration extends NodeBase {
6130
6148
  let isInDeclaration = false;
6131
6149
  let hasRenderedContent = false;
6132
6150
  let separatorString = '', leadingString, nextSeparatorString;
6133
- const systemPatternExports = [];
6151
+ const aggregatedSystemExports = [];
6152
+ const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
6134
6153
  for (const { node, start, separator, contentEnd, end } of separatedNodes) {
6135
6154
  if (!node.included) {
6136
6155
  code.remove(start, end);
6137
6156
  continue;
6138
6157
  }
6158
+ node.render(code, options);
6139
6159
  leadingString = '';
6140
6160
  nextSeparatorString = '';
6141
6161
  if (!node.id.included ||
@@ -6147,21 +6167,9 @@ class VariableDeclaration extends NodeBase {
6147
6167
  isInDeclaration = false;
6148
6168
  }
6149
6169
  else {
6150
- if (options.format === 'system' && node.init !== null) {
6151
- if (node.id.type !== Identifier$1) {
6152
- node.id.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
6153
- }
6154
- else {
6155
- const exportNames = options.exportNamesByVariable.get(node.id.variable);
6156
- if (exportNames) {
6157
- const _ = options.compact ? '' : ' ';
6158
- const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
6159
- code.prependLeft(findNonWhiteSpace(code.original, operatorPos + 1), exportNames.length === 1
6160
- ? `exports('${exportNames[0]}',${_}`
6161
- : getSystemExportFunctionLeft([node.id.variable], false, options));
6162
- nextSeparatorString += ')';
6163
- }
6164
- }
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);
6165
6173
  }
6166
6174
  if (isInDeclaration) {
6167
6175
  separatorString += ',';
@@ -6181,16 +6189,40 @@ class VariableDeclaration extends NodeBase {
6181
6189
  code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
6182
6190
  code.appendLeft(renderedContentEnd, leadingString);
6183
6191
  }
6184
- node.render(code, options);
6185
6192
  actualContentEnd = contentEnd;
6186
6193
  renderedContentEnd = end;
6187
6194
  hasRenderedContent = true;
6188
6195
  lastSeparatorPos = separator;
6189
6196
  separatorString = nextSeparatorString;
6190
6197
  }
6191
- this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement);
6198
+ this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, isNoStatement);
6192
6199
  }
6193
6200
  }
6201
+ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
6202
+ var _a;
6203
+ let singleSystemExport = null;
6204
+ if (options.format === 'system') {
6205
+ for (const { node } of separatedNodes) {
6206
+ if (node.id instanceof Identifier &&
6207
+ node.init &&
6208
+ aggregatedSystemExports.length === 0 &&
6209
+ ((_a = options.exportNamesByVariable.get(node.id.variable)) === null || _a === void 0 ? void 0 : _a.length) === 1) {
6210
+ singleSystemExport = node.id.variable;
6211
+ aggregatedSystemExports.push(singleSystemExport);
6212
+ }
6213
+ else {
6214
+ node.id.addExportedVariables(aggregatedSystemExports, options.exportNamesByVariable);
6215
+ }
6216
+ }
6217
+ if (aggregatedSystemExports.length > 1) {
6218
+ singleSystemExport = null;
6219
+ }
6220
+ else if (singleSystemExport) {
6221
+ aggregatedSystemExports.length = 0;
6222
+ }
6223
+ }
6224
+ return singleSystemExport;
6225
+ }
6194
6226
 
6195
6227
  const NEW_ARRAY_PROPERTIES = [
6196
6228
  { key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
@@ -6613,6 +6645,47 @@ class ArrowFunctionExpression extends NodeBase {
6613
6645
  }
6614
6646
  ArrowFunctionExpression.prototype.preventChildBlockScope = true;
6615
6647
 
6648
+ class ObjectPattern extends NodeBase {
6649
+ addExportedVariables(variables, exportNamesByVariable) {
6650
+ for (const property of this.properties) {
6651
+ if (property.type === Property$1) {
6652
+ property.value.addExportedVariables(variables, exportNamesByVariable);
6653
+ }
6654
+ else {
6655
+ property.argument.addExportedVariables(variables, exportNamesByVariable);
6656
+ }
6657
+ }
6658
+ }
6659
+ declare(kind, init) {
6660
+ const variables = [];
6661
+ for (const property of this.properties) {
6662
+ variables.push(...property.declare(kind, init));
6663
+ }
6664
+ return variables;
6665
+ }
6666
+ deoptimizePath(path) {
6667
+ if (path.length === 0) {
6668
+ for (const property of this.properties) {
6669
+ property.deoptimizePath(path);
6670
+ }
6671
+ }
6672
+ }
6673
+ hasEffectsWhenAssignedAtPath(path, context) {
6674
+ if (path.length > 0)
6675
+ return true;
6676
+ for (const property of this.properties) {
6677
+ if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
6678
+ return true;
6679
+ }
6680
+ return false;
6681
+ }
6682
+ markDeclarationReached() {
6683
+ for (const property of this.properties) {
6684
+ property.markDeclarationReached();
6685
+ }
6686
+ }
6687
+ }
6688
+
6616
6689
  class AssignmentExpression extends NodeBase {
6617
6690
  constructor() {
6618
6691
  super(...arguments);
@@ -6643,7 +6716,7 @@ class AssignmentExpression extends NodeBase {
6643
6716
  }
6644
6717
  this.right.include(context, includeChildrenRecursively);
6645
6718
  }
6646
- render(code, options, { preventASI, renderedParentType } = BLANK) {
6719
+ render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
6647
6720
  if (this.left.included) {
6648
6721
  this.left.render(code, options);
6649
6722
  this.right.render(code, options);
@@ -6655,29 +6728,40 @@ class AssignmentExpression extends NodeBase {
6655
6728
  removeLineBreaks(code, inclusionStart, this.right.start);
6656
6729
  }
6657
6730
  this.right.render(code, options, {
6658
- renderedParentType: renderedParentType || this.parent.type
6731
+ renderedParentType: renderedParentType || this.parent.type,
6732
+ renderedSurroundingElement: renderedSurroundingElement || this.parent.type
6659
6733
  });
6660
6734
  }
6661
6735
  if (options.format === 'system') {
6662
- const exportNames = this.left.variable && options.exportNamesByVariable.get(this.left.variable);
6663
- if (this.left.type === 'Identifier' && exportNames) {
6664
- const _ = options.compact ? '' : ' ';
6665
- const operatorPos = findFirstOccurrenceOutsideComment(code.original, this.operator, this.left.end);
6666
- const operation = this.operator.length > 1 ? `${exportNames[0]}${_}${this.operator.slice(0, -1)}${_}` : '';
6667
- code.overwrite(operatorPos, findNonWhiteSpace(code.original, operatorPos + this.operator.length), `=${_}${exportNames.length === 1
6668
- ? `exports('${exportNames[0]}',${_}`
6669
- : getSystemExportFunctionLeft([this.left.variable], false, options)}${operation}`);
6670
- code.appendLeft(this.right.end, ')');
6736
+ if (this.left instanceof Identifier) {
6737
+ const variable = this.left.variable;
6738
+ const exportNames = options.exportNamesByVariable.get(variable);
6739
+ if (exportNames) {
6740
+ if (exportNames.length === 1) {
6741
+ renderSystemExportExpression(variable, this.start, this.end, code, options);
6742
+ }
6743
+ else {
6744
+ renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
6745
+ }
6746
+ return;
6747
+ }
6671
6748
  }
6672
6749
  else {
6673
6750
  const systemPatternExports = [];
6674
6751
  this.left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
6675
6752
  if (systemPatternExports.length > 0) {
6676
- code.prependRight(this.start, `(${getSystemExportFunctionLeft(systemPatternExports, true, options)}`);
6677
- code.appendLeft(this.end, '))');
6753
+ renderSystemExportFunction(systemPatternExports, this.start, this.end, renderedSurroundingElement === ExpressionStatement$1, code, options);
6754
+ return;
6678
6755
  }
6679
6756
  }
6680
6757
  }
6758
+ if (this.left.included &&
6759
+ this.left instanceof ObjectPattern &&
6760
+ (renderedSurroundingElement === ExpressionStatement$1 ||
6761
+ renderedSurroundingElement === ArrowFunctionExpression$1)) {
6762
+ code.appendRight(this.start, '(');
6763
+ code.prependLeft(this.end, ')');
6764
+ }
6681
6765
  }
6682
6766
  applyDeoptimizations() {
6683
6767
  this.deoptimized = true;
@@ -6804,10 +6888,8 @@ class BinaryExpression extends NodeBase {
6804
6888
  hasEffectsWhenAccessedAtPath(path) {
6805
6889
  return path.length > 1;
6806
6890
  }
6807
- render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
6808
- this.left.render(code, options, {
6809
- renderedSurroundingElement: renderedParentType || renderedSurroundingElement
6810
- });
6891
+ render(code, options, { renderedSurroundingElement } = BLANK) {
6892
+ this.left.render(code, options, { renderedSurroundingElement });
6811
6893
  this.right.render(code, options);
6812
6894
  }
6813
6895
  }
@@ -7052,8 +7134,7 @@ class MemberExpression extends NodeBase {
7052
7134
  if (renderedParentType && isCalleeOfRenderedParent) {
7053
7135
  code.appendRight(this.start, '0, ');
7054
7136
  }
7055
- const surroundingElement = renderedParentType || renderedSurroundingElement;
7056
- this.object.render(code, options, surroundingElement ? { renderedSurroundingElement: surroundingElement } : BLANK);
7137
+ this.object.render(code, options, { renderedSurroundingElement });
7057
7138
  this.property.render(code, options);
7058
7139
  }
7059
7140
  }
@@ -7258,11 +7339,10 @@ class CallExpression extends NodeBase {
7258
7339
  returnExpression.include(context, false);
7259
7340
  }
7260
7341
  }
7261
- render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
7262
- const surroundingELement = renderedParentType || renderedSurroundingElement;
7342
+ render(code, options, { renderedSurroundingElement } = BLANK) {
7263
7343
  this.callee.render(code, options, {
7264
7344
  isCalleeOfRenderedParent: true,
7265
- renderedSurroundingElement: surroundingELement
7345
+ renderedSurroundingElement
7266
7346
  });
7267
7347
  if (this.arguments.length > 0) {
7268
7348
  if (this.arguments[this.arguments.length - 1].included) {
@@ -7377,10 +7457,9 @@ class ClassBody extends NodeBase {
7377
7457
  }
7378
7458
 
7379
7459
  class ClassExpression extends ClassNode {
7380
- render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
7460
+ render(code, options, { renderedSurroundingElement } = BLANK) {
7381
7461
  super.render(code, options);
7382
- const surroundingElement = renderedParentType || renderedSurroundingElement;
7383
- if (surroundingElement === ExpressionStatement$1) {
7462
+ if (renderedSurroundingElement === ExpressionStatement$1) {
7384
7463
  code.appendRight(this.start, '(');
7385
7464
  code.prependLeft(this.end, ')');
7386
7465
  }
@@ -7554,15 +7633,12 @@ class ConditionalExpression extends NodeBase {
7554
7633
  usedBranch.render(code, options, {
7555
7634
  isCalleeOfRenderedParent,
7556
7635
  preventASI: true,
7557
- ...(renderedSurroundingElement
7558
- ? { renderedSurroundingElement }
7559
- : { renderedParentType: renderedParentType || this.parent.type })
7636
+ renderedParentType: renderedParentType || this.parent.type,
7637
+ renderedSurroundingElement: renderedSurroundingElement || this.parent.type
7560
7638
  });
7561
7639
  }
7562
7640
  else {
7563
- this.test.render(code, options, {
7564
- renderedSurroundingElement: renderedParentType || renderedSurroundingElement
7565
- });
7641
+ this.test.render(code, options, { renderedSurroundingElement });
7566
7642
  this.consequent.render(code, options);
7567
7643
  this.alternate.render(code, options);
7568
7644
  }
@@ -7796,10 +7872,9 @@ class ForStatement extends NodeBase {
7796
7872
  }
7797
7873
 
7798
7874
  class FunctionExpression extends FunctionNode {
7799
- render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
7875
+ render(code, options, { renderedSurroundingElement } = BLANK) {
7800
7876
  super.render(code, options);
7801
- const surroundingElement = renderedParentType || renderedSurroundingElement;
7802
- if (surroundingElement === ExpressionStatement$1) {
7877
+ if (renderedSurroundingElement === ExpressionStatement$1) {
7803
7878
  code.appendRight(this.start, '(');
7804
7879
  code.prependLeft(this.end, ')');
7805
7880
  }
@@ -8127,12 +8202,12 @@ class ImportExpression extends NodeBase {
8127
8202
  if (this.inlineNamespace) {
8128
8203
  const _ = options.compact ? '' : ' ';
8129
8204
  const s = options.compact ? '' : ';';
8130
- code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})`);
8205
+ code.overwrite(this.start, this.end, `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})`, { contentOnly: true });
8131
8206
  return;
8132
8207
  }
8133
8208
  if (this.mechanism) {
8134
- code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
8135
- code.overwrite(this.end - 1, this.end, this.mechanism.right);
8209
+ code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
8210
+ code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
8136
8211
  }
8137
8212
  this.source.render(code, options);
8138
8213
  }
@@ -8393,15 +8468,14 @@ class LogicalExpression extends NodeBase {
8393
8468
  this.getUsedBranch().render(code, options, {
8394
8469
  isCalleeOfRenderedParent,
8395
8470
  preventASI,
8396
- ...(renderedSurroundingElement
8397
- ? { renderedSurroundingElement }
8398
- : { renderedParentType: renderedParentType || this.parent.type })
8471
+ renderedParentType: renderedParentType || this.parent.type,
8472
+ renderedSurroundingElement: renderedSurroundingElement || this.parent.type
8399
8473
  });
8400
8474
  }
8401
8475
  else {
8402
8476
  this.left.render(code, options, {
8403
8477
  preventASI,
8404
- renderedSurroundingElement: renderedParentType || renderedSurroundingElement
8478
+ renderedSurroundingElement
8405
8479
  });
8406
8480
  this.right.render(code, options);
8407
8481
  }
@@ -8657,11 +8731,10 @@ class ObjectExpression extends NodeBase {
8657
8731
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8658
8732
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
8659
8733
  }
8660
- render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
8734
+ render(code, options, { renderedSurroundingElement } = BLANK) {
8661
8735
  super.render(code, options);
8662
- const surroundingElement = renderedParentType || renderedSurroundingElement;
8663
- if (surroundingElement === ExpressionStatement$1 ||
8664
- surroundingElement === ArrowFunctionExpression$1) {
8736
+ if (renderedSurroundingElement === ExpressionStatement$1 ||
8737
+ renderedSurroundingElement === ArrowFunctionExpression$1) {
8665
8738
  code.appendRight(this.start, '(');
8666
8739
  code.prependLeft(this.end, ')');
8667
8740
  }
@@ -8707,47 +8780,6 @@ class ObjectExpression extends NodeBase {
8707
8780
  }
8708
8781
  }
8709
8782
 
8710
- class ObjectPattern extends NodeBase {
8711
- addExportedVariables(variables, exportNamesByVariable) {
8712
- for (const property of this.properties) {
8713
- if (property.type === Property$1) {
8714
- property.value.addExportedVariables(variables, exportNamesByVariable);
8715
- }
8716
- else {
8717
- property.argument.addExportedVariables(variables, exportNamesByVariable);
8718
- }
8719
- }
8720
- }
8721
- declare(kind, init) {
8722
- const variables = [];
8723
- for (const property of this.properties) {
8724
- variables.push(...property.declare(kind, init));
8725
- }
8726
- return variables;
8727
- }
8728
- deoptimizePath(path) {
8729
- if (path.length === 0) {
8730
- for (const property of this.properties) {
8731
- property.deoptimizePath(path);
8732
- }
8733
- }
8734
- }
8735
- hasEffectsWhenAssignedAtPath(path, context) {
8736
- if (path.length > 0)
8737
- return true;
8738
- for (const property of this.properties) {
8739
- if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
8740
- return true;
8741
- }
8742
- return false;
8743
- }
8744
- markDeclarationReached() {
8745
- for (const property of this.properties) {
8746
- property.markDeclarationReached();
8747
- }
8748
- }
8749
- }
8750
-
8751
8783
  class PrivateIdentifier extends NodeBase {
8752
8784
  }
8753
8785
 
@@ -8902,17 +8934,12 @@ class SequenceExpression extends NodeBase {
8902
8934
  removeLineBreaks(code, start, node.start);
8903
8935
  }
8904
8936
  if (includedNodes === 1) {
8905
- if (node === lastNode) {
8906
- node.render(code, options, {
8907
- isCalleeOfRenderedParent,
8908
- renderedParentType: renderedParentType || this.parent.type
8909
- });
8910
- }
8911
- else {
8912
- node.render(code, options, {
8913
- renderedSurroundingElement: renderedParentType || this.parent.type
8914
- });
8915
- }
8937
+ const parentType = renderedParentType || this.parent.type;
8938
+ node.render(code, options, {
8939
+ isCalleeOfRenderedParent: isCalleeOfRenderedParent && node === lastNode,
8940
+ renderedParentType: parentType,
8941
+ renderedSurroundingElement: parentType
8942
+ });
8916
8943
  }
8917
8944
  else {
8918
8945
  node.render(code, options);
@@ -9381,31 +9408,19 @@ class UpdateExpression extends NodeBase {
9381
9408
  if (options.format === 'system') {
9382
9409
  const variable = this.argument.variable;
9383
9410
  const exportNames = options.exportNamesByVariable.get(variable);
9384
- if (exportNames && exportNames.length) {
9411
+ if (exportNames) {
9385
9412
  const _ = options.compact ? '' : ' ';
9386
- const name = variable.getName();
9387
9413
  if (this.prefix) {
9388
9414
  if (exportNames.length === 1) {
9389
- code.overwrite(this.start, this.end, `exports('${exportNames[0]}',${_}${this.operator}${name})`);
9415
+ renderSystemExportExpression(variable, this.start, this.end, code, options);
9390
9416
  }
9391
9417
  else {
9392
- code.overwrite(this.start, this.end, `(${this.operator}${name},${_}${getSystemExportStatement([variable], options)},${_}${name})`);
9418
+ renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
9393
9419
  }
9394
9420
  }
9395
- else if (exportNames.length > 1) {
9396
- code.overwrite(this.start, this.end, `(${getSystemExportFunctionLeft([variable], false, options)}${this.operator}${name}))`);
9397
- }
9398
9421
  else {
9399
- let op;
9400
- switch (this.operator) {
9401
- case '++':
9402
- op = `${name}${_}+${_}1`;
9403
- break;
9404
- case '--':
9405
- op = `${name}${_}-${_}1`;
9406
- break;
9407
- }
9408
- code.overwrite(this.start, this.end, `(exports('${exportNames[0]}',${_}${op}),${_}${name}${this.operator})`);
9422
+ const operator = this.operator[0];
9423
+ renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options, `${_}${operator}${_}1`);
9409
9424
  }
9410
9425
  }
9411
9426
  }
@@ -9453,7 +9468,7 @@ class VariableDeclarator extends NodeBase {
9453
9468
  code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1));
9454
9469
  }
9455
9470
  if (this.init) {
9456
- this.init.render(code, options, renderId ? BLANK : { renderedParentType: ExpressionStatement$1 });
9471
+ this.init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
9457
9472
  }
9458
9473
  else if (this.id instanceof Identifier &&
9459
9474
  isReassignedExportsMember(this.id.variable, options.exportNamesByVariable)) {
@@ -10001,9 +10016,9 @@ class Module {
10001
10016
  code: null,
10002
10017
  get dynamicallyImportedIds() {
10003
10018
  const dynamicallyImportedIds = [];
10004
- for (const { resolution } of module.dynamicImports) {
10005
- if (resolution instanceof Module || resolution instanceof ExternalModule) {
10006
- dynamicallyImportedIds.push(resolution.id);
10019
+ for (const { id } of module.dynamicImports) {
10020
+ if (id) {
10021
+ dynamicallyImportedIds.push(id);
10007
10022
  }
10008
10023
  }
10009
10024
  return dynamicallyImportedIds;
@@ -10476,7 +10491,7 @@ class Module {
10476
10491
  else if (argument instanceof Literal && typeof argument.value === 'string') {
10477
10492
  argument = argument.value;
10478
10493
  }
10479
- this.dynamicImports.push({ argument, node, resolution: null });
10494
+ this.dynamicImports.push({ argument, id: null, node, resolution: null });
10480
10495
  }
10481
10496
  addExport(node) {
10482
10497
  if (node instanceof ExportDefaultDeclaration) {
@@ -11280,13 +11295,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
11280
11295
 
11281
11296
  function getStarExcludes({ dependencies, exports }) {
11282
11297
  const starExcludes = new Set(exports.map(expt => expt.exported));
11283
- if (!starExcludes.has('default'))
11284
- starExcludes.add('default');
11285
- // also include reexport names
11298
+ starExcludes.add('default');
11286
11299
  for (const { reexports } of dependencies) {
11287
11300
  if (reexports) {
11288
11301
  for (const reexport of reexports) {
11289
- if (reexport.imported !== '*' && !starExcludes.has(reexport.reexported))
11302
+ if (reexport.imported !== '*')
11290
11303
  starExcludes.add(reexport.reexported);
11291
11304
  }
11292
11305
  }
@@ -11310,9 +11323,7 @@ function getExportsBlock(exports, _, t, n) {
11310
11323
  exports.map(({ name, value }) => `${t}${t}${t}${t}${name}:${_}${value}`).join(`,${n}`) +
11311
11324
  `${n}${t}${t}${t}});${n}${n}`);
11312
11325
  }
11313
- const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports
11314
- .filter(expt => expt.hoisted || expt.uninitialized)
11315
- .map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), _, t, n);
11326
+ const getHoistedExportsBlock = (exports, _, t, n) => getExportsBlock(exports.filter(expt => expt.hoisted).map(expt => ({ name: expt.exported, value: expt.local })), _, t, n);
11316
11327
  const getMissingExportsBlock = (exports, _, t, n) => getExportsBlock(exports
11317
11328
  .filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE)
11318
11329
  .map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), _, t, n);
@@ -11353,10 +11364,8 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
11353
11364
  if (!starExcludes) {
11354
11365
  starExcludes = getStarExcludes({ dependencies, exports });
11355
11366
  }
11356
- if (!createdSetter) {
11357
- setter.push(`${varOrConst} _setter${_}=${_}{};`);
11358
- createdSetter = true;
11359
- }
11367
+ createdSetter = true;
11368
+ setter.push(`${varOrConst} _setter${_}=${_}{};`);
11360
11369
  setter.push(`for${_}(var _$p${_}in${_}module)${_}{`);
11361
11370
  setter.push(`${t}if${_}(!_starExcludes[_$p])${_}_setter[_$p]${_}=${_}module[_$p];`);
11362
11371
  setter.push('}');
@@ -12699,12 +12708,8 @@ class Chunk {
12699
12708
  }
12700
12709
  let expression = null;
12701
12710
  let hoisted = false;
12702
- let uninitialized = false;
12703
12711
  let local = variable.getName();
12704
12712
  if (variable instanceof LocalVariable) {
12705
- if (variable.init === UNDEFINED_EXPRESSION) {
12706
- uninitialized = true;
12707
- }
12708
12713
  for (const declaration of variable.declarations) {
12709
12714
  if (declaration.parent instanceof FunctionDeclaration ||
12710
12715
  (declaration instanceof ExportDefaultDeclaration &&
@@ -12724,8 +12729,7 @@ class Chunk {
12724
12729
  exported: exportName,
12725
12730
  expression,
12726
12731
  hoisted,
12727
- local,
12728
- uninitialized
12732
+ local
12729
12733
  });
12730
12734
  }
12731
12735
  return exports;
@@ -19669,12 +19673,10 @@ class ModuleLoader {
19669
19673
  }));
19670
19674
  }
19671
19675
  async addModuleSource(id, importer, module) {
19672
- var _a;
19673
19676
  timeStart('load modules', 3);
19674
19677
  let source;
19675
19678
  try {
19676
- source =
19677
- (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await this.readQueue.run(async () => readFile(id)));
19679
+ source = await this.readQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id)); });
19678
19680
  }
19679
19681
  catch (err) {
19680
19682
  timeEnd('load modules', 3);
@@ -19723,11 +19725,8 @@ class ModuleLoader {
19723
19725
  });
19724
19726
  return loadNewModulesPromise;
19725
19727
  }
19726
- async fetchDynamicDependencies(module) {
19727
- const dependencies = await Promise.all(module.dynamicImports.map(async (dynamicImport) => {
19728
- const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
19729
- ? dynamicImport.argument
19730
- : dynamicImport.argument.esTreeNode, module.id);
19728
+ async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
19729
+ const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([dynamicImport, resolvedId]) => {
19731
19730
  if (resolvedId === null)
19732
19731
  return null;
19733
19732
  if (typeof resolvedId === 'string') {
@@ -19735,7 +19734,7 @@ class ModuleLoader {
19735
19734
  return null;
19736
19735
  }
19737
19736
  return (dynamicImport.resolution = await this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId));
19738
- }));
19737
+ })));
19739
19738
  for (const dependency of dependencies) {
19740
19739
  if (dependency) {
19741
19740
  module.dynamicDependencies.add(dependency);
@@ -19760,10 +19759,15 @@ class ModuleLoader {
19760
19759
  this.modulesById.set(id, module);
19761
19760
  this.graph.watchFiles[id] = true;
19762
19761
  await this.addModuleSource(id, importer, module);
19763
- await this.pluginDriver.hookParallel('moduleParsed', [module.info]);
19762
+ const resolveStaticDependencyPromises = this.getResolveStaticDependencyPromises(module);
19763
+ const resolveDynamicImportPromises = this.getResolveDynamicImportPromises(module);
19764
+ Promise.all([
19765
+ ...resolveStaticDependencyPromises,
19766
+ ...resolveDynamicImportPromises
19767
+ ]).then(() => this.pluginDriver.hookParallel('moduleParsed', [module.info]));
19764
19768
  await Promise.all([
19765
- this.fetchStaticDependencies(module),
19766
- this.fetchDynamicDependencies(module)
19769
+ this.fetchStaticDependencies(module, resolveStaticDependencyPromises),
19770
+ this.fetchDynamicDependencies(module, resolveDynamicImportPromises)
19767
19771
  ]);
19768
19772
  module.linkImports();
19769
19773
  return module;
@@ -19784,10 +19788,8 @@ class ModuleLoader {
19784
19788
  return this.fetchModule(resolvedId, importer, false);
19785
19789
  }
19786
19790
  }
19787
- async fetchStaticDependencies(module) {
19788
- for (const dependency of await Promise.all(Array.from(module.sources, async (source) => this.fetchResolvedDependency(source, module.id, (module.resolvedIds[source] =
19789
- module.resolvedIds[source] ||
19790
- this.handleResolveId(await this.resolveId(source, module.id, EMPTY_OBJECT), source, module.id)))))) {
19791
+ async fetchStaticDependencies(module, resolveStaticDependencyPromises) {
19792
+ for (const dependency of await Promise.all(resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => resolveStaticDependencyPromise.then(([source, resolvedId]) => this.fetchResolvedDependency(source, module.id, resolvedId))))) {
19791
19793
  module.dependencies.add(dependency);
19792
19794
  dependency.importers.push(module.id);
19793
19795
  }
@@ -19835,6 +19837,25 @@ class ModuleLoader {
19835
19837
  id
19836
19838
  };
19837
19839
  }
19840
+ getResolveDynamicImportPromises(module) {
19841
+ return module.dynamicImports.map(async (dynamicImport) => {
19842
+ const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
19843
+ ? dynamicImport.argument
19844
+ : dynamicImport.argument.esTreeNode, module.id);
19845
+ if (resolvedId && typeof resolvedId === 'object') {
19846
+ dynamicImport.id = resolvedId.id;
19847
+ }
19848
+ return [dynamicImport, resolvedId];
19849
+ });
19850
+ }
19851
+ getResolveStaticDependencyPromises(module) {
19852
+ return Array.from(module.sources, async (source) => [
19853
+ source,
19854
+ (module.resolvedIds[source] =
19855
+ module.resolvedIds[source] ||
19856
+ this.handleResolveId(await this.resolveId(source, module.id, EMPTY_OBJECT), source, module.id))
19857
+ ]);
19858
+ }
19838
19859
  handleResolveId(resolvedId, source, importer) {
19839
19860
  if (resolvedId === null) {
19840
19861
  if (isRelative(source)) {