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.
- package/CHANGELOG.md +44 -0
- package/dist/bin/rollup +3 -3
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +183 -146
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.d.ts +8 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +6 -4
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +183 -146
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +5 -7
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.32.1
|
|
4
|
+
Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
|
|
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 { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$1, lstatSync, realpathSync } from 'fs';
|
|
14
14
|
import { EventEmitter } from 'events';
|
|
15
15
|
|
|
16
|
-
var version = "2.
|
|
16
|
+
var version = "2.32.1";
|
|
17
17
|
|
|
18
18
|
var charToInteger = {};
|
|
19
19
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -2265,6 +2265,10 @@ class ExternalVariable extends Variable {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
}
|
|
2267
2267
|
|
|
2268
|
+
const BLANK = Object.freeze(Object.create(null));
|
|
2269
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
2270
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
2271
|
+
|
|
2268
2272
|
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(' ');
|
|
2269
2273
|
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(' ');
|
|
2270
2274
|
const blacklisted = new Set(reservedWords.concat(builtins));
|
|
@@ -2298,11 +2302,9 @@ function normalize(path) {
|
|
|
2298
2302
|
}
|
|
2299
2303
|
|
|
2300
2304
|
class ExternalModule {
|
|
2301
|
-
constructor(options, id,
|
|
2305
|
+
constructor(options, id, hasModuleSideEffects, meta) {
|
|
2302
2306
|
this.options = options;
|
|
2303
2307
|
this.id = id;
|
|
2304
|
-
this.moduleSideEffects = moduleSideEffects;
|
|
2305
|
-
this.meta = meta;
|
|
2306
2308
|
this.defaultVariableName = '';
|
|
2307
2309
|
this.dynamicImporters = [];
|
|
2308
2310
|
this.importers = [];
|
|
@@ -2313,14 +2315,31 @@ class ExternalModule {
|
|
|
2313
2315
|
this.renormalizeRenderPath = false;
|
|
2314
2316
|
this.used = false;
|
|
2315
2317
|
this.variableName = '';
|
|
2316
|
-
this.id = id;
|
|
2317
2318
|
this.execIndex = Infinity;
|
|
2318
|
-
this.
|
|
2319
|
-
const parts = id.split(/[\\/]/);
|
|
2320
|
-
this.suggestedVariableName = makeLegal(parts.pop());
|
|
2319
|
+
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2321
2320
|
this.nameSuggestions = Object.create(null);
|
|
2322
2321
|
this.declarations = Object.create(null);
|
|
2323
2322
|
this.exportedVariables = new Map();
|
|
2323
|
+
const module = this;
|
|
2324
|
+
this.info = {
|
|
2325
|
+
ast: null,
|
|
2326
|
+
code: null,
|
|
2327
|
+
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
2328
|
+
get dynamicImporters() {
|
|
2329
|
+
return module.dynamicImporters.sort();
|
|
2330
|
+
},
|
|
2331
|
+
hasModuleSideEffects,
|
|
2332
|
+
id,
|
|
2333
|
+
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
2334
|
+
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
2335
|
+
importedIds: EMPTY_ARRAY,
|
|
2336
|
+
get importers() {
|
|
2337
|
+
return module.importers.sort();
|
|
2338
|
+
},
|
|
2339
|
+
isEntry: false,
|
|
2340
|
+
isExternal: true,
|
|
2341
|
+
meta
|
|
2342
|
+
};
|
|
2324
2343
|
}
|
|
2325
2344
|
getVariableForExportName(name) {
|
|
2326
2345
|
let declaration = this.declarations[name];
|
|
@@ -2385,7 +2404,7 @@ function markModuleAndImpureDependenciesAsExecuted(baseModule) {
|
|
|
2385
2404
|
for (const dependency of [...module.dependencies, ...module.implicitlyLoadedBefore]) {
|
|
2386
2405
|
if (!(dependency instanceof ExternalModule) &&
|
|
2387
2406
|
!dependency.isExecuted &&
|
|
2388
|
-
(dependency.
|
|
2407
|
+
(dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
|
|
2389
2408
|
!visitedModules.has(dependency.id)) {
|
|
2390
2409
|
dependency.isExecuted = true;
|
|
2391
2410
|
visitedModules.add(dependency.id);
|
|
@@ -2742,6 +2761,7 @@ const INCLUDE_PARAMETERS = 'variables';
|
|
|
2742
2761
|
class NodeBase {
|
|
2743
2762
|
constructor(esTreeNode, parent, parentScope) {
|
|
2744
2763
|
this.included = false;
|
|
2764
|
+
this.esTreeNode = esTreeNode;
|
|
2745
2765
|
this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
|
|
2746
2766
|
this.parent = parent;
|
|
2747
2767
|
this.context = parent.context;
|
|
@@ -3140,10 +3160,6 @@ function isReference(node, parent) {
|
|
|
3140
3160
|
return false;
|
|
3141
3161
|
}
|
|
3142
3162
|
|
|
3143
|
-
const BLANK = Object.freeze(Object.create(null));
|
|
3144
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
3145
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
3146
|
-
|
|
3147
3163
|
const ValueProperties = Symbol('Value Properties');
|
|
3148
3164
|
const PURE = { pure: true };
|
|
3149
3165
|
const IMPURE = { pure: false };
|
|
@@ -4606,9 +4622,6 @@ const getPropertyAccess = (name) => {
|
|
|
4606
4622
|
: `[${JSON.stringify(name)}]`;
|
|
4607
4623
|
};
|
|
4608
4624
|
|
|
4609
|
-
const esModuleExport = `Object.defineProperty(exports, '__esModule', { value: true });`;
|
|
4610
|
-
const compactEsModuleExport = `Object.defineProperty(exports,'__esModule',{value:true});`;
|
|
4611
|
-
|
|
4612
4625
|
const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
|
|
4613
4626
|
const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
|
|
4614
4627
|
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
@@ -4641,9 +4654,9 @@ function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
|
4641
4654
|
function getDefaultOnlyHelper() {
|
|
4642
4655
|
return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
|
|
4643
4656
|
}
|
|
4644
|
-
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze) {
|
|
4657
|
+
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
|
|
4645
4658
|
return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
|
|
4646
|
-
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, usedHelpers)
|
|
4659
|
+
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
|
|
4647
4660
|
: '').join('');
|
|
4648
4661
|
}
|
|
4649
4662
|
const HELPER_GENERATORS = {
|
|
@@ -4653,17 +4666,17 @@ const HELPER_GENERATORS = {
|
|
|
4653
4666
|
[INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
4654
4667
|
`e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
|
|
4655
4668
|
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
4656
|
-
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
4669
|
+
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
4657
4670
|
(usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
|
|
4658
4671
|
? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
|
|
4659
4672
|
: `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
|
|
4660
|
-
createNamespaceObject(_, n, t, t, liveBindings, freeze)) +
|
|
4673
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
|
|
4661
4674
|
`}${n}${n}`,
|
|
4662
|
-
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
4663
|
-
createNamespaceObject(_, n, t, t, liveBindings, freeze) +
|
|
4675
|
+
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
4676
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
4664
4677
|
`}${n}${n}`,
|
|
4665
|
-
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
4666
|
-
`${t}return ${getFrozen(`{__proto__: null,${_}'default':${_}e}`, freeze)};${n}` +
|
|
4678
|
+
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
4679
|
+
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
4667
4680
|
`}${n}${n}`
|
|
4668
4681
|
};
|
|
4669
4682
|
function getDefaultLiveBinding(_) {
|
|
@@ -4672,8 +4685,10 @@ function getDefaultLiveBinding(_) {
|
|
|
4672
4685
|
function getDefaultStatic(_) {
|
|
4673
4686
|
return `e['default']${_}:${_}e`;
|
|
4674
4687
|
}
|
|
4675
|
-
function createNamespaceObject(_, n, t, i, liveBindings, freeze) {
|
|
4676
|
-
return (`${i}var n${_}=${_}
|
|
4688
|
+
function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
|
|
4689
|
+
return (`${i}var n${_}=${_}${namespaceToStringTag
|
|
4690
|
+
? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
|
|
4691
|
+
: 'Object.create(null)'};${n}` +
|
|
4677
4692
|
`${i}if${_}(e)${_}{${n}` +
|
|
4678
4693
|
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
4679
4694
|
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
@@ -4799,8 +4814,29 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
|
|
|
4799
4814
|
}
|
|
4800
4815
|
return `${moduleVariableName}.${imported}`;
|
|
4801
4816
|
}
|
|
4817
|
+
function getEsModuleExport(_) {
|
|
4818
|
+
return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
|
|
4819
|
+
}
|
|
4820
|
+
function getNamespaceToStringExport(_) {
|
|
4821
|
+
return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
|
|
4822
|
+
}
|
|
4823
|
+
function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
|
|
4824
|
+
let namespaceMarkers = '';
|
|
4825
|
+
if (hasNamedExports) {
|
|
4826
|
+
if (addEsModule) {
|
|
4827
|
+
namespaceMarkers += getEsModuleExport(_);
|
|
4828
|
+
}
|
|
4829
|
+
if (addNamespaceToStringTag) {
|
|
4830
|
+
if (namespaceMarkers) {
|
|
4831
|
+
namespaceMarkers += n;
|
|
4832
|
+
}
|
|
4833
|
+
namespaceMarkers += getNamespaceToStringExport(_);
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
return namespaceMarkers;
|
|
4837
|
+
}
|
|
4802
4838
|
|
|
4803
|
-
function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t) {
|
|
4839
|
+
function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t) {
|
|
4804
4840
|
const neededInteropHelpers = new Set();
|
|
4805
4841
|
const interopStatements = [];
|
|
4806
4842
|
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
@@ -4853,7 +4889,7 @@ function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings
|
|
|
4853
4889
|
}
|
|
4854
4890
|
}
|
|
4855
4891
|
}
|
|
4856
|
-
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4892
|
+
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4857
4893
|
}
|
|
4858
4894
|
|
|
4859
4895
|
const builtins$1 = {
|
|
@@ -4905,7 +4941,7 @@ function removeExtensionFromRelativeAmdId(id) {
|
|
|
4905
4941
|
}
|
|
4906
4942
|
return id;
|
|
4907
4943
|
}
|
|
4908
|
-
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro,
|
|
4944
|
+
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 }) {
|
|
4909
4945
|
warnOnBuiltins(warn, dependencies);
|
|
4910
4946
|
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
4911
4947
|
const args = dependencies.map(m => m.name);
|
|
@@ -4926,31 +4962,31 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
4926
4962
|
}
|
|
4927
4963
|
const params = (amdId ? `'${amdId}',${_}` : ``) + (deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
4928
4964
|
const useStrict = strict ? `${_}'use strict';` : '';
|
|
4929
|
-
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t)}`);
|
|
4965
|
+
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
4930
4966
|
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
magicString.append(outro);
|
|
4967
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
4968
|
+
if (namespaceMarkers) {
|
|
4969
|
+
namespaceMarkers = n + n + namespaceMarkers;
|
|
4970
|
+
}
|
|
4971
|
+
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
4937
4972
|
return magicString
|
|
4938
4973
|
.indent(t)
|
|
4939
4974
|
.prepend(`${amdDefine}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
4940
4975
|
.append(`${n}${n}});`);
|
|
4941
4976
|
}
|
|
4942
4977
|
|
|
4943
|
-
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro,
|
|
4978
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
4944
4979
|
const n = compact ? '' : '\n';
|
|
4945
4980
|
const s = compact ? '' : ';';
|
|
4946
4981
|
const _ = compact ? '' : ' ';
|
|
4947
4982
|
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4983
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
4984
|
+
if (namespaceMarkers) {
|
|
4985
|
+
namespaceMarkers += n + n;
|
|
4986
|
+
}
|
|
4951
4987
|
const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
|
|
4952
|
-
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t);
|
|
4953
|
-
magicString.prepend(`${useStrict}${intro}${
|
|
4988
|
+
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
4989
|
+
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
4954
4990
|
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
4955
4991
|
return magicString.append(`${exportBlock}${outro}`);
|
|
4956
4992
|
}
|
|
@@ -5492,7 +5528,7 @@ function trimEmptyImports(dependencies) {
|
|
|
5492
5528
|
}
|
|
5493
5529
|
|
|
5494
5530
|
const thisProp = (name) => `this${keypath(name)}`;
|
|
5495
|
-
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { compact, extend, freeze, externalLiveBindings, globals, interop, name, strict }) {
|
|
5531
|
+
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, namedExportsMode, outro, varOrConst, warn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
|
|
5496
5532
|
const _ = compact ? '' : ' ';
|
|
5497
5533
|
const s = compact ? '' : ';';
|
|
5498
5534
|
const n = compact ? '' : '\n';
|
|
@@ -5525,7 +5561,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
5525
5561
|
}
|
|
5526
5562
|
}
|
|
5527
5563
|
const useStrict = strict ? `${t}'use strict';${n}` : '';
|
|
5528
|
-
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t);
|
|
5564
|
+
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
5529
5565
|
magicString.prepend(`${intro}${interopBlock}`);
|
|
5530
5566
|
let wrapperIntro = `(function${_}(${args.join(`,${_}`)})${_}{${n}${useStrict}${n}`;
|
|
5531
5567
|
if (hasExports) {
|
|
@@ -5543,7 +5579,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
5543
5579
|
wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
|
|
5544
5580
|
}
|
|
5545
5581
|
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
5546
|
-
|
|
5582
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
|
|
5583
|
+
if (namespaceMarkers) {
|
|
5584
|
+
namespaceMarkers = n + n + namespaceMarkers;
|
|
5585
|
+
}
|
|
5586
|
+
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
5547
5587
|
return magicString.indent(t).prepend(wrapperIntro).append(wrapperOutro);
|
|
5548
5588
|
}
|
|
5549
5589
|
|
|
@@ -5703,7 +5743,7 @@ function safeAccess(name, globalVar, _) {
|
|
|
5703
5743
|
let acc = globalVar;
|
|
5704
5744
|
return parts.map(part => (acc += property(part))).join(`${_}&&${_}`);
|
|
5705
5745
|
}
|
|
5706
|
-
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 }) {
|
|
5746
|
+
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 }) {
|
|
5707
5747
|
const _ = compact ? '' : ' ';
|
|
5708
5748
|
const n = compact ? '' : '\n';
|
|
5709
5749
|
const s = compact ? '' : ';';
|
|
@@ -5776,14 +5816,13 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
5776
5816
|
`${t}${iifeStart}${iifeExport}${iifeEnd};${n}` +
|
|
5777
5817
|
`}(${globalArg}(function${_}(${factoryArgs.join(', ')})${_}{${useStrict}${n}`;
|
|
5778
5818
|
const wrapperOutro = n + n + '})));';
|
|
5779
|
-
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, accessedGlobals, _, n, s, t)}`);
|
|
5819
|
+
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
5780
5820
|
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
magicString.append(outro);
|
|
5821
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
|
|
5822
|
+
if (namespaceMarkers) {
|
|
5823
|
+
namespaceMarkers = n + n + namespaceMarkers;
|
|
5824
|
+
}
|
|
5825
|
+
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
5787
5826
|
return magicString.trim().indent(t).append(wrapperOutro).prepend(wrapperIntro);
|
|
5788
5827
|
}
|
|
5789
5828
|
|
|
@@ -9580,7 +9619,7 @@ function initialiseTimers(inputOptions) {
|
|
|
9580
9619
|
|
|
9581
9620
|
function tryParse(module, Parser, acornOptions) {
|
|
9582
9621
|
try {
|
|
9583
|
-
return Parser.parse(module.code, {
|
|
9622
|
+
return Parser.parse(module.info.code, {
|
|
9584
9623
|
...acornOptions,
|
|
9585
9624
|
onComment: (block, text, start, end) => module.comments.push({ block, text, start, end })
|
|
9586
9625
|
});
|
|
@@ -9625,14 +9664,12 @@ function getVariableForExportNameRecursive(target, name, isExportAllSearch, sear
|
|
|
9625
9664
|
return target.getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules);
|
|
9626
9665
|
}
|
|
9627
9666
|
class Module {
|
|
9628
|
-
constructor(graph, id, options,
|
|
9667
|
+
constructor(graph, id, options, isEntry, hasModuleSideEffects, syntheticNamedExports, meta) {
|
|
9629
9668
|
this.graph = graph;
|
|
9630
9669
|
this.id = id;
|
|
9631
9670
|
this.options = options;
|
|
9632
|
-
this.isEntryPoint = isEntryPoint;
|
|
9633
|
-
this.moduleSideEffects = moduleSideEffects;
|
|
9634
9671
|
this.syntheticNamedExports = syntheticNamedExports;
|
|
9635
|
-
this.
|
|
9672
|
+
this.ast = null;
|
|
9636
9673
|
this.chunkFileNames = new Set();
|
|
9637
9674
|
this.chunkName = null;
|
|
9638
9675
|
this.comments = [];
|
|
@@ -9669,6 +9706,40 @@ class Module {
|
|
|
9669
9706
|
this.transitiveReexports = null;
|
|
9670
9707
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
9671
9708
|
this.context = options.moduleContext(id);
|
|
9709
|
+
const module = this;
|
|
9710
|
+
this.info = {
|
|
9711
|
+
ast: null,
|
|
9712
|
+
code: null,
|
|
9713
|
+
get dynamicallyImportedIds() {
|
|
9714
|
+
const dynamicallyImportedIds = [];
|
|
9715
|
+
for (const { resolution } of module.dynamicImports) {
|
|
9716
|
+
if (resolution instanceof Module || resolution instanceof ExternalModule) {
|
|
9717
|
+
dynamicallyImportedIds.push(resolution.id);
|
|
9718
|
+
}
|
|
9719
|
+
}
|
|
9720
|
+
return dynamicallyImportedIds;
|
|
9721
|
+
},
|
|
9722
|
+
get dynamicImporters() {
|
|
9723
|
+
return module.dynamicImporters.sort();
|
|
9724
|
+
},
|
|
9725
|
+
hasModuleSideEffects,
|
|
9726
|
+
id,
|
|
9727
|
+
get implicitlyLoadedAfterOneOf() {
|
|
9728
|
+
return Array.from(module.implicitlyLoadedAfter, getId);
|
|
9729
|
+
},
|
|
9730
|
+
get implicitlyLoadedBefore() {
|
|
9731
|
+
return Array.from(module.implicitlyLoadedBefore, getId);
|
|
9732
|
+
},
|
|
9733
|
+
get importedIds() {
|
|
9734
|
+
return Array.from(module.sources, source => module.resolvedIds[source].id);
|
|
9735
|
+
},
|
|
9736
|
+
get importers() {
|
|
9737
|
+
return module.importers.sort();
|
|
9738
|
+
},
|
|
9739
|
+
isEntry,
|
|
9740
|
+
isExternal: false,
|
|
9741
|
+
meta
|
|
9742
|
+
};
|
|
9672
9743
|
}
|
|
9673
9744
|
basename() {
|
|
9674
9745
|
const base = basename(this.id);
|
|
@@ -9712,7 +9783,7 @@ class Module {
|
|
|
9712
9783
|
const additionalSideEffectModules = new Set();
|
|
9713
9784
|
const possibleDependencies = new Set(this.dependencies);
|
|
9714
9785
|
let dependencyVariables = this.imports;
|
|
9715
|
-
if (this.
|
|
9786
|
+
if (this.info.isEntry ||
|
|
9716
9787
|
this.includedDynamicImporters.length > 0 ||
|
|
9717
9788
|
this.namespace.included ||
|
|
9718
9789
|
this.implicitlyLoadedAfter.size > 0) {
|
|
@@ -9735,9 +9806,10 @@ class Module {
|
|
|
9735
9806
|
}
|
|
9736
9807
|
relevantDependencies.add(variable.module);
|
|
9737
9808
|
}
|
|
9738
|
-
if (this.options.treeshake && this.
|
|
9809
|
+
if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') {
|
|
9739
9810
|
for (const dependency of possibleDependencies) {
|
|
9740
|
-
if (!(dependency.
|
|
9811
|
+
if (!(dependency.info.hasModuleSideEffects ||
|
|
9812
|
+
additionalSideEffectModules.has(dependency)) ||
|
|
9741
9813
|
relevantDependencies.has(dependency)) {
|
|
9742
9814
|
continue;
|
|
9743
9815
|
}
|
|
@@ -9892,7 +9964,7 @@ class Module {
|
|
|
9892
9964
|
return null;
|
|
9893
9965
|
}
|
|
9894
9966
|
hasEffects() {
|
|
9895
|
-
return (this.
|
|
9967
|
+
return (this.info.hasModuleSideEffects === 'no-treeshake' ||
|
|
9896
9968
|
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
9897
9969
|
}
|
|
9898
9970
|
include() {
|
|
@@ -9970,7 +10042,7 @@ class Module {
|
|
|
9970
10042
|
return magicString;
|
|
9971
10043
|
}
|
|
9972
10044
|
setSource({ alwaysRemovedCode, ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
|
|
9973
|
-
this.code = code;
|
|
10045
|
+
this.info.code = code;
|
|
9974
10046
|
this.originalCode = originalCode;
|
|
9975
10047
|
this.originalSourcemap = originalSourcemap;
|
|
9976
10048
|
this.sourcemapChain = sourcemapChain;
|
|
@@ -9982,17 +10054,14 @@ class Module {
|
|
|
9982
10054
|
this.updateOptions(moduleOptions);
|
|
9983
10055
|
timeStart('generate ast', 3);
|
|
9984
10056
|
this.alwaysRemovedCode = alwaysRemovedCode || [];
|
|
9985
|
-
if (ast) {
|
|
9986
|
-
this.
|
|
9987
|
-
}
|
|
9988
|
-
else {
|
|
9989
|
-
this.esTreeAst = tryParse(this, this.graph.acornParser, this.options.acorn);
|
|
10057
|
+
if (!ast) {
|
|
10058
|
+
ast = tryParse(this, this.graph.acornParser, this.options.acorn);
|
|
9990
10059
|
for (const comment of this.comments) {
|
|
9991
10060
|
if (!comment.block && SOURCEMAPPING_URL_RE.test(comment.text)) {
|
|
9992
10061
|
this.alwaysRemovedCode.push([comment.start, comment.end]);
|
|
9993
10062
|
}
|
|
9994
10063
|
}
|
|
9995
|
-
markPureCallExpressions(this.comments,
|
|
10064
|
+
markPureCallExpressions(this.comments, ast);
|
|
9996
10065
|
}
|
|
9997
10066
|
timeEnd('generate ast', 3);
|
|
9998
10067
|
this.resolvedIds = resolvedIds || Object.create(null);
|
|
@@ -10036,19 +10105,20 @@ class Module {
|
|
|
10036
10105
|
};
|
|
10037
10106
|
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
10038
10107
|
this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
|
|
10039
|
-
this.ast = new Program$1(
|
|
10108
|
+
this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
|
|
10109
|
+
this.info.ast = ast;
|
|
10040
10110
|
timeEnd('analyse ast', 3);
|
|
10041
10111
|
}
|
|
10042
10112
|
toJSON() {
|
|
10043
10113
|
return {
|
|
10044
10114
|
alwaysRemovedCode: this.alwaysRemovedCode,
|
|
10045
|
-
ast: this.
|
|
10046
|
-
code: this.code,
|
|
10115
|
+
ast: this.ast.esTreeNode,
|
|
10116
|
+
code: this.info.code,
|
|
10047
10117
|
customTransformCache: this.customTransformCache,
|
|
10048
10118
|
dependencies: Array.from(this.dependencies, getId),
|
|
10049
10119
|
id: this.id,
|
|
10050
|
-
meta: this.meta,
|
|
10051
|
-
moduleSideEffects: this.
|
|
10120
|
+
meta: this.info.meta,
|
|
10121
|
+
moduleSideEffects: this.info.hasModuleSideEffects,
|
|
10052
10122
|
originalCode: this.originalCode,
|
|
10053
10123
|
originalSourcemap: this.originalSourcemap,
|
|
10054
10124
|
resolvedIds: this.resolvedIds,
|
|
@@ -10079,13 +10149,13 @@ class Module {
|
|
|
10079
10149
|
}
|
|
10080
10150
|
updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
|
|
10081
10151
|
if (moduleSideEffects != null) {
|
|
10082
|
-
this.
|
|
10152
|
+
this.info.hasModuleSideEffects = moduleSideEffects;
|
|
10083
10153
|
}
|
|
10084
10154
|
if (syntheticNamedExports != null) {
|
|
10085
10155
|
this.syntheticNamedExports = syntheticNamedExports;
|
|
10086
10156
|
}
|
|
10087
10157
|
if (meta != null) {
|
|
10088
|
-
this.meta = { ...this.meta, ...meta };
|
|
10158
|
+
this.info.meta = { ...this.info.meta, ...meta };
|
|
10089
10159
|
}
|
|
10090
10160
|
}
|
|
10091
10161
|
warn(props, pos) {
|
|
@@ -10195,7 +10265,7 @@ class Module {
|
|
|
10195
10265
|
addLocationToLogProps(props, pos) {
|
|
10196
10266
|
props.id = this.id;
|
|
10197
10267
|
props.pos = pos;
|
|
10198
|
-
let code = this.code;
|
|
10268
|
+
let code = this.info.code;
|
|
10199
10269
|
let { column, line } = locate(code, pos, { offsetLine: 1 });
|
|
10200
10270
|
try {
|
|
10201
10271
|
({ column, line } = getOriginalLocation(this.sourcemapChain, { column, line }));
|
|
@@ -10392,7 +10462,6 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
|
|
|
10392
10462
|
else {
|
|
10393
10463
|
const sources = originalSourcemap.sources;
|
|
10394
10464
|
const sourcesContent = originalSourcemap.sourcesContent || [];
|
|
10395
|
-
// TODO indiscriminately treating IDs and sources as normal paths is probably bad.
|
|
10396
10465
|
const directory = dirname(id) || '.';
|
|
10397
10466
|
const sourceRoot = originalSourcemap.sourceRoot || '.';
|
|
10398
10467
|
const baseSources = sources.map((source, i) => new Source(resolve(directory, sourceRoot, source), sourcesContent[i]));
|
|
@@ -10846,7 +10915,7 @@ class Chunk$1 {
|
|
|
10846
10915
|
if (this.isEmpty && module.isIncluded()) {
|
|
10847
10916
|
this.isEmpty = false;
|
|
10848
10917
|
}
|
|
10849
|
-
if (module.
|
|
10918
|
+
if (module.info.isEntry || outputOptions.preserveModules) {
|
|
10850
10919
|
this.entryModules.push(module);
|
|
10851
10920
|
}
|
|
10852
10921
|
for (const importer of module.includedDynamicImporters) {
|
|
@@ -10875,7 +10944,7 @@ class Chunk$1 {
|
|
|
10875
10944
|
chunk.dependencies.add(dependency instanceof Module ? chunkByModule.get(dependency) : dependency);
|
|
10876
10945
|
}
|
|
10877
10946
|
if (!chunk.dependencies.has(chunkByModule.get(facadedModule)) &&
|
|
10878
|
-
facadedModule.
|
|
10947
|
+
facadedModule.info.hasModuleSideEffects &&
|
|
10879
10948
|
facadedModule.hasEffects()) {
|
|
10880
10949
|
chunk.dependencies.add(chunkByModule.get(facadedModule));
|
|
10881
10950
|
}
|
|
@@ -10929,7 +10998,7 @@ class Chunk$1 {
|
|
|
10929
10998
|
else {
|
|
10930
10999
|
assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
|
|
10931
11000
|
}
|
|
10932
|
-
if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.
|
|
11001
|
+
if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
|
|
10933
11002
|
this.exportMode = getExportMode(this, this.outputOptions, this.unsetOptions, this.facadeModule.id, this.inputOptions.onwarn);
|
|
10934
11003
|
}
|
|
10935
11004
|
generateFacades() {
|
|
@@ -10955,17 +11024,21 @@ class Chunk$1 {
|
|
|
10955
11024
|
if (requiredFacades.length === 0) {
|
|
10956
11025
|
requiredFacades.push({});
|
|
10957
11026
|
}
|
|
10958
|
-
if (!this.facadeModule
|
|
10959
|
-
|
|
10960
|
-
module.preserveSignature
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
this.
|
|
10966
|
-
this.
|
|
11027
|
+
if (!this.facadeModule) {
|
|
11028
|
+
const needsStrictFacade = module.preserveSignature === 'strict' ||
|
|
11029
|
+
(module.preserveSignature === 'exports-only' &&
|
|
11030
|
+
module.getExportNamesByVariable().size !== 0);
|
|
11031
|
+
if (!needsStrictFacade ||
|
|
11032
|
+
this.outputOptions.preserveModules ||
|
|
11033
|
+
this.canModuleBeFacade(module, exposedVariables)) {
|
|
11034
|
+
this.facadeModule = module;
|
|
11035
|
+
this.facadeChunkByModule.set(module, this);
|
|
11036
|
+
if (module.preserveSignature) {
|
|
11037
|
+
this.strictFacade = needsStrictFacade;
|
|
11038
|
+
this.ensureReexportsAreAvailableForModule(module);
|
|
11039
|
+
}
|
|
11040
|
+
this.assignFacadeName(requiredFacades.shift(), module);
|
|
10967
11041
|
}
|
|
10968
|
-
this.assignFacadeName(requiredFacades.shift(), module);
|
|
10969
11042
|
}
|
|
10970
11043
|
for (const facadeName of requiredFacades) {
|
|
10971
11044
|
facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
|
|
@@ -11046,7 +11119,7 @@ class Chunk$1 {
|
|
|
11046
11119
|
exports: this.getExportNames(),
|
|
11047
11120
|
facadeModuleId: facadeModule && facadeModule.id,
|
|
11048
11121
|
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
11049
|
-
isEntry: facadeModule !== null && facadeModule.
|
|
11122
|
+
isEntry: facadeModule !== null && facadeModule.info.isEntry,
|
|
11050
11123
|
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
11051
11124
|
modules: this.renderedModules,
|
|
11052
11125
|
get name() {
|
|
@@ -11248,8 +11321,9 @@ class Chunk$1 {
|
|
|
11248
11321
|
hasExports,
|
|
11249
11322
|
indentString: this.indentString,
|
|
11250
11323
|
intro: addons.intro,
|
|
11251
|
-
|
|
11252
|
-
(this.facadeModule !== null && this.facadeModule.
|
|
11324
|
+
isEntryFacade: this.outputOptions.preserveModules ||
|
|
11325
|
+
(this.facadeModule !== null && this.facadeModule.info.isEntry),
|
|
11326
|
+
isModuleFacade: this.facadeModule !== null,
|
|
11253
11327
|
namedExportsMode: this.exportMode !== 'default',
|
|
11254
11328
|
outro: addons.outro,
|
|
11255
11329
|
usesTopLevelAwait,
|
|
@@ -11750,7 +11824,7 @@ class Chunk$1 {
|
|
|
11750
11824
|
}
|
|
11751
11825
|
}
|
|
11752
11826
|
if (this.includedNamespaces.has(module) ||
|
|
11753
|
-
(module.
|
|
11827
|
+
(module.info.isEntry && module.preserveSignature !== false) ||
|
|
11754
11828
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
11755
11829
|
this.ensureReexportsAreAvailableForModule(module);
|
|
11756
11830
|
}
|
|
@@ -12379,7 +12453,7 @@ function validateOptionsForMultiChunkOutput(outputOptions) {
|
|
|
12379
12453
|
}
|
|
12380
12454
|
function getIncludedModules(modulesById) {
|
|
12381
12455
|
return [...modulesById.values()].filter(module => module instanceof Module &&
|
|
12382
|
-
(module.isIncluded() || module.
|
|
12456
|
+
(module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0));
|
|
12383
12457
|
}
|
|
12384
12458
|
function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
12385
12459
|
const existingAlias = manualChunkAliasByEntry.get(module);
|
|
@@ -18001,7 +18075,7 @@ function transform(source, module, pluginDriver, warn) {
|
|
|
18001
18075
|
ast,
|
|
18002
18076
|
code,
|
|
18003
18077
|
customTransformCache,
|
|
18004
|
-
meta: module.meta,
|
|
18078
|
+
meta: module.info.meta,
|
|
18005
18079
|
originalCode,
|
|
18006
18080
|
originalSourcemap,
|
|
18007
18081
|
sourcemapChain,
|
|
@@ -18095,7 +18169,7 @@ class ModuleLoader {
|
|
|
18095
18169
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
18096
18170
|
return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then(async (entryModule) => {
|
|
18097
18171
|
addChunkNamesToModule(entryModule, unresolvedModule, false);
|
|
18098
|
-
if (!entryModule.
|
|
18172
|
+
if (!entryModule.info.isEntry) {
|
|
18099
18173
|
this.implicitEntryModules.add(entryModule);
|
|
18100
18174
|
const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id)));
|
|
18101
18175
|
for (const module of implicitlyLoadedAfterModules) {
|
|
@@ -18164,7 +18238,9 @@ class ModuleLoader {
|
|
|
18164
18238
|
}
|
|
18165
18239
|
async fetchDynamicDependencies(module) {
|
|
18166
18240
|
const dependencies = await Promise.all(module.dynamicImports.map(async (dynamicImport) => {
|
|
18167
|
-
const resolvedId = await this.resolveDynamicImport(module, dynamicImport.argument
|
|
18241
|
+
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
18242
|
+
? dynamicImport.argument
|
|
18243
|
+
: dynamicImport.argument.esTreeNode, module.id);
|
|
18168
18244
|
if (resolvedId === null)
|
|
18169
18245
|
return null;
|
|
18170
18246
|
if (typeof resolvedId === 'string') {
|
|
@@ -18184,7 +18260,7 @@ class ModuleLoader {
|
|
|
18184
18260
|
const existingModule = this.modulesById.get(id);
|
|
18185
18261
|
if (existingModule instanceof Module) {
|
|
18186
18262
|
if (isEntry) {
|
|
18187
|
-
existingModule.
|
|
18263
|
+
existingModule.info.isEntry = true;
|
|
18188
18264
|
this.implicitEntryModules.delete(existingModule);
|
|
18189
18265
|
for (const dependant of existingModule.implicitlyLoadedAfter) {
|
|
18190
18266
|
dependant.implicitlyLoadedBefore.delete(existingModule);
|
|
@@ -18197,6 +18273,7 @@ class ModuleLoader {
|
|
|
18197
18273
|
this.modulesById.set(id, module);
|
|
18198
18274
|
this.graph.watchFiles[id] = true;
|
|
18199
18275
|
await this.addModuleSource(id, importer, module);
|
|
18276
|
+
await this.pluginDriver.hookParallel('moduleParsed', [module.info]);
|
|
18200
18277
|
await Promise.all([
|
|
18201
18278
|
this.fetchStaticDependencies(module),
|
|
18202
18279
|
this.fetchDynamicDependencies(module)
|
|
@@ -18287,7 +18364,6 @@ class ModuleLoader {
|
|
|
18287
18364
|
return this.fetchModule(this.addDefaultsToResolvedId(typeof resolveIdResult === 'object' ? resolveIdResult : { id: resolveIdResult }), undefined, isEntry);
|
|
18288
18365
|
}
|
|
18289
18366
|
async resolveDynamicImport(module, specifier, importer) {
|
|
18290
|
-
// TODO we only should expose the acorn AST here
|
|
18291
18367
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
18292
18368
|
specifier,
|
|
18293
18369
|
importer
|
|
@@ -18433,6 +18509,7 @@ const inputHookNames = {
|
|
|
18433
18509
|
buildEnd: 1,
|
|
18434
18510
|
buildStart: 1,
|
|
18435
18511
|
load: 1,
|
|
18512
|
+
moduleParsed: 1,
|
|
18436
18513
|
options: 1,
|
|
18437
18514
|
resolveDynamicImport: 1,
|
|
18438
18515
|
resolveId: 1,
|
|
@@ -18650,47 +18727,7 @@ class Graph {
|
|
|
18650
18727
|
const foundModule = this.modulesById.get(moduleId);
|
|
18651
18728
|
if (!foundModule)
|
|
18652
18729
|
return null;
|
|
18653
|
-
return
|
|
18654
|
-
get dynamicallyImportedIds() {
|
|
18655
|
-
if (foundModule instanceof Module) {
|
|
18656
|
-
const dynamicallyImportedIds = [];
|
|
18657
|
-
for (const { resolution } of foundModule.dynamicImports) {
|
|
18658
|
-
if (resolution instanceof Module || resolution instanceof ExternalModule) {
|
|
18659
|
-
dynamicallyImportedIds.push(resolution.id);
|
|
18660
|
-
}
|
|
18661
|
-
}
|
|
18662
|
-
return dynamicallyImportedIds;
|
|
18663
|
-
}
|
|
18664
|
-
return EMPTY_ARRAY;
|
|
18665
|
-
},
|
|
18666
|
-
get dynamicImporters() {
|
|
18667
|
-
return foundModule.dynamicImporters.sort();
|
|
18668
|
-
},
|
|
18669
|
-
hasModuleSideEffects: foundModule.moduleSideEffects,
|
|
18670
|
-
id: foundModule.id,
|
|
18671
|
-
get implicitlyLoadedAfterOneOf() {
|
|
18672
|
-
return foundModule instanceof Module
|
|
18673
|
-
? Array.from(foundModule.implicitlyLoadedAfter, getId)
|
|
18674
|
-
: EMPTY_ARRAY;
|
|
18675
|
-
},
|
|
18676
|
-
get implicitlyLoadedBefore() {
|
|
18677
|
-
return foundModule instanceof Module
|
|
18678
|
-
? Array.from(foundModule.implicitlyLoadedBefore, getId)
|
|
18679
|
-
: [];
|
|
18680
|
-
},
|
|
18681
|
-
get importedIds() {
|
|
18682
|
-
if (foundModule instanceof Module) {
|
|
18683
|
-
return Array.from(foundModule.sources, source => foundModule.resolvedIds[source].id);
|
|
18684
|
-
}
|
|
18685
|
-
return EMPTY_ARRAY;
|
|
18686
|
-
},
|
|
18687
|
-
get importers() {
|
|
18688
|
-
return foundModule.importers.sort();
|
|
18689
|
-
},
|
|
18690
|
-
isEntry: foundModule instanceof Module && foundModule.isEntryPoint,
|
|
18691
|
-
isExternal: foundModule instanceof ExternalModule,
|
|
18692
|
-
meta: foundModule.meta
|
|
18693
|
-
};
|
|
18730
|
+
return foundModule.info;
|
|
18694
18731
|
};
|
|
18695
18732
|
this.deoptimizationTracker = new PathTracker();
|
|
18696
18733
|
this.cachedModules = new Map();
|
|
@@ -18789,7 +18826,7 @@ class Graph {
|
|
|
18789
18826
|
this.needsTreeshakingPass = false;
|
|
18790
18827
|
for (const module of this.modules) {
|
|
18791
18828
|
if (module.isExecuted) {
|
|
18792
|
-
if (module.
|
|
18829
|
+
if (module.info.hasModuleSideEffects === 'no-treeshake') {
|
|
18793
18830
|
module.includeAllInBundle();
|
|
18794
18831
|
}
|
|
18795
18832
|
else {
|
|
@@ -18808,7 +18845,7 @@ class Graph {
|
|
|
18808
18845
|
externalModule.warnUnusedImports();
|
|
18809
18846
|
for (const module of this.implicitEntryModules) {
|
|
18810
18847
|
for (const dependant of module.implicitlyLoadedAfter) {
|
|
18811
|
-
if (!(dependant.
|
|
18848
|
+
if (!(dependant.info.isEntry || dependant.isIncluded())) {
|
|
18812
18849
|
error(errImplicitDependantIsNotIncluded(dependant));
|
|
18813
18850
|
}
|
|
18814
18851
|
}
|