rollup 2.29.0 → 2.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.29.0
4
- Thu, 08 Oct 2020 04:24:04 GMT - commit 0b02e52bc7816c473784794670a2c3047ac62a07
3
+ Rollup.js v2.32.1
4
+ Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
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 = "2.29.0";
22
+ var version = "2.32.1";
23
23
 
24
24
  function ensureArray(items) {
25
25
  if (Array.isArray(items)) {
@@ -2356,6 +2356,10 @@ class ExternalVariable extends Variable {
2356
2356
  }
2357
2357
  }
2358
2358
 
2359
+ const BLANK = Object.freeze(Object.create(null));
2360
+ const EMPTY_OBJECT = Object.freeze({});
2361
+ const EMPTY_ARRAY = Object.freeze([]);
2362
+
2359
2363
  const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' ');
2360
2364
  const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' ');
2361
2365
  const blacklisted = new Set(reservedWords.concat(builtins));
@@ -2375,11 +2379,9 @@ function makeLegal(str) {
2375
2379
  }
2376
2380
 
2377
2381
  class ExternalModule {
2378
- constructor(options, id, moduleSideEffects, meta) {
2382
+ constructor(options, id, hasModuleSideEffects, meta) {
2379
2383
  this.options = options;
2380
2384
  this.id = id;
2381
- this.moduleSideEffects = moduleSideEffects;
2382
- this.meta = meta;
2383
2385
  this.defaultVariableName = '';
2384
2386
  this.dynamicImporters = [];
2385
2387
  this.importers = [];
@@ -2390,14 +2392,31 @@ class ExternalModule {
2390
2392
  this.renormalizeRenderPath = false;
2391
2393
  this.used = false;
2392
2394
  this.variableName = '';
2393
- this.id = id;
2394
2395
  this.execIndex = Infinity;
2395
- this.moduleSideEffects = moduleSideEffects;
2396
- const parts = id.split(/[\\/]/);
2397
- this.suggestedVariableName = makeLegal(parts.pop());
2396
+ this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
2398
2397
  this.nameSuggestions = Object.create(null);
2399
2398
  this.declarations = Object.create(null);
2400
2399
  this.exportedVariables = new Map();
2400
+ const module = this;
2401
+ this.info = {
2402
+ ast: null,
2403
+ code: null,
2404
+ dynamicallyImportedIds: EMPTY_ARRAY,
2405
+ get dynamicImporters() {
2406
+ return module.dynamicImporters.sort();
2407
+ },
2408
+ hasModuleSideEffects,
2409
+ id,
2410
+ implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
2411
+ implicitlyLoadedBefore: EMPTY_ARRAY,
2412
+ importedIds: EMPTY_ARRAY,
2413
+ get importers() {
2414
+ return module.importers.sort();
2415
+ },
2416
+ isEntry: false,
2417
+ isExternal: true,
2418
+ meta
2419
+ };
2401
2420
  }
2402
2421
  getVariableForExportName(name) {
2403
2422
  let declaration = this.declarations[name];
@@ -2462,7 +2481,7 @@ function markModuleAndImpureDependenciesAsExecuted(baseModule) {
2462
2481
  for (const dependency of [...module.dependencies, ...module.implicitlyLoadedBefore]) {
2463
2482
  if (!(dependency instanceof ExternalModule) &&
2464
2483
  !dependency.isExecuted &&
2465
- (dependency.moduleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
2484
+ (dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
2466
2485
  !visitedModules.has(dependency.id)) {
2467
2486
  dependency.isExecuted = true;
2468
2487
  visitedModules.add(dependency.id);
@@ -2819,6 +2838,7 @@ const INCLUDE_PARAMETERS = 'variables';
2819
2838
  class NodeBase {
2820
2839
  constructor(esTreeNode, parent, parentScope) {
2821
2840
  this.included = false;
2841
+ this.esTreeNode = esTreeNode;
2822
2842
  this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
2823
2843
  this.parent = parent;
2824
2844
  this.context = parent.context;
@@ -3217,10 +3237,6 @@ function isReference(node, parent) {
3217
3237
  return false;
3218
3238
  }
3219
3239
 
3220
- const BLANK = Object.freeze(Object.create(null));
3221
- const EMPTY_OBJECT = Object.freeze({});
3222
- const EMPTY_ARRAY = Object.freeze([]);
3223
-
3224
3240
  const ValueProperties = Symbol('Value Properties');
3225
3241
  const PURE = { pure: true };
3226
3242
  const IMPURE = { pure: false };
@@ -4683,9 +4699,6 @@ const getPropertyAccess = (name) => {
4683
4699
  : `[${JSON.stringify(name)}]`;
4684
4700
  };
4685
4701
 
4686
- const esModuleExport = `Object.defineProperty(exports, '__esModule', { value: true });`;
4687
- const compactEsModuleExport = `Object.defineProperty(exports,'__esModule',{value:true});`;
4688
-
4689
4702
  const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
4690
4703
  const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
4691
4704
  const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
@@ -4718,9 +4731,9 @@ function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
4718
4731
  function getDefaultOnlyHelper() {
4719
4732
  return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
4720
4733
  }
4721
- function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze) {
4734
+ function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
4722
4735
  return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
4723
- ? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, usedHelpers)
4736
+ ? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
4724
4737
  : '').join('');
4725
4738
  }
4726
4739
  const HELPER_GENERATORS = {
@@ -4730,17 +4743,17 @@ const HELPER_GENERATORS = {
4730
4743
  [INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
4731
4744
  `e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
4732
4745
  `${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
4733
- [INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
4746
+ [INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
4734
4747
  (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
4735
4748
  ? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
4736
4749
  : `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
4737
- createNamespaceObject(_, n, t, t, liveBindings, freeze)) +
4750
+ createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
4738
4751
  `}${n}${n}`,
4739
- [INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
4740
- createNamespaceObject(_, n, t, t, liveBindings, freeze) +
4752
+ [INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
4753
+ createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
4741
4754
  `}${n}${n}`,
4742
- [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
4743
- `${t}return ${getFrozen(`{__proto__: null,${_}'default':${_}e}`, freeze)};${n}` +
4755
+ [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
4756
+ `${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
4744
4757
  `}${n}${n}`
4745
4758
  };
4746
4759
  function getDefaultLiveBinding(_) {
@@ -4749,8 +4762,10 @@ function getDefaultLiveBinding(_) {
4749
4762
  function getDefaultStatic(_) {
4750
4763
  return `e['default']${_}:${_}e`;
4751
4764
  }
4752
- function createNamespaceObject(_, n, t, i, liveBindings, freeze) {
4753
- return (`${i}var n${_}=${_}Object.create(null);${n}` +
4765
+ function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
4766
+ return (`${i}var n${_}=${_}${namespaceToStringTag
4767
+ ? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
4768
+ : 'Object.create(null)'};${n}` +
4754
4769
  `${i}if${_}(e)${_}{${n}` +
4755
4770
  `${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
4756
4771
  (liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
@@ -4876,8 +4891,29 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
4876
4891
  }
4877
4892
  return `${moduleVariableName}.${imported}`;
4878
4893
  }
4894
+ function getEsModuleExport(_) {
4895
+ return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
4896
+ }
4897
+ function getNamespaceToStringExport(_) {
4898
+ return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
4899
+ }
4900
+ function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
4901
+ let namespaceMarkers = '';
4902
+ if (hasNamedExports) {
4903
+ if (addEsModule) {
4904
+ namespaceMarkers += getEsModuleExport(_);
4905
+ }
4906
+ if (addNamespaceToStringTag) {
4907
+ if (namespaceMarkers) {
4908
+ namespaceMarkers += n;
4909
+ }
4910
+ namespaceMarkers += getNamespaceToStringExport(_);
4911
+ }
4912
+ }
4913
+ return namespaceMarkers;
4914
+ }
4879
4915
 
4880
- function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t) {
4916
+ function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t) {
4881
4917
  const neededInteropHelpers = new Set();
4882
4918
  const interopStatements = [];
4883
4919
  const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
@@ -4930,7 +4966,7 @@ function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings
4930
4966
  }
4931
4967
  }
4932
4968
  }
4933
- return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
4969
+ return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
4934
4970
  }
4935
4971
 
4936
4972
  const builtins$1 = {
@@ -4982,7 +5018,7 @@ function removeExtensionFromRelativeAmdId(id) {
4982
5018
  }
4983
5019
  return id;
4984
5020
  }
4985
- function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryModuleFacade, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, externalLiveBindings, freeze, interop, strict }) {
5021
+ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
4986
5022
  warnOnBuiltins(warn, dependencies);
4987
5023
  const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
4988
5024
  const args = dependencies.map(m => m.name);
@@ -5003,31 +5039,31 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
5003
5039
  }
5004
5040
  const params = (amdId ? `'${amdId}',${_}` : ``) + (deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
5005
5041
  const useStrict = strict ? `${_}'use strict';` : '';
5006
- magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t)}`);
5042
+ magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
5007
5043
  const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
5008
- if (exportBlock)
5009
- magicString.append(exportBlock);
5010
- if (namedExportsMode && hasExports && isEntryModuleFacade && esModule)
5011
- magicString.append(`${n}${n}${compact ? compactEsModuleExport : esModuleExport}`);
5012
- if (outro)
5013
- magicString.append(outro);
5044
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
5045
+ if (namespaceMarkers) {
5046
+ namespaceMarkers = n + n + namespaceMarkers;
5047
+ }
5048
+ magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
5014
5049
  return magicString
5015
5050
  .indent(t)
5016
5051
  .prepend(`${amdDefine}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
5017
5052
  .append(`${n}${n}});`);
5018
5053
  }
5019
5054
 
5020
- function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, strict }) {
5055
+ function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
5021
5056
  const n = compact ? '' : '\n';
5022
5057
  const s = compact ? '' : ';';
5023
5058
  const _ = compact ? '' : ' ';
5024
5059
  const useStrict = strict ? `'use strict';${n}${n}` : '';
5025
- const esModuleProp = namedExportsMode && hasExports && isEntryModuleFacade && esModule
5026
- ? `${compact ? compactEsModuleExport : esModuleExport}${n}${n}`
5027
- : '';
5060
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
5061
+ if (namespaceMarkers) {
5062
+ namespaceMarkers += n + n;
5063
+ }
5028
5064
  const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
5029
- const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t);
5030
- magicString.prepend(`${useStrict}${intro}${esModuleProp}${importBlock}${interopBlock}`);
5065
+ const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
5066
+ magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
5031
5067
  const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
5032
5068
  return magicString.append(`${exportBlock}${outro}`);
5033
5069
  }
@@ -5548,7 +5584,7 @@ function trimEmptyImports(dependencies) {
5548
5584
  }
5549
5585
 
5550
5586
  const thisProp = (name) => `this${keypath(name)}`;
5551
- function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { compact, extend, freeze, externalLiveBindings, globals, interop, name, strict }) {
5587
+ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
5552
5588
  const _ = compact ? '' : ' ';
5553
5589
  const s = compact ? '' : ';';
5554
5590
  const n = compact ? '' : '\n';
@@ -5581,7 +5617,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
5581
5617
  }
5582
5618
  }
5583
5619
  const useStrict = strict ? `${t}'use strict';${n}` : '';
5584
- const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t);
5620
+ const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
5585
5621
  magicString.prepend(`${intro}${interopBlock}`);
5586
5622
  let wrapperIntro = `(function${_}(${args.join(`,${_}`)})${_}{${n}${useStrict}${n}`;
5587
5623
  if (hasExports) {
@@ -5599,7 +5635,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
5599
5635
  wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
5600
5636
  }
5601
5637
  const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
5602
- magicString.append(`${exportBlock}${outro}`);
5638
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
5639
+ if (namespaceMarkers) {
5640
+ namespaceMarkers = n + n + namespaceMarkers;
5641
+ }
5642
+ magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
5603
5643
  return magicString.indent(t).prepend(wrapperIntro).append(wrapperOutro);
5604
5644
  }
5605
5645
 
@@ -5759,7 +5799,7 @@ function safeAccess(name, globalVar, _) {
5759
5799
  let acc = globalVar;
5760
5800
  return parts.map(part => (acc += property(part))).join(`${_}&&${_}`);
5761
5801
  }
5762
- function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, extend, externalLiveBindings, freeze, interop, name, globals, noConflict, strict }) {
5802
+ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
5763
5803
  const _ = compact ? '' : ' ';
5764
5804
  const n = compact ? '' : '\n';
5765
5805
  const s = compact ? '' : ';';
@@ -5832,14 +5872,13 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
5832
5872
  `${t}${iifeStart}${iifeExport}${iifeEnd};${n}` +
5833
5873
  `}(${globalArg}(function${_}(${factoryArgs.join(', ')})${_}{${useStrict}${n}`;
5834
5874
  const wrapperOutro = n + n + '})));';
5835
- magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t)}`);
5875
+ magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
5836
5876
  const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
5837
- if (exportBlock)
5838
- magicString.append(exportBlock);
5839
- if (namedExportsMode && hasExports && esModule)
5840
- magicString.append(n + n + (compact ? compactEsModuleExport : esModuleExport));
5841
- if (outro)
5842
- magicString.append(outro);
5877
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
5878
+ if (namespaceMarkers) {
5879
+ namespaceMarkers = n + n + namespaceMarkers;
5880
+ }
5881
+ magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
5843
5882
  return magicString.trim().indent(t).append(wrapperOutro).prepend(wrapperIntro);
5844
5883
  }
5845
5884
 
@@ -9636,7 +9675,7 @@ function initialiseTimers(inputOptions) {
9636
9675
 
9637
9676
  function tryParse(module, Parser, acornOptions) {
9638
9677
  try {
9639
- return Parser.parse(module.code, {
9678
+ return Parser.parse(module.info.code, {
9640
9679
  ...acornOptions,
9641
9680
  onComment: (block, text, start, end) => module.comments.push({ block, text, start, end })
9642
9681
  });
@@ -9681,14 +9720,12 @@ function getVariableForExportNameRecursive(target, name, isExportAllSearch, sear
9681
9720
  return target.getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules);
9682
9721
  }
9683
9722
  class Module {
9684
- constructor(graph, id, options, isEntryPoint, moduleSideEffects, syntheticNamedExports, meta) {
9723
+ constructor(graph, id, options, isEntry, hasModuleSideEffects, syntheticNamedExports, meta) {
9685
9724
  this.graph = graph;
9686
9725
  this.id = id;
9687
9726
  this.options = options;
9688
- this.isEntryPoint = isEntryPoint;
9689
- this.moduleSideEffects = moduleSideEffects;
9690
9727
  this.syntheticNamedExports = syntheticNamedExports;
9691
- this.meta = meta;
9728
+ this.ast = null;
9692
9729
  this.chunkFileNames = new Set();
9693
9730
  this.chunkName = null;
9694
9731
  this.comments = [];
@@ -9725,6 +9762,40 @@ class Module {
9725
9762
  this.transitiveReexports = null;
9726
9763
  this.excludeFromSourcemap = /\0/.test(id);
9727
9764
  this.context = options.moduleContext(id);
9765
+ const module = this;
9766
+ this.info = {
9767
+ ast: null,
9768
+ code: null,
9769
+ get dynamicallyImportedIds() {
9770
+ const dynamicallyImportedIds = [];
9771
+ for (const { resolution } of module.dynamicImports) {
9772
+ if (resolution instanceof Module || resolution instanceof ExternalModule) {
9773
+ dynamicallyImportedIds.push(resolution.id);
9774
+ }
9775
+ }
9776
+ return dynamicallyImportedIds;
9777
+ },
9778
+ get dynamicImporters() {
9779
+ return module.dynamicImporters.sort();
9780
+ },
9781
+ hasModuleSideEffects,
9782
+ id,
9783
+ get implicitlyLoadedAfterOneOf() {
9784
+ return Array.from(module.implicitlyLoadedAfter, getId);
9785
+ },
9786
+ get implicitlyLoadedBefore() {
9787
+ return Array.from(module.implicitlyLoadedBefore, getId);
9788
+ },
9789
+ get importedIds() {
9790
+ return Array.from(module.sources, source => module.resolvedIds[source].id);
9791
+ },
9792
+ get importers() {
9793
+ return module.importers.sort();
9794
+ },
9795
+ isEntry,
9796
+ isExternal: false,
9797
+ meta
9798
+ };
9728
9799
  }
9729
9800
  basename() {
9730
9801
  const base = sysPath.basename(this.id);
@@ -9768,7 +9839,7 @@ class Module {
9768
9839
  const additionalSideEffectModules = new Set();
9769
9840
  const possibleDependencies = new Set(this.dependencies);
9770
9841
  let dependencyVariables = this.imports;
9771
- if (this.isEntryPoint ||
9842
+ if (this.info.isEntry ||
9772
9843
  this.includedDynamicImporters.length > 0 ||
9773
9844
  this.namespace.included ||
9774
9845
  this.implicitlyLoadedAfter.size > 0) {
@@ -9791,9 +9862,10 @@ class Module {
9791
9862
  }
9792
9863
  relevantDependencies.add(variable.module);
9793
9864
  }
9794
- if (this.options.treeshake && this.moduleSideEffects !== 'no-treeshake') {
9865
+ if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') {
9795
9866
  for (const dependency of possibleDependencies) {
9796
- if (!(dependency.moduleSideEffects || additionalSideEffectModules.has(dependency)) ||
9867
+ if (!(dependency.info.hasModuleSideEffects ||
9868
+ additionalSideEffectModules.has(dependency)) ||
9797
9869
  relevantDependencies.has(dependency)) {
9798
9870
  continue;
9799
9871
  }
@@ -9948,7 +10020,7 @@ class Module {
9948
10020
  return null;
9949
10021
  }
9950
10022
  hasEffects() {
9951
- return (this.moduleSideEffects === 'no-treeshake' ||
10023
+ return (this.info.hasModuleSideEffects === 'no-treeshake' ||
9952
10024
  (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
9953
10025
  }
9954
10026
  include() {
@@ -10026,7 +10098,7 @@ class Module {
10026
10098
  return magicString;
10027
10099
  }
10028
10100
  setSource({ alwaysRemovedCode, ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
10029
- this.code = code;
10101
+ this.info.code = code;
10030
10102
  this.originalCode = originalCode;
10031
10103
  this.originalSourcemap = originalSourcemap;
10032
10104
  this.sourcemapChain = sourcemapChain;
@@ -10038,17 +10110,14 @@ class Module {
10038
10110
  this.updateOptions(moduleOptions);
10039
10111
  timeStart('generate ast', 3);
10040
10112
  this.alwaysRemovedCode = alwaysRemovedCode || [];
10041
- if (ast) {
10042
- this.esTreeAst = ast;
10043
- }
10044
- else {
10045
- this.esTreeAst = tryParse(this, this.graph.acornParser, this.options.acorn);
10113
+ if (!ast) {
10114
+ ast = tryParse(this, this.graph.acornParser, this.options.acorn);
10046
10115
  for (const comment of this.comments) {
10047
10116
  if (!comment.block && SOURCEMAPPING_URL_RE.test(comment.text)) {
10048
10117
  this.alwaysRemovedCode.push([comment.start, comment.end]);
10049
10118
  }
10050
10119
  }
10051
- markPureCallExpressions(this.comments, this.esTreeAst);
10120
+ markPureCallExpressions(this.comments, ast);
10052
10121
  }
10053
10122
  timeEnd('generate ast', 3);
10054
10123
  this.resolvedIds = resolvedIds || Object.create(null);
@@ -10092,19 +10161,20 @@ class Module {
10092
10161
  };
10093
10162
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
10094
10163
  this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
10095
- this.ast = new Program$1(this.esTreeAst, { type: 'Module', context: this.astContext }, this.scope);
10164
+ this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
10165
+ this.info.ast = ast;
10096
10166
  timeEnd('analyse ast', 3);
10097
10167
  }
10098
10168
  toJSON() {
10099
10169
  return {
10100
10170
  alwaysRemovedCode: this.alwaysRemovedCode,
10101
- ast: this.esTreeAst,
10102
- code: this.code,
10171
+ ast: this.ast.esTreeNode,
10172
+ code: this.info.code,
10103
10173
  customTransformCache: this.customTransformCache,
10104
10174
  dependencies: Array.from(this.dependencies, getId),
10105
10175
  id: this.id,
10106
- meta: this.meta,
10107
- moduleSideEffects: this.moduleSideEffects,
10176
+ meta: this.info.meta,
10177
+ moduleSideEffects: this.info.hasModuleSideEffects,
10108
10178
  originalCode: this.originalCode,
10109
10179
  originalSourcemap: this.originalSourcemap,
10110
10180
  resolvedIds: this.resolvedIds,
@@ -10135,13 +10205,13 @@ class Module {
10135
10205
  }
10136
10206
  updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
10137
10207
  if (moduleSideEffects != null) {
10138
- this.moduleSideEffects = moduleSideEffects;
10208
+ this.info.hasModuleSideEffects = moduleSideEffects;
10139
10209
  }
10140
10210
  if (syntheticNamedExports != null) {
10141
10211
  this.syntheticNamedExports = syntheticNamedExports;
10142
10212
  }
10143
10213
  if (meta != null) {
10144
- this.meta = { ...this.meta, ...meta };
10214
+ this.info.meta = { ...this.info.meta, ...meta };
10145
10215
  }
10146
10216
  }
10147
10217
  warn(props, pos) {
@@ -10251,7 +10321,7 @@ class Module {
10251
10321
  addLocationToLogProps(props, pos) {
10252
10322
  props.id = this.id;
10253
10323
  props.pos = pos;
10254
- let code = this.code;
10324
+ let code = this.info.code;
10255
10325
  let { column, line } = locate(code, pos, { offsetLine: 1 });
10256
10326
  try {
10257
10327
  ({ column, line } = getOriginalLocation(this.sourcemapChain, { column, line }));
@@ -10448,7 +10518,6 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
10448
10518
  else {
10449
10519
  const sources = originalSourcemap.sources;
10450
10520
  const sourcesContent = originalSourcemap.sourcesContent || [];
10451
- // TODO indiscriminately treating IDs and sources as normal paths is probably bad.
10452
10521
  const directory = sysPath.dirname(id) || '.';
10453
10522
  const sourceRoot = originalSourcemap.sourceRoot || '.';
10454
10523
  const baseSources = sources.map((source, i) => new Source(sysPath.resolve(directory, sourceRoot, source), sourcesContent[i]));
@@ -10902,7 +10971,7 @@ class Chunk$1 {
10902
10971
  if (this.isEmpty && module.isIncluded()) {
10903
10972
  this.isEmpty = false;
10904
10973
  }
10905
- if (module.isEntryPoint || outputOptions.preserveModules) {
10974
+ if (module.info.isEntry || outputOptions.preserveModules) {
10906
10975
  this.entryModules.push(module);
10907
10976
  }
10908
10977
  for (const importer of module.includedDynamicImporters) {
@@ -10931,7 +11000,7 @@ class Chunk$1 {
10931
11000
  chunk.dependencies.add(dependency instanceof Module ? chunkByModule.get(dependency) : dependency);
10932
11001
  }
10933
11002
  if (!chunk.dependencies.has(chunkByModule.get(facadedModule)) &&
10934
- facadedModule.moduleSideEffects &&
11003
+ facadedModule.info.hasModuleSideEffects &&
10935
11004
  facadedModule.hasEffects()) {
10936
11005
  chunk.dependencies.add(chunkByModule.get(facadedModule));
10937
11006
  }
@@ -10985,7 +11054,7 @@ class Chunk$1 {
10985
11054
  else {
10986
11055
  assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
10987
11056
  }
10988
- if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.isEntryPoint))
11057
+ if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
10989
11058
  this.exportMode = getExportMode(this, this.outputOptions, this.unsetOptions, this.facadeModule.id, this.inputOptions.onwarn);
10990
11059
  }
10991
11060
  generateFacades() {
@@ -11011,17 +11080,21 @@ class Chunk$1 {
11011
11080
  if (requiredFacades.length === 0) {
11012
11081
  requiredFacades.push({});
11013
11082
  }
11014
- if (!this.facadeModule &&
11015
- (this.outputOptions.preserveModules ||
11016
- module.preserveSignature !== 'strict' ||
11017
- this.canModuleBeFacade(module, exposedVariables))) {
11018
- this.facadeModule = module;
11019
- this.facadeChunkByModule.set(module, this);
11020
- if (module.preserveSignature) {
11021
- this.strictFacade = module.preserveSignature === 'strict';
11022
- this.ensureReexportsAreAvailableForModule(module);
11083
+ if (!this.facadeModule) {
11084
+ const needsStrictFacade = module.preserveSignature === 'strict' ||
11085
+ (module.preserveSignature === 'exports-only' &&
11086
+ module.getExportNamesByVariable().size !== 0);
11087
+ if (!needsStrictFacade ||
11088
+ this.outputOptions.preserveModules ||
11089
+ this.canModuleBeFacade(module, exposedVariables)) {
11090
+ this.facadeModule = module;
11091
+ this.facadeChunkByModule.set(module, this);
11092
+ if (module.preserveSignature) {
11093
+ this.strictFacade = needsStrictFacade;
11094
+ this.ensureReexportsAreAvailableForModule(module);
11095
+ }
11096
+ this.assignFacadeName(requiredFacades.shift(), module);
11023
11097
  }
11024
- this.assignFacadeName(requiredFacades.shift(), module);
11025
11098
  }
11026
11099
  for (const facadeName of requiredFacades) {
11027
11100
  facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
@@ -11102,7 +11175,7 @@ class Chunk$1 {
11102
11175
  exports: this.getExportNames(),
11103
11176
  facadeModuleId: facadeModule && facadeModule.id,
11104
11177
  isDynamicEntry: this.dynamicEntryModules.length > 0,
11105
- isEntry: facadeModule !== null && facadeModule.isEntryPoint,
11178
+ isEntry: facadeModule !== null && facadeModule.info.isEntry,
11106
11179
  isImplicitEntry: this.implicitEntryModules.length > 0,
11107
11180
  modules: this.renderedModules,
11108
11181
  get name() {
@@ -11304,8 +11377,9 @@ class Chunk$1 {
11304
11377
  hasExports,
11305
11378
  indentString: this.indentString,
11306
11379
  intro: addons.intro,
11307
- isEntryModuleFacade: this.outputOptions.preserveModules ||
11308
- (this.facadeModule !== null && this.facadeModule.isEntryPoint),
11380
+ isEntryFacade: this.outputOptions.preserveModules ||
11381
+ (this.facadeModule !== null && this.facadeModule.info.isEntry),
11382
+ isModuleFacade: this.facadeModule !== null,
11309
11383
  namedExportsMode: this.exportMode !== 'default',
11310
11384
  outro: addons.outro,
11311
11385
  usesTopLevelAwait,
@@ -11806,7 +11880,7 @@ class Chunk$1 {
11806
11880
  }
11807
11881
  }
11808
11882
  if (this.includedNamespaces.has(module) ||
11809
- (module.isEntryPoint && module.preserveSignature !== false) ||
11883
+ (module.info.isEntry && module.preserveSignature !== false) ||
11810
11884
  module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
11811
11885
  this.ensureReexportsAreAvailableForModule(module);
11812
11886
  }
@@ -12435,7 +12509,7 @@ function validateOptionsForMultiChunkOutput(outputOptions) {
12435
12509
  }
12436
12510
  function getIncludedModules(modulesById) {
12437
12511
  return [...modulesById.values()].filter(module => module instanceof Module &&
12438
- (module.isIncluded() || module.isEntryPoint || module.includedDynamicImporters.length > 0));
12512
+ (module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0));
12439
12513
  }
12440
12514
  function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
12441
12515
  const existingAlias = manualChunkAliasByEntry.get(module);
@@ -18057,7 +18131,7 @@ function transform(source, module, pluginDriver, warn) {
18057
18131
  ast,
18058
18132
  code,
18059
18133
  customTransformCache,
18060
- meta: module.meta,
18134
+ meta: module.info.meta,
18061
18135
  originalCode,
18062
18136
  originalSourcemap,
18063
18137
  sourcemapChain,
@@ -18151,7 +18225,7 @@ class ModuleLoader {
18151
18225
  addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
18152
18226
  return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then(async (entryModule) => {
18153
18227
  addChunkNamesToModule(entryModule, unresolvedModule, false);
18154
- if (!entryModule.isEntryPoint) {
18228
+ if (!entryModule.info.isEntry) {
18155
18229
  this.implicitEntryModules.add(entryModule);
18156
18230
  const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id)));
18157
18231
  for (const module of implicitlyLoadedAfterModules) {
@@ -18220,7 +18294,9 @@ class ModuleLoader {
18220
18294
  }
18221
18295
  async fetchDynamicDependencies(module) {
18222
18296
  const dependencies = await Promise.all(module.dynamicImports.map(async (dynamicImport) => {
18223
- const resolvedId = await this.resolveDynamicImport(module, dynamicImport.argument, module.id);
18297
+ const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
18298
+ ? dynamicImport.argument
18299
+ : dynamicImport.argument.esTreeNode, module.id);
18224
18300
  if (resolvedId === null)
18225
18301
  return null;
18226
18302
  if (typeof resolvedId === 'string') {
@@ -18240,7 +18316,7 @@ class ModuleLoader {
18240
18316
  const existingModule = this.modulesById.get(id);
18241
18317
  if (existingModule instanceof Module) {
18242
18318
  if (isEntry) {
18243
- existingModule.isEntryPoint = true;
18319
+ existingModule.info.isEntry = true;
18244
18320
  this.implicitEntryModules.delete(existingModule);
18245
18321
  for (const dependant of existingModule.implicitlyLoadedAfter) {
18246
18322
  dependant.implicitlyLoadedBefore.delete(existingModule);
@@ -18253,6 +18329,7 @@ class ModuleLoader {
18253
18329
  this.modulesById.set(id, module);
18254
18330
  this.graph.watchFiles[id] = true;
18255
18331
  await this.addModuleSource(id, importer, module);
18332
+ await this.pluginDriver.hookParallel('moduleParsed', [module.info]);
18256
18333
  await Promise.all([
18257
18334
  this.fetchStaticDependencies(module),
18258
18335
  this.fetchDynamicDependencies(module)
@@ -18343,7 +18420,6 @@ class ModuleLoader {
18343
18420
  return this.fetchModule(this.addDefaultsToResolvedId(typeof resolveIdResult === 'object' ? resolveIdResult : { id: resolveIdResult }), undefined, isEntry);
18344
18421
  }
18345
18422
  async resolveDynamicImport(module, specifier, importer) {
18346
- // TODO we only should expose the acorn AST here
18347
18423
  const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
18348
18424
  specifier,
18349
18425
  importer
@@ -18489,6 +18565,7 @@ const inputHookNames = {
18489
18565
  buildEnd: 1,
18490
18566
  buildStart: 1,
18491
18567
  load: 1,
18568
+ moduleParsed: 1,
18492
18569
  options: 1,
18493
18570
  resolveDynamicImport: 1,
18494
18571
  resolveId: 1,
@@ -18706,47 +18783,7 @@ class Graph {
18706
18783
  const foundModule = this.modulesById.get(moduleId);
18707
18784
  if (!foundModule)
18708
18785
  return null;
18709
- return {
18710
- get dynamicallyImportedIds() {
18711
- if (foundModule instanceof Module) {
18712
- const dynamicallyImportedIds = [];
18713
- for (const { resolution } of foundModule.dynamicImports) {
18714
- if (resolution instanceof Module || resolution instanceof ExternalModule) {
18715
- dynamicallyImportedIds.push(resolution.id);
18716
- }
18717
- }
18718
- return dynamicallyImportedIds;
18719
- }
18720
- return EMPTY_ARRAY;
18721
- },
18722
- get dynamicImporters() {
18723
- return foundModule.dynamicImporters.sort();
18724
- },
18725
- hasModuleSideEffects: foundModule.moduleSideEffects,
18726
- id: foundModule.id,
18727
- get implicitlyLoadedAfterOneOf() {
18728
- return foundModule instanceof Module
18729
- ? Array.from(foundModule.implicitlyLoadedAfter, getId)
18730
- : EMPTY_ARRAY;
18731
- },
18732
- get implicitlyLoadedBefore() {
18733
- return foundModule instanceof Module
18734
- ? Array.from(foundModule.implicitlyLoadedBefore, getId)
18735
- : [];
18736
- },
18737
- get importedIds() {
18738
- if (foundModule instanceof Module) {
18739
- return Array.from(foundModule.sources, source => foundModule.resolvedIds[source].id);
18740
- }
18741
- return EMPTY_ARRAY;
18742
- },
18743
- get importers() {
18744
- return foundModule.importers.sort();
18745
- },
18746
- isEntry: foundModule instanceof Module && foundModule.isEntryPoint,
18747
- isExternal: foundModule instanceof ExternalModule,
18748
- meta: foundModule.meta
18749
- };
18786
+ return foundModule.info;
18750
18787
  };
18751
18788
  this.deoptimizationTracker = new PathTracker();
18752
18789
  this.cachedModules = new Map();
@@ -18845,7 +18882,7 @@ class Graph {
18845
18882
  this.needsTreeshakingPass = false;
18846
18883
  for (const module of this.modules) {
18847
18884
  if (module.isExecuted) {
18848
- if (module.moduleSideEffects === 'no-treeshake') {
18885
+ if (module.info.hasModuleSideEffects === 'no-treeshake') {
18849
18886
  module.includeAllInBundle();
18850
18887
  }
18851
18888
  else {
@@ -18864,7 +18901,7 @@ class Graph {
18864
18901
  externalModule.warnUnusedImports();
18865
18902
  for (const module of this.implicitEntryModules) {
18866
18903
  for (const dependant of module.implicitlyLoadedAfter) {
18867
- if (!(dependant.isEntryPoint || dependant.isIncluded())) {
18904
+ if (!(dependant.info.isEntry || dependant.isIncluded())) {
18868
18905
  error(errImplicitDependantIsNotIncluded(dependant));
18869
18906
  }
18870
18907
  }