rollup 2.77.0 → 3.0.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +31 -2
- package/dist/bin/rollup +78 -72
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +1603 -1556
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +5 -4
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.d.ts +26 -55
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +126 -12
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +1542 -1495
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +2 -2
- package/package.json +13 -12
- package/CHANGELOG.md +0 -6671
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js
|
|
4
|
-
Fri, 15 Jul 2022
|
|
3
|
+
Rollup.js v3.0.0-2
|
|
4
|
+
Fri, 15 Jul 2022 15:25:15 GMT - commit 13b0ef8778ca5ccfd54b113ef545bf235a4c7e34
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version$1 = "
|
|
30
|
+
var version$1 = "3.0.0-2";
|
|
31
31
|
|
|
32
32
|
function ensureArray$1(items) {
|
|
33
33
|
if (Array.isArray(items)) {
|
|
@@ -215,6 +215,7 @@ function augmentCodeLocation(props, pos, source, id) {
|
|
|
215
215
|
}
|
|
216
216
|
var Errors;
|
|
217
217
|
(function (Errors) {
|
|
218
|
+
Errors["ADDON_ERROR"] = "ADDON_ERROR";
|
|
218
219
|
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
219
220
|
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
220
221
|
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
@@ -237,6 +238,7 @@ var Errors;
|
|
|
237
238
|
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
238
239
|
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
239
240
|
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
241
|
+
Errors["INVALID_TLA_FORMAT"] = "INVALID_TLA_FORMAT";
|
|
240
242
|
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
241
243
|
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
242
244
|
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
@@ -251,10 +253,17 @@ var Errors;
|
|
|
251
253
|
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
252
254
|
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
253
255
|
})(Errors || (Errors = {}));
|
|
256
|
+
function errAddonNotGenerated(message, hook, plugin) {
|
|
257
|
+
return {
|
|
258
|
+
code: Errors.ADDON_ERROR,
|
|
259
|
+
message: `Could not retrieve ${hook}. Check configuration of plugin ${plugin}.
|
|
260
|
+
\tError Message: ${message}`
|
|
261
|
+
};
|
|
262
|
+
}
|
|
254
263
|
function errAssetNotFinalisedForFileName(name) {
|
|
255
264
|
return {
|
|
256
265
|
code: Errors.ASSET_NOT_FINALISED,
|
|
257
|
-
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
266
|
+
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_<referenceId>, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.`
|
|
258
267
|
};
|
|
259
268
|
}
|
|
260
269
|
function errCannotEmitFromOptionsHook() {
|
|
@@ -266,7 +275,7 @@ function errCannotEmitFromOptionsHook() {
|
|
|
266
275
|
function errChunkNotGeneratedForFileName(name) {
|
|
267
276
|
return {
|
|
268
277
|
code: Errors.CHUNK_NOT_GENERATED,
|
|
269
|
-
message: `Plugin error - Unable to get file name for chunk "${name}".
|
|
278
|
+
message: `Plugin error - Unable to get file name for emitted chunk "${name}". You can only get file names once chunks have been generated after the "renderStart" hook.`
|
|
270
279
|
};
|
|
271
280
|
}
|
|
272
281
|
function errChunkInvalid({ fileName, code }, exception) {
|
|
@@ -385,6 +394,13 @@ function errInvalidRollupPhaseForChunkEmission() {
|
|
|
385
394
|
message: `Cannot emit chunks after module loading has finished.`
|
|
386
395
|
};
|
|
387
396
|
}
|
|
397
|
+
function errInvalidFormatForTopLevelAwait(id, format) {
|
|
398
|
+
return {
|
|
399
|
+
code: Errors.INVALID_TLA_FORMAT,
|
|
400
|
+
id,
|
|
401
|
+
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
402
|
+
};
|
|
403
|
+
}
|
|
388
404
|
function errMissingExport(exportName, importingModule, importedModule) {
|
|
389
405
|
return {
|
|
390
406
|
code: Errors.MISSING_EXPORT,
|
|
@@ -645,33 +661,6 @@ const fseventsImporter = /*#__PURE__*/Object.defineProperty({
|
|
|
645
661
|
getFsEvents
|
|
646
662
|
}, Symbol.toStringTag, { value: 'Module' });
|
|
647
663
|
|
|
648
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
649
|
-
|
|
650
|
-
function getDefaultExportFromCjs (x) {
|
|
651
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
function getAugmentedNamespace(n) {
|
|
655
|
-
var f = n.default;
|
|
656
|
-
if (typeof f == "function") {
|
|
657
|
-
var a = function () {
|
|
658
|
-
return f.apply(this, arguments);
|
|
659
|
-
};
|
|
660
|
-
a.prototype = f.prototype;
|
|
661
|
-
} else a = {};
|
|
662
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
663
|
-
Object.keys(n).forEach(function (k) {
|
|
664
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
665
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
666
|
-
enumerable: true,
|
|
667
|
-
get: function () {
|
|
668
|
-
return n[k];
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
return a;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
664
|
var charToInteger = {};
|
|
676
665
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
677
666
|
for (var i$1 = 0; i$1 < chars$1.length; i$1++) {
|
|
@@ -2144,6 +2133,43 @@ class Bundle$1 {
|
|
|
2144
2133
|
}
|
|
2145
2134
|
}
|
|
2146
2135
|
|
|
2136
|
+
const needsEscapeRegEx = /[\\'\r\n\u2028\u2029]/;
|
|
2137
|
+
const quoteNewlineRegEx = /(['\r\n\u2028\u2029])/g;
|
|
2138
|
+
const backSlashRegEx = /\\/g;
|
|
2139
|
+
function escapeId(id) {
|
|
2140
|
+
if (!id.match(needsEscapeRegEx))
|
|
2141
|
+
return id;
|
|
2142
|
+
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
class ExternalChunk {
|
|
2146
|
+
constructor(module, options, inputBase) {
|
|
2147
|
+
this.options = options;
|
|
2148
|
+
this.inputBase = inputBase;
|
|
2149
|
+
this.defaultVariableName = '';
|
|
2150
|
+
this.namespaceVariableName = '';
|
|
2151
|
+
this.variableName = '';
|
|
2152
|
+
this.fileName = null;
|
|
2153
|
+
this.id = module.id;
|
|
2154
|
+
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
2155
|
+
this.suggestedVariableName = module.suggestedVariableName;
|
|
2156
|
+
}
|
|
2157
|
+
getFileName() {
|
|
2158
|
+
if (this.fileName) {
|
|
2159
|
+
return this.fileName;
|
|
2160
|
+
}
|
|
2161
|
+
const { paths } = this.options;
|
|
2162
|
+
return (this.fileName =
|
|
2163
|
+
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
2164
|
+
(this.renormalizeRenderPath ? normalize(require$$0.relative(this.inputBase, this.id)) : this.id));
|
|
2165
|
+
}
|
|
2166
|
+
getImportPath(importer) {
|
|
2167
|
+
return escapeId(this.renormalizeRenderPath
|
|
2168
|
+
? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
|
|
2169
|
+
: this.getFileName());
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2147
2173
|
function getOrCreate(map, key, init) {
|
|
2148
2174
|
const existing = map.get(key);
|
|
2149
2175
|
if (existing) {
|
|
@@ -2428,19 +2454,15 @@ class ExternalModule {
|
|
|
2428
2454
|
this.options = options;
|
|
2429
2455
|
this.id = id;
|
|
2430
2456
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
2431
|
-
this.declarations = new Map();
|
|
2432
|
-
this.defaultVariableName = '';
|
|
2433
2457
|
this.dynamicImporters = [];
|
|
2434
2458
|
this.execIndex = Infinity;
|
|
2435
2459
|
this.exportedVariables = new Map();
|
|
2436
2460
|
this.importers = [];
|
|
2437
|
-
this.mostCommonSuggestion = 0;
|
|
2438
|
-
this.nameSuggestions = new Map();
|
|
2439
|
-
this.namespaceVariableName = '';
|
|
2440
2461
|
this.reexported = false;
|
|
2441
|
-
this.renderPath = undefined;
|
|
2442
2462
|
this.used = false;
|
|
2443
|
-
this.
|
|
2463
|
+
this.declarations = new Map();
|
|
2464
|
+
this.mostCommonSuggestion = 0;
|
|
2465
|
+
this.nameSuggestions = new Map();
|
|
2444
2466
|
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2445
2467
|
const { importers, dynamicImporters } = this;
|
|
2446
2468
|
const info = (this.info = {
|
|
@@ -2453,7 +2475,7 @@ class ExternalModule {
|
|
|
2453
2475
|
},
|
|
2454
2476
|
hasDefaultExport: null,
|
|
2455
2477
|
get hasModuleSideEffects() {
|
|
2456
|
-
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
|
|
2478
|
+
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
|
|
2457
2479
|
return info.moduleSideEffects;
|
|
2458
2480
|
},
|
|
2459
2481
|
id,
|
|
@@ -2485,15 +2507,6 @@ class ExternalModule {
|
|
|
2485
2507
|
this.exportedVariables.set(externalVariable, name);
|
|
2486
2508
|
return [externalVariable];
|
|
2487
2509
|
}
|
|
2488
|
-
setRenderPath(options, inputBase) {
|
|
2489
|
-
this.renderPath =
|
|
2490
|
-
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
2491
|
-
if (!this.renderPath) {
|
|
2492
|
-
this.renderPath = this.renormalizeRenderPath
|
|
2493
|
-
? normalize(require$$0.relative(inputBase, this.id))
|
|
2494
|
-
: this.id;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
2510
|
suggestName(name) {
|
|
2498
2511
|
var _a;
|
|
2499
2512
|
const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
@@ -2526,6 +2539,33 @@ class ExternalModule {
|
|
|
2526
2539
|
}
|
|
2527
2540
|
}
|
|
2528
2541
|
|
|
2542
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2543
|
+
|
|
2544
|
+
function getDefaultExportFromCjs (x) {
|
|
2545
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
function getAugmentedNamespace(n) {
|
|
2549
|
+
var f = n.default;
|
|
2550
|
+
if (typeof f == "function") {
|
|
2551
|
+
var a = function () {
|
|
2552
|
+
return f.apply(this, arguments);
|
|
2553
|
+
};
|
|
2554
|
+
a.prototype = f.prototype;
|
|
2555
|
+
} else a = {};
|
|
2556
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
2557
|
+
Object.keys(n).forEach(function (k) {
|
|
2558
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
2559
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
2560
|
+
enumerable: true,
|
|
2561
|
+
get: function () {
|
|
2562
|
+
return n[k];
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2565
|
+
});
|
|
2566
|
+
return a;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2529
2569
|
var picomatch$1 = {exports: {}};
|
|
2530
2570
|
|
|
2531
2571
|
var utils$3 = {};
|
|
@@ -10344,7 +10384,9 @@ class ImportExpression extends NodeBase {
|
|
|
10344
10384
|
super(...arguments);
|
|
10345
10385
|
this.inlineNamespace = null;
|
|
10346
10386
|
this.mechanism = null;
|
|
10387
|
+
this.namespaceExportName = undefined;
|
|
10347
10388
|
this.resolution = null;
|
|
10389
|
+
this.resolutionString = null;
|
|
10348
10390
|
}
|
|
10349
10391
|
hasEffects() {
|
|
10350
10392
|
return true;
|
|
@@ -10361,8 +10403,8 @@ class ImportExpression extends NodeBase {
|
|
|
10361
10403
|
this.context.addDynamicImport(this);
|
|
10362
10404
|
}
|
|
10363
10405
|
render(code, options) {
|
|
10406
|
+
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10364
10407
|
if (this.inlineNamespace) {
|
|
10365
|
-
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10366
10408
|
const [left, right] = getDirectReturnFunction([], {
|
|
10367
10409
|
functionReturn: true,
|
|
10368
10410
|
lineBreakIndent: null,
|
|
@@ -10375,22 +10417,26 @@ class ImportExpression extends NodeBase {
|
|
|
10375
10417
|
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
|
|
10376
10418
|
code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
|
|
10377
10419
|
}
|
|
10378
|
-
this.
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
}
|
|
10388
|
-
|
|
10420
|
+
if (this.resolutionString) {
|
|
10421
|
+
code.overwrite(this.source.start, this.source.end, this.resolutionString);
|
|
10422
|
+
if (this.namespaceExportName) {
|
|
10423
|
+
const [left, right] = getDirectReturnFunction(['n'], {
|
|
10424
|
+
functionReturn: true,
|
|
10425
|
+
lineBreakIndent: null,
|
|
10426
|
+
name: null
|
|
10427
|
+
});
|
|
10428
|
+
code.prependLeft(this.end, `.then(${left}n.${this.namespaceExportName}${right})`);
|
|
10429
|
+
}
|
|
10430
|
+
}
|
|
10431
|
+
else {
|
|
10432
|
+
this.source.render(code, options);
|
|
10389
10433
|
}
|
|
10390
10434
|
}
|
|
10391
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope) {
|
|
10435
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
|
|
10392
10436
|
const { format } = options;
|
|
10393
10437
|
this.resolution = resolution;
|
|
10438
|
+
this.resolutionString = resolutionString;
|
|
10439
|
+
this.namespaceExportName = namespaceExportName;
|
|
10394
10440
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
10395
10441
|
let helper;
|
|
10396
10442
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -10685,25 +10731,17 @@ class LogicalExpression extends NodeBase {
|
|
|
10685
10731
|
}
|
|
10686
10732
|
}
|
|
10687
10733
|
|
|
10688
|
-
const ASSET_PREFIX = 'ROLLUP_ASSET_URL_';
|
|
10689
|
-
const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_';
|
|
10690
10734
|
const FILE_PREFIX = 'ROLLUP_FILE_URL_';
|
|
10691
10735
|
class MetaProperty extends NodeBase {
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
metaProperty.startsWith(CHUNK_PREFIX))
|
|
10698
|
-
? accessedFileUrlGlobals
|
|
10699
|
-
: accessedMetaUrlGlobals)[format];
|
|
10700
|
-
if (accessedGlobals.length > 0) {
|
|
10701
|
-
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
10702
|
-
}
|
|
10736
|
+
constructor() {
|
|
10737
|
+
super(...arguments);
|
|
10738
|
+
this.metaProperty = null;
|
|
10739
|
+
this.preliminaryChunkId = null;
|
|
10740
|
+
this.referenceId = null;
|
|
10703
10741
|
}
|
|
10704
10742
|
getReferencedFileName(outputPluginDriver) {
|
|
10705
|
-
const metaProperty = this
|
|
10706
|
-
if (metaProperty
|
|
10743
|
+
const { metaProperty } = this;
|
|
10744
|
+
if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
|
|
10707
10745
|
return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
|
|
10708
10746
|
}
|
|
10709
10747
|
return null;
|
|
@@ -10720,71 +10758,37 @@ class MetaProperty extends NodeBase {
|
|
|
10720
10758
|
if (this.meta.name === 'import') {
|
|
10721
10759
|
this.context.addImportMeta(this);
|
|
10722
10760
|
const parent = this.parent;
|
|
10723
|
-
this.metaProperty =
|
|
10761
|
+
const metaProperty = (this.metaProperty =
|
|
10724
10762
|
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
10725
10763
|
? parent.propertyKey
|
|
10726
|
-
: null;
|
|
10764
|
+
: null);
|
|
10765
|
+
if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
|
|
10766
|
+
this.referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
10767
|
+
}
|
|
10727
10768
|
}
|
|
10728
10769
|
}
|
|
10729
10770
|
}
|
|
10730
|
-
|
|
10771
|
+
render(code, { format, pluginDriver, snippets }) {
|
|
10731
10772
|
var _a;
|
|
10732
|
-
const parent = this
|
|
10733
|
-
const
|
|
10734
|
-
if (
|
|
10735
|
-
|
|
10736
|
-
metaProperty.startsWith(ASSET_PREFIX) ||
|
|
10737
|
-
metaProperty.startsWith(CHUNK_PREFIX))) {
|
|
10738
|
-
let referenceId = null;
|
|
10739
|
-
let assetReferenceId = null;
|
|
10740
|
-
let chunkReferenceId = null;
|
|
10741
|
-
let fileName;
|
|
10742
|
-
if (metaProperty.startsWith(FILE_PREFIX)) {
|
|
10743
|
-
referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
10744
|
-
fileName = outputPluginDriver.getFileName(referenceId);
|
|
10745
|
-
}
|
|
10746
|
-
else if (metaProperty.startsWith(ASSET_PREFIX)) {
|
|
10747
|
-
warnDeprecation(`Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
|
|
10748
|
-
assetReferenceId = metaProperty.substring(ASSET_PREFIX.length);
|
|
10749
|
-
fileName = outputPluginDriver.getFileName(assetReferenceId);
|
|
10750
|
-
}
|
|
10751
|
-
else {
|
|
10752
|
-
warnDeprecation(`Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
|
|
10753
|
-
chunkReferenceId = metaProperty.substring(CHUNK_PREFIX.length);
|
|
10754
|
-
fileName = outputPluginDriver.getFileName(chunkReferenceId);
|
|
10755
|
-
}
|
|
10773
|
+
const { metaProperty, parent, referenceId } = this;
|
|
10774
|
+
const chunkId = this.preliminaryChunkId;
|
|
10775
|
+
if (referenceId) {
|
|
10776
|
+
const fileName = pluginDriver.getFileName(referenceId);
|
|
10756
10777
|
const relativePath = normalize(require$$0.relative(require$$0.dirname(chunkId), fileName));
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
]);
|
|
10768
|
-
}
|
|
10769
|
-
if (!replacement) {
|
|
10770
|
-
replacement =
|
|
10771
|
-
outputPluginDriver.hookFirstSync('resolveFileUrl', [
|
|
10772
|
-
{
|
|
10773
|
-
assetReferenceId,
|
|
10774
|
-
chunkId,
|
|
10775
|
-
chunkReferenceId,
|
|
10776
|
-
fileName,
|
|
10777
|
-
format,
|
|
10778
|
-
moduleId: this.context.module.id,
|
|
10779
|
-
referenceId: referenceId || assetReferenceId || chunkReferenceId,
|
|
10780
|
-
relativePath
|
|
10781
|
-
}
|
|
10782
|
-
]) || relativeUrlMechanisms[format](relativePath);
|
|
10783
|
-
}
|
|
10778
|
+
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
10779
|
+
{
|
|
10780
|
+
chunkId,
|
|
10781
|
+
fileName,
|
|
10782
|
+
format,
|
|
10783
|
+
moduleId: this.context.module.id,
|
|
10784
|
+
referenceId,
|
|
10785
|
+
relativePath
|
|
10786
|
+
}
|
|
10787
|
+
]) || relativeUrlMechanisms[format](relativePath);
|
|
10784
10788
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
10785
10789
|
return;
|
|
10786
10790
|
}
|
|
10787
|
-
const replacement =
|
|
10791
|
+
const replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
10788
10792
|
metaProperty,
|
|
10789
10793
|
{
|
|
10790
10794
|
chunkId,
|
|
@@ -10801,6 +10805,14 @@ class MetaProperty extends NodeBase {
|
|
|
10801
10805
|
}
|
|
10802
10806
|
}
|
|
10803
10807
|
}
|
|
10808
|
+
setResolution(format, accessedGlobalsByScope, preliminaryChunkId) {
|
|
10809
|
+
var _a;
|
|
10810
|
+
this.preliminaryChunkId = preliminaryChunkId;
|
|
10811
|
+
const accessedGlobals = (((_a = this.metaProperty) === null || _a === void 0 ? void 0 : _a.startsWith(FILE_PREFIX)) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
|
|
10812
|
+
if (accessedGlobals.length > 0) {
|
|
10813
|
+
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
10814
|
+
}
|
|
10815
|
+
}
|
|
10804
10816
|
}
|
|
10805
10817
|
const accessedMetaUrlGlobals = {
|
|
10806
10818
|
amd: ['document', 'module', 'URL'],
|
|
@@ -12314,7 +12326,26 @@ function getTimings() {
|
|
|
12314
12326
|
}
|
|
12315
12327
|
let timeStart = NOOP;
|
|
12316
12328
|
let timeEnd = NOOP;
|
|
12317
|
-
const TIMED_PLUGIN_HOOKS = [
|
|
12329
|
+
const TIMED_PLUGIN_HOOKS = [
|
|
12330
|
+
'augmentChunkHash',
|
|
12331
|
+
'buildEnd',
|
|
12332
|
+
'buildStart',
|
|
12333
|
+
'generateBundle',
|
|
12334
|
+
'load',
|
|
12335
|
+
'moduleParsed',
|
|
12336
|
+
'options',
|
|
12337
|
+
'outputOptions',
|
|
12338
|
+
'renderChunk',
|
|
12339
|
+
'renderDynamicImport',
|
|
12340
|
+
'renderStart',
|
|
12341
|
+
'resolveDynamicImport',
|
|
12342
|
+
'resolveFileUrl',
|
|
12343
|
+
'resolveId',
|
|
12344
|
+
'resolveImportMeta',
|
|
12345
|
+
'shouldTransformCachedModule',
|
|
12346
|
+
'transform',
|
|
12347
|
+
'writeBundle'
|
|
12348
|
+
];
|
|
12318
12349
|
function getPluginWithTimers(plugin, index) {
|
|
12319
12350
|
for (const hook of TIMED_PLUGIN_HOOKS) {
|
|
12320
12351
|
if (hook in plugin) {
|
|
@@ -12328,13 +12359,6 @@ function getPluginWithTimers(plugin, index) {
|
|
|
12328
12359
|
timeStart(timerLabel, 4);
|
|
12329
12360
|
const result = func.apply(this, args);
|
|
12330
12361
|
timeEnd(timerLabel, 4);
|
|
12331
|
-
if (result && typeof result.then === 'function') {
|
|
12332
|
-
timeStart(`${timerLabel} (async)`, 4);
|
|
12333
|
-
return result.then((hookResult) => {
|
|
12334
|
-
timeEnd(`${timerLabel} (async)`, 4);
|
|
12335
|
-
return hookResult;
|
|
12336
|
-
});
|
|
12337
|
-
}
|
|
12338
12362
|
return result;
|
|
12339
12363
|
};
|
|
12340
12364
|
}
|
|
@@ -12446,7 +12470,6 @@ class Module {
|
|
|
12446
12470
|
this.needsExportShim = false;
|
|
12447
12471
|
this.sideEffectDependenciesByVariable = new Map();
|
|
12448
12472
|
this.sources = new Set();
|
|
12449
|
-
this.usesTopLevelAwait = false;
|
|
12450
12473
|
this.allExportNames = null;
|
|
12451
12474
|
this.ast = null;
|
|
12452
12475
|
this.exportAllModules = [];
|
|
@@ -12491,7 +12514,7 @@ class Module {
|
|
|
12491
12514
|
return module.exports.has('default') || reexportDescriptions.has('default');
|
|
12492
12515
|
},
|
|
12493
12516
|
get hasModuleSideEffects() {
|
|
12494
|
-
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
|
|
12517
|
+
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
|
|
12495
12518
|
return this.moduleSideEffects;
|
|
12496
12519
|
},
|
|
12497
12520
|
id,
|
|
@@ -12803,12 +12826,17 @@ class Module {
|
|
|
12803
12826
|
this.exportAllModules.push(...externalExportAllModules);
|
|
12804
12827
|
}
|
|
12805
12828
|
render(options) {
|
|
12806
|
-
const
|
|
12807
|
-
this.ast.render(
|
|
12808
|
-
|
|
12809
|
-
|
|
12829
|
+
const source = this.magicString.clone();
|
|
12830
|
+
this.ast.render(source, options);
|
|
12831
|
+
source.trim();
|
|
12832
|
+
const { usesTopLevelAwait } = this.astContext;
|
|
12833
|
+
if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') {
|
|
12834
|
+
return error(errInvalidFormatForTopLevelAwait(this.id, options.format));
|
|
12835
|
+
}
|
|
12836
|
+
return { source, usesTopLevelAwait };
|
|
12810
12837
|
}
|
|
12811
12838
|
setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
|
|
12839
|
+
timeStart('generate ast', 3);
|
|
12812
12840
|
this.info.code = code;
|
|
12813
12841
|
this.originalCode = originalCode;
|
|
12814
12842
|
this.originalSourcemap = originalSourcemap;
|
|
@@ -12819,11 +12847,11 @@ class Module {
|
|
|
12819
12847
|
this.transformDependencies = transformDependencies;
|
|
12820
12848
|
this.customTransformCache = customTransformCache;
|
|
12821
12849
|
this.updateOptions(moduleOptions);
|
|
12822
|
-
timeStart('generate ast', 3);
|
|
12823
12850
|
if (!ast) {
|
|
12824
12851
|
ast = this.tryParse();
|
|
12825
12852
|
}
|
|
12826
12853
|
timeEnd('generate ast', 3);
|
|
12854
|
+
timeStart('analyze ast', 3);
|
|
12827
12855
|
this.resolvedIds = resolvedIds || Object.create(null);
|
|
12828
12856
|
// By default, `id` is the file name. Custom resolvers and loaders
|
|
12829
12857
|
// can change that, but it makes sense to use it for the source file name
|
|
@@ -12832,7 +12860,6 @@ class Module {
|
|
|
12832
12860
|
filename: (this.excludeFromSourcemap ? null : fileName),
|
|
12833
12861
|
indentExclusionRanges: []
|
|
12834
12862
|
});
|
|
12835
|
-
timeStart('analyse ast', 3);
|
|
12836
12863
|
this.astContext = {
|
|
12837
12864
|
addDynamicImport: this.addDynamicImport.bind(this),
|
|
12838
12865
|
addExport: this.addExport.bind(this),
|
|
@@ -12865,7 +12892,7 @@ class Module {
|
|
|
12865
12892
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
12866
12893
|
this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
|
|
12867
12894
|
this.info.ast = ast;
|
|
12868
|
-
timeEnd('
|
|
12895
|
+
timeEnd('analyze ast', 3);
|
|
12869
12896
|
}
|
|
12870
12897
|
toJSON() {
|
|
12871
12898
|
return {
|
|
@@ -13240,11 +13267,11 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
13240
13267
|
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
13241
13268
|
}
|
|
13242
13269
|
let exportBlock = '';
|
|
13243
|
-
for (const { defaultVariableName,
|
|
13270
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13244
13271
|
if (reexports && namedExportsMode) {
|
|
13245
13272
|
for (const specifier of reexports) {
|
|
13246
13273
|
if (specifier.reexported !== '*') {
|
|
13247
|
-
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop,
|
|
13274
|
+
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
13248
13275
|
if (exportBlock)
|
|
13249
13276
|
exportBlock += n;
|
|
13250
13277
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
@@ -13302,9 +13329,9 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
|
|
|
13302
13329
|
return exports[0].local;
|
|
13303
13330
|
}
|
|
13304
13331
|
else {
|
|
13305
|
-
for (const { defaultVariableName,
|
|
13332
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13306
13333
|
if (reexports) {
|
|
13307
|
-
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop,
|
|
13334
|
+
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
13308
13335
|
}
|
|
13309
13336
|
}
|
|
13310
13337
|
}
|
|
@@ -13379,7 +13406,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13379
13406
|
neededInteropHelpers.add(helper);
|
|
13380
13407
|
interopStatements.push(`${cnst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
13381
13408
|
};
|
|
13382
|
-
for (const { defaultVariableName, imports,
|
|
13409
|
+
for (const { defaultVariableName, imports, importPath, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13383
13410
|
if (isChunk) {
|
|
13384
13411
|
for (const { imported, reexported } of [
|
|
13385
13412
|
...(imports || []),
|
|
@@ -13394,7 +13421,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13394
13421
|
}
|
|
13395
13422
|
}
|
|
13396
13423
|
else {
|
|
13397
|
-
const moduleInterop = String(interop(
|
|
13424
|
+
const moduleInterop = String(interop(importPath));
|
|
13398
13425
|
let hasDefault = false;
|
|
13399
13426
|
let hasNamespace = false;
|
|
13400
13427
|
for (const { imported, reexported } of [
|
|
@@ -13459,7 +13486,9 @@ const builtins = {
|
|
|
13459
13486
|
zlib: true
|
|
13460
13487
|
};
|
|
13461
13488
|
function warnOnBuiltins(warn, dependencies) {
|
|
13462
|
-
const externalBuiltins = dependencies
|
|
13489
|
+
const externalBuiltins = dependencies
|
|
13490
|
+
.map(({ importPath }) => importPath)
|
|
13491
|
+
.filter(importPath => importPath in builtins);
|
|
13463
13492
|
if (!externalBuiltins.length)
|
|
13464
13493
|
return;
|
|
13465
13494
|
warn({
|
|
@@ -13469,9 +13498,9 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
13469
13498
|
});
|
|
13470
13499
|
}
|
|
13471
13500
|
|
|
13472
|
-
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets,
|
|
13473
|
-
warnOnBuiltins(
|
|
13474
|
-
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.
|
|
13501
|
+
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13502
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13503
|
+
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
|
|
13475
13504
|
const args = dependencies.map(m => m.name);
|
|
13476
13505
|
const { n, getNonArrowFunctionIntro, _ } = snippets;
|
|
13477
13506
|
if (namedExportsMode && hasExports) {
|
|
@@ -13496,8 +13525,8 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13496
13525
|
if (namespaceMarkers) {
|
|
13497
13526
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13498
13527
|
}
|
|
13499
|
-
magicString
|
|
13500
|
-
|
|
13528
|
+
magicString
|
|
13529
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
13501
13530
|
.indent(t)
|
|
13502
13531
|
// factory function should be wrapped by parentheses to avoid lazy parsing,
|
|
13503
13532
|
// cf. https://v8.dev/blog/preparser#pife
|
|
@@ -13505,7 +13534,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13505
13534
|
isAsync: false,
|
|
13506
13535
|
name: null
|
|
13507
13536
|
})}{${useStrict}${n}${n}`)
|
|
13508
|
-
.append(`${n}${n}}));`)
|
|
13537
|
+
.append(`${n}${n}}));`);
|
|
13509
13538
|
}
|
|
13510
13539
|
|
|
13511
13540
|
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
@@ -13519,23 +13548,23 @@ function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13519
13548
|
const interopBlock = getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets);
|
|
13520
13549
|
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
13521
13550
|
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
13522
|
-
|
|
13551
|
+
magicString.append(`${exportBlock}${outro}`);
|
|
13523
13552
|
}
|
|
13524
13553
|
function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
13525
13554
|
let importBlock = '';
|
|
13526
13555
|
let definingVariable = false;
|
|
13527
|
-
for (const {
|
|
13556
|
+
for (const { importPath, name, reexports, imports } of dependencies) {
|
|
13528
13557
|
if (!reexports && !imports) {
|
|
13529
13558
|
if (importBlock) {
|
|
13530
13559
|
importBlock += compact && !definingVariable ? ',' : `;${n}`;
|
|
13531
13560
|
}
|
|
13532
13561
|
definingVariable = false;
|
|
13533
|
-
importBlock += `require('${
|
|
13562
|
+
importBlock += `require('${importPath}')`;
|
|
13534
13563
|
}
|
|
13535
13564
|
else {
|
|
13536
13565
|
importBlock += compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${cnst} `;
|
|
13537
13566
|
definingVariable = true;
|
|
13538
|
-
importBlock += `${name}${_}=${_}require('${
|
|
13567
|
+
importBlock += `${name}${_}=${_}require('${importPath}')`;
|
|
13539
13568
|
}
|
|
13540
13569
|
}
|
|
13541
13570
|
if (importBlock) {
|
|
@@ -13557,13 +13586,13 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
13557
13586
|
magicString.append(n + n + exportBlock.join(n).trim());
|
|
13558
13587
|
if (outro)
|
|
13559
13588
|
magicString.append(outro);
|
|
13560
|
-
|
|
13589
|
+
magicString.trim();
|
|
13561
13590
|
}
|
|
13562
13591
|
function getImportBlock(dependencies, _) {
|
|
13563
13592
|
const importBlock = [];
|
|
13564
|
-
for (const {
|
|
13593
|
+
for (const { importPath, reexports, imports, name } of dependencies) {
|
|
13565
13594
|
if (!reexports && !imports) {
|
|
13566
|
-
importBlock.push(`import${_}'${
|
|
13595
|
+
importBlock.push(`import${_}'${importPath}';`);
|
|
13567
13596
|
continue;
|
|
13568
13597
|
}
|
|
13569
13598
|
if (imports) {
|
|
@@ -13582,10 +13611,10 @@ function getImportBlock(dependencies, _) {
|
|
|
13582
13611
|
}
|
|
13583
13612
|
}
|
|
13584
13613
|
if (starImport) {
|
|
13585
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${
|
|
13614
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${importPath}';`);
|
|
13586
13615
|
}
|
|
13587
13616
|
if (defaultImport && importedNames.length === 0) {
|
|
13588
|
-
importBlock.push(`import ${defaultImport.local} from${_}'${
|
|
13617
|
+
importBlock.push(`import ${defaultImport.local} from${_}'${importPath}';`);
|
|
13589
13618
|
}
|
|
13590
13619
|
else if (importedNames.length > 0) {
|
|
13591
13620
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
@@ -13597,7 +13626,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13597
13626
|
return `${specifier.imported} as ${specifier.local}`;
|
|
13598
13627
|
}
|
|
13599
13628
|
})
|
|
13600
|
-
.join(`,${_}`)}${_}}${_}from${_}'${
|
|
13629
|
+
.join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
|
|
13601
13630
|
}
|
|
13602
13631
|
}
|
|
13603
13632
|
if (reexports) {
|
|
@@ -13616,12 +13645,12 @@ function getImportBlock(dependencies, _) {
|
|
|
13616
13645
|
}
|
|
13617
13646
|
}
|
|
13618
13647
|
if (starExport) {
|
|
13619
|
-
importBlock.push(`export${_}*${_}from${_}'${
|
|
13648
|
+
importBlock.push(`export${_}*${_}from${_}'${importPath}';`);
|
|
13620
13649
|
}
|
|
13621
13650
|
if (namespaceReexports.length > 0) {
|
|
13622
13651
|
if (!imports ||
|
|
13623
13652
|
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
13624
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}'${
|
|
13653
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}'${importPath}';`);
|
|
13625
13654
|
}
|
|
13626
13655
|
for (const specifier of namespaceReexports) {
|
|
13627
13656
|
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
@@ -13637,7 +13666,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13637
13666
|
return `${specifier.imported} as ${specifier.reexported}`;
|
|
13638
13667
|
}
|
|
13639
13668
|
})
|
|
13640
|
-
.join(`,${_}`)}${_}}${_}from${_}'${
|
|
13669
|
+
.join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
|
|
13641
13670
|
}
|
|
13642
13671
|
}
|
|
13643
13672
|
}
|
|
@@ -13703,7 +13732,7 @@ function trimEmptyImports(dependencies) {
|
|
|
13703
13732
|
return [];
|
|
13704
13733
|
}
|
|
13705
13734
|
|
|
13706
|
-
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets,
|
|
13735
|
+
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
|
|
13707
13736
|
const { _, cnst, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
|
|
13708
13737
|
const isNamespaced = name && name.includes('.');
|
|
13709
13738
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
@@ -13713,12 +13742,12 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13713
13742
|
message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
|
|
13714
13743
|
});
|
|
13715
13744
|
}
|
|
13716
|
-
warnOnBuiltins(
|
|
13745
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13717
13746
|
const external = trimEmptyImports(dependencies);
|
|
13718
13747
|
const deps = external.map(dep => dep.globalName || 'null');
|
|
13719
13748
|
const args = external.map(m => m.name);
|
|
13720
13749
|
if (hasExports && !name) {
|
|
13721
|
-
|
|
13750
|
+
onwarn({
|
|
13722
13751
|
code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT',
|
|
13723
13752
|
message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`
|
|
13724
13753
|
});
|
|
@@ -13759,8 +13788,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13759
13788
|
if (namespaceMarkers) {
|
|
13760
13789
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13761
13790
|
}
|
|
13762
|
-
magicString
|
|
13763
|
-
|
|
13791
|
+
magicString
|
|
13792
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
13793
|
+
.indent(t)
|
|
13794
|
+
.prepend(wrapperIntro)
|
|
13795
|
+
.append(wrapperOutro);
|
|
13764
13796
|
}
|
|
13765
13797
|
|
|
13766
13798
|
function system(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, snippets, outro, usesTopLevelAwait }, { externalLiveBindings, freeze, name, namespaceToStringTag, strict, systemNullSetters }) {
|
|
@@ -13775,7 +13807,7 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
13775
13807
|
// factory function should be wrapped by parentheses to avoid lazy parsing,
|
|
13776
13808
|
// cf. https://v8.dev/blog/preparser#pife
|
|
13777
13809
|
let wrapperStart = `System.register(${registeredName}[` +
|
|
13778
|
-
dependencies.map(({
|
|
13810
|
+
dependencies.map(({ importPath }) => `'${importPath}'`).join(`,${_}`) +
|
|
13779
13811
|
`],${_}(${getNonArrowFunctionIntro(wrapperParams, { isAsync: false, name: null })}{${n}${t}${strict ? "'use strict';" : ''}` +
|
|
13780
13812
|
getStarExcludesBlock(starExcludes, t, snippets) +
|
|
13781
13813
|
getImportBindingsBlock(importBindings, t, snippets) +
|
|
@@ -13796,13 +13828,16 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
13796
13828
|
name: null
|
|
13797
13829
|
})}{${n}${n}`;
|
|
13798
13830
|
const wrapperEnd = `${t}${t}})${n}${t}}${s}${n}}));`;
|
|
13799
|
-
magicString
|
|
13831
|
+
magicString
|
|
13832
|
+
.prepend(intro +
|
|
13800
13833
|
getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, namespaceToStringTag) +
|
|
13801
|
-
getHoistedExportsBlock(exports, t, snippets))
|
|
13802
|
-
|
|
13834
|
+
getHoistedExportsBlock(exports, t, snippets))
|
|
13835
|
+
.append(`${outro}${n}${n}` +
|
|
13803
13836
|
getSyntheticExportsBlock(exports, t, snippets) +
|
|
13804
|
-
getMissingExportsBlock(exports, t, snippets))
|
|
13805
|
-
|
|
13837
|
+
getMissingExportsBlock(exports, t, snippets))
|
|
13838
|
+
.indent(`${t}${t}${t}`)
|
|
13839
|
+
.append(wrapperEnd)
|
|
13840
|
+
.prepend(wrapperStart);
|
|
13806
13841
|
}
|
|
13807
13842
|
function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, getPropertyAccess, n }) {
|
|
13808
13843
|
const importBindings = [];
|
|
@@ -13904,7 +13939,7 @@ function safeAccess(name, globalVar, { _, getPropertyAccess }) {
|
|
|
13904
13939
|
.map(part => (propertyPath += getPropertyAccess(part)))
|
|
13905
13940
|
.join(`${_}&&${_}`);
|
|
13906
13941
|
}
|
|
13907
|
-
function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets,
|
|
13942
|
+
function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
|
|
13908
13943
|
const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
13909
13944
|
const factoryVar = compact ? 'f' : 'factory';
|
|
13910
13945
|
const globalVar = compact ? 'g' : 'global';
|
|
@@ -13914,9 +13949,9 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13914
13949
|
message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.'
|
|
13915
13950
|
});
|
|
13916
13951
|
}
|
|
13917
|
-
warnOnBuiltins(
|
|
13918
|
-
const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.
|
|
13919
|
-
const cjsDeps = dependencies.map(m => `require('${m.
|
|
13952
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13953
|
+
const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
|
|
13954
|
+
const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
|
|
13920
13955
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
13921
13956
|
const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar, getPropertyAccess));
|
|
13922
13957
|
const factoryParams = trimmedImports.map(m => m.name);
|
|
@@ -13993,169 +14028,328 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13993
14028
|
if (namespaceMarkers) {
|
|
13994
14029
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13995
14030
|
}
|
|
13996
|
-
magicString
|
|
13997
|
-
|
|
14031
|
+
magicString
|
|
14032
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
14033
|
+
.trim()
|
|
14034
|
+
.indent(t)
|
|
14035
|
+
.append(wrapperOutro)
|
|
14036
|
+
.prepend(wrapperIntro);
|
|
13998
14037
|
}
|
|
13999
14038
|
|
|
14000
14039
|
const finalisers = { amd, cjs, es, iife, system, umd };
|
|
14001
14040
|
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14041
|
+
const createHash = () => crypto.createHash('sha256');
|
|
14042
|
+
|
|
14043
|
+
// Four random characters from the private use area to minimize risk of conflicts
|
|
14044
|
+
const hashPlaceholderLeft = '\uf7f9\ue4d3';
|
|
14045
|
+
const hashPlaceholderRight = '\ue3cc\uf1fe';
|
|
14046
|
+
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
14047
|
+
// This is the size of a sha256
|
|
14048
|
+
const maxHashSize = 64;
|
|
14049
|
+
const defaultHashSize = 8;
|
|
14050
|
+
const getHashPlaceholderGenerator = () => {
|
|
14051
|
+
let nextIndex = 0;
|
|
14052
|
+
return (optionName, hashSize = defaultHashSize) => {
|
|
14053
|
+
if (hashSize > maxHashSize) {
|
|
14054
|
+
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14055
|
+
}
|
|
14056
|
+
const placeholder = `${hashPlaceholderLeft}${String(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
14057
|
+
if (placeholder.length > hashSize) {
|
|
14058
|
+
return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14059
|
+
}
|
|
14060
|
+
nextIndex++;
|
|
14061
|
+
return placeholder;
|
|
14062
|
+
};
|
|
14063
|
+
};
|
|
14064
|
+
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}\\d{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14065
|
+
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14066
|
+
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14067
|
+
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14068
|
+
const containedPlaceholders = new Set();
|
|
14069
|
+
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14070
|
+
if (placeholders.has(placeholder)) {
|
|
14071
|
+
containedPlaceholders.add(placeholder);
|
|
14072
|
+
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14073
|
+
}
|
|
14074
|
+
return placeholder;
|
|
14075
|
+
});
|
|
14076
|
+
return { containedPlaceholders, transformedCode };
|
|
14077
|
+
};
|
|
14078
|
+
|
|
14079
|
+
function renderNamePattern(pattern, patternName, replacements) {
|
|
14080
|
+
if (isPathFragment(pattern))
|
|
14081
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14082
|
+
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14083
|
+
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14084
|
+
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14085
|
+
}
|
|
14086
|
+
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14087
|
+
if (isPathFragment(replacement))
|
|
14088
|
+
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14089
|
+
return replacement;
|
|
14090
|
+
});
|
|
14091
|
+
}
|
|
14092
|
+
function makeUnique(name, existingNames) {
|
|
14093
|
+
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14094
|
+
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14095
|
+
return name;
|
|
14096
|
+
const ext = require$$0.extname(name);
|
|
14097
|
+
name = name.substring(0, name.length - ext.length);
|
|
14098
|
+
let uniqueName, uniqueIndex = 1;
|
|
14099
|
+
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14100
|
+
;
|
|
14101
|
+
return uniqueName;
|
|
14102
|
+
}
|
|
14103
|
+
|
|
14104
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
14105
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
14106
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
14107
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
14108
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
14109
|
+
ext: () => require$$0.extname(emittedName).substring(1),
|
|
14110
|
+
extname: () => require$$0.extname(emittedName),
|
|
14111
|
+
hash: size => createHash()
|
|
14112
|
+
.update(source)
|
|
14113
|
+
.digest('hex')
|
|
14114
|
+
.substring(0, size || defaultHashSize),
|
|
14115
|
+
name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
|
|
14116
|
+
}), bundle);
|
|
14117
|
+
}
|
|
14118
|
+
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
14119
|
+
if (fileName in bundle) {
|
|
14120
|
+
warn(errFileNameConflict(fileName));
|
|
14007
14121
|
}
|
|
14008
|
-
|
|
14009
|
-
|
|
14122
|
+
bundle[fileName] = FILE_PLACEHOLDER;
|
|
14123
|
+
}
|
|
14124
|
+
const FILE_PLACEHOLDER = {
|
|
14125
|
+
type: 'placeholder'
|
|
14126
|
+
};
|
|
14127
|
+
function hasValidType(emittedFile) {
|
|
14128
|
+
return Boolean(emittedFile &&
|
|
14129
|
+
(emittedFile.type === 'asset' ||
|
|
14130
|
+
emittedFile.type === 'chunk'));
|
|
14131
|
+
}
|
|
14132
|
+
function hasValidName(emittedFile) {
|
|
14133
|
+
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
14134
|
+
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
14135
|
+
}
|
|
14136
|
+
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
14137
|
+
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
14138
|
+
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
14139
|
+
return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
|
|
14010
14140
|
}
|
|
14141
|
+
return source;
|
|
14011
14142
|
}
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
this.names = map.names;
|
|
14016
|
-
this.mappings = map.mappings;
|
|
14143
|
+
function getAssetFileName(file, referenceId) {
|
|
14144
|
+
if (typeof file.fileName !== 'string') {
|
|
14145
|
+
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
14017
14146
|
}
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
|
|
14023
|
-
const nameIndexMap = new Map();
|
|
14024
|
-
const mappings = [];
|
|
14025
|
-
for (const line of this.mappings) {
|
|
14026
|
-
const tracedLine = [];
|
|
14027
|
-
for (const segment of line) {
|
|
14028
|
-
if (segment.length === 1)
|
|
14029
|
-
continue;
|
|
14030
|
-
const source = this.sources[segment[1]];
|
|
14031
|
-
if (!source)
|
|
14032
|
-
continue;
|
|
14033
|
-
const traced = source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : '');
|
|
14034
|
-
if (traced) {
|
|
14035
|
-
const { column, line, name, source: { content, filename } } = traced;
|
|
14036
|
-
let sourceIndex = sourceIndexMap.get(filename);
|
|
14037
|
-
if (sourceIndex === undefined) {
|
|
14038
|
-
sourceIndex = sources.length;
|
|
14039
|
-
sources.push(filename);
|
|
14040
|
-
sourceIndexMap.set(filename, sourceIndex);
|
|
14041
|
-
sourcesContent[sourceIndex] = content;
|
|
14042
|
-
}
|
|
14043
|
-
else if (sourcesContent[sourceIndex] == null) {
|
|
14044
|
-
sourcesContent[sourceIndex] = content;
|
|
14045
|
-
}
|
|
14046
|
-
else if (content != null && sourcesContent[sourceIndex] !== content) {
|
|
14047
|
-
return error({
|
|
14048
|
-
message: `Multiple conflicting contents for sourcemap source ${filename}`
|
|
14049
|
-
});
|
|
14050
|
-
}
|
|
14051
|
-
const tracedSegment = [segment[0], sourceIndex, line, column];
|
|
14052
|
-
if (name) {
|
|
14053
|
-
let nameIndex = nameIndexMap.get(name);
|
|
14054
|
-
if (nameIndex === undefined) {
|
|
14055
|
-
nameIndex = names.length;
|
|
14056
|
-
names.push(name);
|
|
14057
|
-
nameIndexMap.set(name, nameIndex);
|
|
14058
|
-
}
|
|
14059
|
-
tracedSegment[4] = nameIndex;
|
|
14060
|
-
}
|
|
14061
|
-
tracedLine.push(tracedSegment);
|
|
14062
|
-
}
|
|
14063
|
-
}
|
|
14064
|
-
mappings.push(tracedLine);
|
|
14065
|
-
}
|
|
14066
|
-
return { mappings, names, sources, sourcesContent };
|
|
14147
|
+
return file.fileName;
|
|
14148
|
+
}
|
|
14149
|
+
function getChunkFileName(file, facadeChunkByModule) {
|
|
14150
|
+
if (file.fileName) {
|
|
14151
|
+
return file.fileName;
|
|
14067
14152
|
}
|
|
14068
|
-
|
|
14069
|
-
const
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
const source = this.sources[segment[1]];
|
|
14085
|
-
if (!source)
|
|
14086
|
-
return null;
|
|
14087
|
-
return source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : name);
|
|
14153
|
+
if (facadeChunkByModule) {
|
|
14154
|
+
const chunk = facadeChunkByModule.get(file.module);
|
|
14155
|
+
return chunk.id || chunk.getFileName();
|
|
14156
|
+
}
|
|
14157
|
+
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
14158
|
+
}
|
|
14159
|
+
class FileEmitter {
|
|
14160
|
+
constructor(graph, options, baseFileEmitter) {
|
|
14161
|
+
this.graph = graph;
|
|
14162
|
+
this.options = options;
|
|
14163
|
+
this.bundle = null;
|
|
14164
|
+
this.facadeChunkByModule = null;
|
|
14165
|
+
this.outputOptions = null;
|
|
14166
|
+
this.emitFile = (emittedFile) => {
|
|
14167
|
+
if (!hasValidType(emittedFile)) {
|
|
14168
|
+
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
14088
14169
|
}
|
|
14089
|
-
if (
|
|
14090
|
-
|
|
14170
|
+
if (!hasValidName(emittedFile)) {
|
|
14171
|
+
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
14172
|
+
}
|
|
14173
|
+
if (emittedFile.type === 'chunk') {
|
|
14174
|
+
return this.emitChunk(emittedFile);
|
|
14175
|
+
}
|
|
14176
|
+
return this.emitAsset(emittedFile);
|
|
14177
|
+
};
|
|
14178
|
+
this.finaliseAssets = () => {
|
|
14179
|
+
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
14180
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
14181
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
14182
|
+
}
|
|
14183
|
+
};
|
|
14184
|
+
this.getFileName = (fileReferenceId) => {
|
|
14185
|
+
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
14186
|
+
if (!emittedFile)
|
|
14187
|
+
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
14188
|
+
if (emittedFile.type === 'chunk') {
|
|
14189
|
+
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
14190
|
+
}
|
|
14191
|
+
return getAssetFileName(emittedFile, fileReferenceId);
|
|
14192
|
+
};
|
|
14193
|
+
this.setAssetSource = (referenceId, requestedSource) => {
|
|
14194
|
+
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
14195
|
+
if (!consumedFile)
|
|
14196
|
+
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
14197
|
+
if (consumedFile.type !== 'asset') {
|
|
14198
|
+
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
14199
|
+
}
|
|
14200
|
+
if (consumedFile.source !== undefined) {
|
|
14201
|
+
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
14202
|
+
}
|
|
14203
|
+
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
14204
|
+
if (this.bundle) {
|
|
14205
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
14091
14206
|
}
|
|
14092
14207
|
else {
|
|
14093
|
-
|
|
14208
|
+
consumedFile.source = source;
|
|
14209
|
+
}
|
|
14210
|
+
};
|
|
14211
|
+
this.setChunkInformation = (facadeChunkByModule) => {
|
|
14212
|
+
this.facadeChunkByModule = facadeChunkByModule;
|
|
14213
|
+
};
|
|
14214
|
+
this.setOutputBundle = (outputBundle, outputOptions) => {
|
|
14215
|
+
this.outputOptions = outputOptions;
|
|
14216
|
+
this.bundle = outputBundle;
|
|
14217
|
+
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
14218
|
+
if (emittedFile.fileName) {
|
|
14219
|
+
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
14220
|
+
}
|
|
14221
|
+
}
|
|
14222
|
+
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
14223
|
+
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
14224
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
14225
|
+
}
|
|
14226
|
+
}
|
|
14227
|
+
};
|
|
14228
|
+
this.filesByReferenceId = baseFileEmitter
|
|
14229
|
+
? new Map(baseFileEmitter.filesByReferenceId)
|
|
14230
|
+
: new Map();
|
|
14231
|
+
}
|
|
14232
|
+
assignReferenceId(file, idBase) {
|
|
14233
|
+
let referenceId;
|
|
14234
|
+
do {
|
|
14235
|
+
referenceId = createHash()
|
|
14236
|
+
.update(referenceId || idBase)
|
|
14237
|
+
.digest('hex')
|
|
14238
|
+
.substring(0, 8);
|
|
14239
|
+
} while (this.filesByReferenceId.has(referenceId));
|
|
14240
|
+
this.filesByReferenceId.set(referenceId, file);
|
|
14241
|
+
return referenceId;
|
|
14242
|
+
}
|
|
14243
|
+
emitAsset(emittedAsset) {
|
|
14244
|
+
const source = typeof emittedAsset.source !== 'undefined'
|
|
14245
|
+
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
14246
|
+
: undefined;
|
|
14247
|
+
const consumedAsset = {
|
|
14248
|
+
fileName: emittedAsset.fileName,
|
|
14249
|
+
name: emittedAsset.name,
|
|
14250
|
+
source,
|
|
14251
|
+
type: 'asset'
|
|
14252
|
+
};
|
|
14253
|
+
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
14254
|
+
if (this.bundle) {
|
|
14255
|
+
if (emittedAsset.fileName) {
|
|
14256
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
14257
|
+
}
|
|
14258
|
+
if (source !== undefined) {
|
|
14259
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
14094
14260
|
}
|
|
14095
14261
|
}
|
|
14096
|
-
return
|
|
14262
|
+
return referenceId;
|
|
14097
14263
|
}
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
if (map.mappings) {
|
|
14102
|
-
return new Link(map, [source]);
|
|
14264
|
+
emitChunk(emittedChunk) {
|
|
14265
|
+
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
14266
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
14103
14267
|
}
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14268
|
+
if (typeof emittedChunk.id !== 'string') {
|
|
14269
|
+
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
14270
|
+
}
|
|
14271
|
+
const consumedChunk = {
|
|
14272
|
+
fileName: emittedChunk.fileName,
|
|
14273
|
+
module: null,
|
|
14274
|
+
name: emittedChunk.name || emittedChunk.id,
|
|
14275
|
+
type: 'chunk'
|
|
14276
|
+
};
|
|
14277
|
+
this.graph.moduleLoader
|
|
14278
|
+
.emitChunk(emittedChunk)
|
|
14279
|
+
.then(module => (consumedChunk.module = module))
|
|
14280
|
+
.catch(() => {
|
|
14281
|
+
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
14282
|
+
// once module loading has finished
|
|
14111
14283
|
});
|
|
14112
|
-
return
|
|
14113
|
-
mappings: [],
|
|
14114
|
-
names: []
|
|
14115
|
-
}, [source]);
|
|
14116
|
-
};
|
|
14117
|
-
}
|
|
14118
|
-
function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, linkMap) {
|
|
14119
|
-
let source;
|
|
14120
|
-
if (!originalSourcemap) {
|
|
14121
|
-
source = new Source(id, originalCode);
|
|
14284
|
+
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
14122
14285
|
}
|
|
14123
|
-
|
|
14124
|
-
const
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
const
|
|
14129
|
-
|
|
14286
|
+
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
14287
|
+
const fileName = consumedFile.fileName ||
|
|
14288
|
+
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
14289
|
+
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
14290
|
+
// We must not modify the original assets to avoid interaction between outputs
|
|
14291
|
+
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
14292
|
+
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
14293
|
+
bundle[fileName] = {
|
|
14294
|
+
fileName,
|
|
14295
|
+
name: consumedFile.name,
|
|
14296
|
+
source,
|
|
14297
|
+
type: 'asset'
|
|
14298
|
+
};
|
|
14130
14299
|
}
|
|
14131
|
-
return sourcemapChain.reduce(linkMap, source);
|
|
14132
14300
|
}
|
|
14133
|
-
function
|
|
14134
|
-
const
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
.map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
|
|
14138
|
-
const link = new Link(map, moduleSources);
|
|
14139
|
-
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
14140
|
-
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
14141
|
-
if (file) {
|
|
14142
|
-
const directory = require$$0.dirname(file);
|
|
14143
|
-
sources = sources.map((source) => require$$0.relative(directory, source));
|
|
14144
|
-
file = require$$0.basename(file);
|
|
14301
|
+
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
14302
|
+
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
14303
|
+
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
14304
|
+
return fileName;
|
|
14145
14305
|
}
|
|
14146
|
-
|
|
14147
|
-
return new SourceMap({ file, mappings, names, sources, sourcesContent });
|
|
14306
|
+
return null;
|
|
14148
14307
|
}
|
|
14149
|
-
function
|
|
14150
|
-
if (
|
|
14151
|
-
return
|
|
14308
|
+
function areSourcesEqual(sourceA, sourceB) {
|
|
14309
|
+
if (typeof sourceA === 'string') {
|
|
14310
|
+
return sourceA === sourceB;
|
|
14152
14311
|
}
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14312
|
+
if (typeof sourceB === 'string') {
|
|
14313
|
+
return false;
|
|
14314
|
+
}
|
|
14315
|
+
if ('equals' in sourceA) {
|
|
14316
|
+
return sourceA.equals(sourceB);
|
|
14317
|
+
}
|
|
14318
|
+
if (sourceA.length !== sourceB.length) {
|
|
14319
|
+
return false;
|
|
14320
|
+
}
|
|
14321
|
+
for (let index = 0; index < sourceA.length; index++) {
|
|
14322
|
+
if (sourceA[index] !== sourceB[index]) {
|
|
14323
|
+
return false;
|
|
14324
|
+
}
|
|
14325
|
+
}
|
|
14326
|
+
return true;
|
|
14156
14327
|
}
|
|
14157
14328
|
|
|
14158
|
-
const
|
|
14329
|
+
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14330
|
+
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14331
|
+
async function createAddons(options, outputPluginDriver, chunk) {
|
|
14332
|
+
try {
|
|
14333
|
+
let [banner, footer, intro, outro] = await Promise.all([
|
|
14334
|
+
outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
|
|
14335
|
+
outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
|
|
14336
|
+
outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
|
|
14337
|
+
outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
|
|
14338
|
+
]);
|
|
14339
|
+
if (intro)
|
|
14340
|
+
intro += '\n\n';
|
|
14341
|
+
if (outro)
|
|
14342
|
+
outro = `\n\n${outro}`;
|
|
14343
|
+
if (banner)
|
|
14344
|
+
banner += '\n';
|
|
14345
|
+
if (footer)
|
|
14346
|
+
footer = '\n' + footer;
|
|
14347
|
+
return { banner, footer, intro, outro };
|
|
14348
|
+
}
|
|
14349
|
+
catch (err) {
|
|
14350
|
+
return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14159
14353
|
|
|
14160
14354
|
const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
14161
14355
|
amd: deconflictImportsOther,
|
|
@@ -14165,21 +14359,21 @@ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
|
14165
14359
|
system: deconflictImportsEsmOrSystem,
|
|
14166
14360
|
umd: deconflictImportsOther
|
|
14167
14361
|
};
|
|
14168
|
-
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14362
|
+
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14169
14363
|
const reversedModules = modules.slice().reverse();
|
|
14170
14364
|
for (const module of reversedModules) {
|
|
14171
14365
|
module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14172
14366
|
}
|
|
14173
14367
|
deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
|
|
14174
|
-
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, syntheticExports);
|
|
14368
|
+
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
|
|
14175
14369
|
for (const module of reversedModules) {
|
|
14176
14370
|
module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14177
14371
|
}
|
|
14178
14372
|
}
|
|
14179
|
-
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, syntheticExports) {
|
|
14373
|
+
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
|
|
14180
14374
|
// This is needed for namespace reexports
|
|
14181
14375
|
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14182
|
-
if (preserveModules || dependency instanceof
|
|
14376
|
+
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14183
14377
|
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14184
14378
|
}
|
|
14185
14379
|
}
|
|
@@ -14187,7 +14381,9 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14187
14381
|
const module = variable.module;
|
|
14188
14382
|
const name = variable.name;
|
|
14189
14383
|
if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
|
|
14190
|
-
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14384
|
+
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14385
|
+
? externalChunkByModule.get(module)
|
|
14386
|
+
: chunkByModule.get(module)).variableName);
|
|
14191
14387
|
}
|
|
14192
14388
|
else if (module instanceof ExternalModule && name === 'default') {
|
|
14193
14389
|
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
@@ -14202,12 +14398,12 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14202
14398
|
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14203
14399
|
}
|
|
14204
14400
|
}
|
|
14205
|
-
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule) {
|
|
14206
|
-
for (const
|
|
14207
|
-
|
|
14401
|
+
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14402
|
+
for (const chunk of dependencies) {
|
|
14403
|
+
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14208
14404
|
}
|
|
14209
|
-
for (const
|
|
14210
|
-
|
|
14405
|
+
for (const chunk of deconflictedNamespace) {
|
|
14406
|
+
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14211
14407
|
}
|
|
14212
14408
|
for (const externalModule of deconflictedDefault) {
|
|
14213
14409
|
if (deconflictedNamespace.has(externalModule) &&
|
|
@@ -14221,12 +14417,13 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14221
14417
|
for (const variable of imports) {
|
|
14222
14418
|
const module = variable.module;
|
|
14223
14419
|
if (module instanceof ExternalModule) {
|
|
14420
|
+
const chunk = externalChunkByModule.get(module);
|
|
14224
14421
|
const name = variable.name;
|
|
14225
14422
|
if (name === 'default') {
|
|
14226
14423
|
const moduleInterop = String(interop(module.id));
|
|
14227
14424
|
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
14228
|
-
?
|
|
14229
|
-
:
|
|
14425
|
+
? chunk.defaultVariableName
|
|
14426
|
+
: chunk.variableName;
|
|
14230
14427
|
if (isDefaultAProperty(moduleInterop, externalLiveBindings)) {
|
|
14231
14428
|
variable.setRenderNames(variableName, 'default');
|
|
14232
14429
|
}
|
|
@@ -14236,12 +14433,12 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14236
14433
|
}
|
|
14237
14434
|
else if (name === '*') {
|
|
14238
14435
|
variable.setRenderNames(null, namespaceInteropHelpersByInteropType[String(interop(module.id))]
|
|
14239
|
-
?
|
|
14240
|
-
:
|
|
14436
|
+
? chunk.namespaceVariableName
|
|
14437
|
+
: chunk.variableName);
|
|
14241
14438
|
}
|
|
14242
14439
|
else {
|
|
14243
14440
|
// if the second parameter is `null`, it uses its "name" for the property name
|
|
14244
|
-
variable.setRenderNames(
|
|
14441
|
+
variable.setRenderNames(chunk.variableName, null);
|
|
14245
14442
|
}
|
|
14246
14443
|
}
|
|
14247
14444
|
else {
|
|
@@ -14275,15 +14472,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
|
|
|
14275
14472
|
}
|
|
14276
14473
|
}
|
|
14277
14474
|
|
|
14278
|
-
const needsEscapeRegEx = /[\\'\r\n\u2028\u2029]/;
|
|
14279
|
-
const quoteNewlineRegEx = /(['\r\n\u2028\u2029])/g;
|
|
14280
|
-
const backSlashRegEx = /\\/g;
|
|
14281
|
-
function escapeId(id) {
|
|
14282
|
-
if (!id.match(needsEscapeRegEx))
|
|
14283
|
-
return id;
|
|
14284
|
-
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
|
14285
|
-
}
|
|
14286
|
-
|
|
14287
14475
|
function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
|
|
14288
14476
|
let nameIndex = 0;
|
|
14289
14477
|
for (const variable of exports) {
|
|
@@ -14375,14 +14563,14 @@ function getIndentString(modules, options) {
|
|
|
14375
14563
|
return '\t';
|
|
14376
14564
|
}
|
|
14377
14565
|
|
|
14378
|
-
function getStaticDependencies(chunk, orderedModules, chunkByModule) {
|
|
14566
|
+
function getStaticDependencies(chunk, orderedModules, chunkByModule, externalChunkByModule) {
|
|
14379
14567
|
const staticDependencyBlocks = [];
|
|
14380
14568
|
const handledDependencies = new Set();
|
|
14381
14569
|
for (let modulePos = orderedModules.length - 1; modulePos >= 0; modulePos--) {
|
|
14382
14570
|
const module = orderedModules[modulePos];
|
|
14383
14571
|
if (!handledDependencies.has(module)) {
|
|
14384
14572
|
const staticDependencies = [];
|
|
14385
|
-
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule);
|
|
14573
|
+
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule, externalChunkByModule);
|
|
14386
14574
|
staticDependencyBlocks.unshift(staticDependencies);
|
|
14387
14575
|
}
|
|
14388
14576
|
}
|
|
@@ -14394,11 +14582,11 @@ function getStaticDependencies(chunk, orderedModules, chunkByModule) {
|
|
|
14394
14582
|
}
|
|
14395
14583
|
return dependencies;
|
|
14396
14584
|
}
|
|
14397
|
-
function addStaticDependencies(module, staticDependencies, handledModules, chunk, chunkByModule) {
|
|
14585
|
+
function addStaticDependencies(module, staticDependencies, handledModules, chunk, chunkByModule, externalChunkByModule) {
|
|
14398
14586
|
const dependencies = module.getDependenciesToBeIncluded();
|
|
14399
14587
|
for (const dependency of dependencies) {
|
|
14400
14588
|
if (dependency instanceof ExternalModule) {
|
|
14401
|
-
staticDependencies.push(dependency);
|
|
14589
|
+
staticDependencies.push(externalChunkByModule.get(dependency));
|
|
14402
14590
|
continue;
|
|
14403
14591
|
}
|
|
14404
14592
|
const dependencyChunk = chunkByModule.get(dependency);
|
|
@@ -14408,91 +14596,29 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
|
|
|
14408
14596
|
}
|
|
14409
14597
|
if (!handledModules.has(dependency)) {
|
|
14410
14598
|
handledModules.add(dependency);
|
|
14411
|
-
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule);
|
|
14599
|
+
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule, externalChunkByModule);
|
|
14412
14600
|
}
|
|
14413
14601
|
}
|
|
14414
14602
|
}
|
|
14415
14603
|
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
if (typeof map === 'string') {
|
|
14420
|
-
map = JSON.parse(map);
|
|
14421
|
-
}
|
|
14422
|
-
if (map.mappings === '') {
|
|
14423
|
-
return {
|
|
14424
|
-
mappings: [],
|
|
14425
|
-
names: [],
|
|
14426
|
-
sources: [],
|
|
14427
|
-
version: 3
|
|
14428
|
-
};
|
|
14429
|
-
}
|
|
14430
|
-
const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
|
|
14431
|
-
return { ...map, mappings };
|
|
14432
|
-
}
|
|
14433
|
-
|
|
14434
|
-
function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemapChain }) {
|
|
14435
|
-
const renderChunkReducer = (code, result, plugin) => {
|
|
14436
|
-
if (result == null)
|
|
14437
|
-
return code;
|
|
14438
|
-
if (typeof result === 'string')
|
|
14439
|
-
result = {
|
|
14440
|
-
code: result,
|
|
14441
|
-
map: undefined
|
|
14442
|
-
};
|
|
14443
|
-
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
|
|
14444
|
-
if (result.map !== null) {
|
|
14445
|
-
const map = decodedSourcemap(result.map);
|
|
14446
|
-
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
|
|
14447
|
-
}
|
|
14448
|
-
return result.code;
|
|
14449
|
-
};
|
|
14450
|
-
return outputPluginDriver.hookReduceArg0('renderChunk', [code, renderChunk, options], renderChunkReducer);
|
|
14451
|
-
}
|
|
14452
|
-
|
|
14453
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
14454
|
-
if (isPathFragment(pattern))
|
|
14455
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14456
|
-
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
14457
|
-
if (!replacements.hasOwnProperty(type)) {
|
|
14458
|
-
return error(errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`));
|
|
14459
|
-
}
|
|
14460
|
-
const replacement = replacements[type]();
|
|
14461
|
-
if (isPathFragment(replacement))
|
|
14462
|
-
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14463
|
-
return replacement;
|
|
14464
|
-
});
|
|
14465
|
-
}
|
|
14466
|
-
function makeUnique(name, existingNames) {
|
|
14467
|
-
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14468
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14469
|
-
return name;
|
|
14470
|
-
const ext = require$$0.extname(name);
|
|
14471
|
-
name = name.substring(0, name.length - ext.length);
|
|
14472
|
-
let uniqueName, uniqueIndex = 1;
|
|
14473
|
-
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14474
|
-
;
|
|
14475
|
-
return uniqueName;
|
|
14476
|
-
}
|
|
14477
|
-
|
|
14478
|
-
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
|
|
14479
|
-
function getGlobalName(module, globals, hasExports, warn) {
|
|
14480
|
-
const globalName = typeof globals === 'function' ? globals(module.id) : globals[module.id];
|
|
14604
|
+
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
|
|
14605
|
+
function getGlobalName(chunk, globals, hasExports, warn) {
|
|
14606
|
+
const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
|
|
14481
14607
|
if (globalName) {
|
|
14482
14608
|
return globalName;
|
|
14483
14609
|
}
|
|
14484
14610
|
if (hasExports) {
|
|
14485
14611
|
warn({
|
|
14486
14612
|
code: 'MISSING_GLOBAL_NAME',
|
|
14487
|
-
guess:
|
|
14488
|
-
message: `No name was provided for external module '${
|
|
14489
|
-
source:
|
|
14613
|
+
guess: chunk.variableName,
|
|
14614
|
+
message: `No name was provided for external module '${chunk.id}' in output.globals – guessing '${chunk.variableName}'`,
|
|
14615
|
+
source: chunk.id
|
|
14490
14616
|
});
|
|
14491
|
-
return
|
|
14617
|
+
return chunk.variableName;
|
|
14492
14618
|
}
|
|
14493
14619
|
}
|
|
14494
14620
|
class Chunk {
|
|
14495
|
-
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, manualChunkAlias) {
|
|
14621
|
+
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, manualChunkAlias, getPlaceholder, bundle, inputBase, snippets) {
|
|
14496
14622
|
this.orderedModules = orderedModules;
|
|
14497
14623
|
this.inputOptions = inputOptions;
|
|
14498
14624
|
this.outputOptions = outputOptions;
|
|
@@ -14500,19 +14626,22 @@ class Chunk {
|
|
|
14500
14626
|
this.pluginDriver = pluginDriver;
|
|
14501
14627
|
this.modulesById = modulesById;
|
|
14502
14628
|
this.chunkByModule = chunkByModule;
|
|
14629
|
+
this.externalChunkByModule = externalChunkByModule;
|
|
14503
14630
|
this.facadeChunkByModule = facadeChunkByModule;
|
|
14504
14631
|
this.includedNamespaces = includedNamespaces;
|
|
14505
14632
|
this.manualChunkAlias = manualChunkAlias;
|
|
14633
|
+
this.getPlaceholder = getPlaceholder;
|
|
14634
|
+
this.bundle = bundle;
|
|
14635
|
+
this.inputBase = inputBase;
|
|
14636
|
+
this.snippets = snippets;
|
|
14506
14637
|
this.entryModules = [];
|
|
14507
14638
|
this.exportMode = 'named';
|
|
14508
14639
|
this.facadeModule = null;
|
|
14509
14640
|
this.id = null;
|
|
14510
14641
|
this.namespaceVariableName = '';
|
|
14511
|
-
this.needsExportsShim = false;
|
|
14512
14642
|
this.variableName = '';
|
|
14513
14643
|
this.accessedGlobalsByScope = new Map();
|
|
14514
14644
|
this.dependencies = new Set();
|
|
14515
|
-
this.dynamicDependencies = new Set();
|
|
14516
14645
|
this.dynamicEntryModules = [];
|
|
14517
14646
|
this.dynamicName = null;
|
|
14518
14647
|
this.exportNamesByVariable = new Map();
|
|
@@ -14522,23 +14651,23 @@ class Chunk {
|
|
|
14522
14651
|
this.implicitEntryModules = [];
|
|
14523
14652
|
this.implicitlyLoadedBefore = new Set();
|
|
14524
14653
|
this.imports = new Set();
|
|
14654
|
+
this.includedDynamicImports = null;
|
|
14525
14655
|
this.includedReexportsByModule = new Map();
|
|
14526
|
-
|
|
14527
|
-
// This may only be updated in the constructor
|
|
14656
|
+
// This may be updated in the constructor
|
|
14528
14657
|
this.isEmpty = true;
|
|
14529
14658
|
this.name = null;
|
|
14659
|
+
this.needsExportsShim = false;
|
|
14660
|
+
this.preRenderedChunkInfo = null;
|
|
14661
|
+
this.preliminaryFileName = null;
|
|
14662
|
+
this.renderedChunkInfo = null;
|
|
14530
14663
|
this.renderedDependencies = null;
|
|
14531
|
-
this.renderedExports = null;
|
|
14532
|
-
this.renderedHash = undefined;
|
|
14533
|
-
this.renderedModuleSources = new Map();
|
|
14534
14664
|
this.renderedModules = Object.create(null);
|
|
14535
|
-
this.renderedSource = null;
|
|
14536
14665
|
this.sortedExportNames = null;
|
|
14537
14666
|
this.strictFacade = false;
|
|
14538
|
-
this.usedModules = undefined;
|
|
14539
14667
|
this.execIndex = orderedModules.length > 0 ? orderedModules[0].execIndex : Infinity;
|
|
14540
14668
|
const chunkModules = new Set(orderedModules);
|
|
14541
14669
|
for (const module of orderedModules) {
|
|
14670
|
+
chunkByModule.set(module, this);
|
|
14542
14671
|
if (module.namespace.included) {
|
|
14543
14672
|
includedNamespaces.add(module);
|
|
14544
14673
|
}
|
|
@@ -14564,14 +14693,16 @@ class Chunk {
|
|
|
14564
14693
|
}
|
|
14565
14694
|
this.suggestedVariableName = makeLegal(this.generateVariableName());
|
|
14566
14695
|
}
|
|
14567
|
-
static generateFacade(inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, facadedModule, facadeName) {
|
|
14568
|
-
const chunk = new Chunk([], inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, null);
|
|
14696
|
+
static generateFacade(inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, facadedModule, facadeName, getPlaceholder, bundle, inputBase, snippets) {
|
|
14697
|
+
const chunk = new Chunk([], inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, null, getPlaceholder, bundle, inputBase, snippets);
|
|
14569
14698
|
chunk.assignFacadeName(facadeName, facadedModule);
|
|
14570
14699
|
if (!facadeChunkByModule.has(facadedModule)) {
|
|
14571
14700
|
facadeChunkByModule.set(facadedModule, chunk);
|
|
14572
14701
|
}
|
|
14573
14702
|
for (const dependency of facadedModule.getDependenciesToBeIncluded()) {
|
|
14574
|
-
chunk.dependencies.add(dependency instanceof Module
|
|
14703
|
+
chunk.dependencies.add(dependency instanceof Module
|
|
14704
|
+
? chunkByModule.get(dependency)
|
|
14705
|
+
: externalChunkByModule.get(dependency));
|
|
14575
14706
|
}
|
|
14576
14707
|
if (!chunk.dependencies.has(chunkByModule.get(facadedModule)) &&
|
|
14577
14708
|
facadedModule.info.moduleSideEffects &&
|
|
@@ -14587,17 +14718,6 @@ class Chunk {
|
|
|
14587
14718
|
const moduleExportNamesByVariable = module.getExportNamesByVariable();
|
|
14588
14719
|
for (const exposedVariable of this.exports) {
|
|
14589
14720
|
if (!moduleExportNamesByVariable.has(exposedVariable)) {
|
|
14590
|
-
if (moduleExportNamesByVariable.size === 0 &&
|
|
14591
|
-
module.isUserDefinedEntryPoint &&
|
|
14592
|
-
module.preserveSignature === 'strict' &&
|
|
14593
|
-
this.unsetOptions.has('preserveEntrySignatures')) {
|
|
14594
|
-
this.inputOptions.onwarn({
|
|
14595
|
-
code: 'EMPTY_FACADE',
|
|
14596
|
-
id: module.id,
|
|
14597
|
-
message: `To preserve the export signature of the entry module "${relativeId(module.id)}", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`,
|
|
14598
|
-
url: 'https://rollupjs.org/guide/en/#preserveentrysignatures'
|
|
14599
|
-
});
|
|
14600
|
-
}
|
|
14601
14721
|
return false;
|
|
14602
14722
|
}
|
|
14603
14723
|
}
|
|
@@ -14668,11 +14788,11 @@ class Chunk {
|
|
|
14668
14788
|
if (module.preserveSignature) {
|
|
14669
14789
|
this.strictFacade = needsStrictFacade;
|
|
14670
14790
|
}
|
|
14671
|
-
this.assignFacadeName(requiredFacades.shift(), module);
|
|
14791
|
+
this.assignFacadeName(requiredFacades.shift(), module, this.outputOptions.preserveModules);
|
|
14672
14792
|
}
|
|
14673
14793
|
}
|
|
14674
14794
|
for (const facadeName of requiredFacades) {
|
|
14675
|
-
facades.push(Chunk.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
|
|
14795
|
+
facades.push(Chunk.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName, this.getPlaceholder, this.bundle, this.inputBase, this.snippets));
|
|
14676
14796
|
}
|
|
14677
14797
|
}
|
|
14678
14798
|
for (const module of this.dynamicEntryModules) {
|
|
@@ -14699,89 +14819,24 @@ class Chunk {
|
|
|
14699
14819
|
}
|
|
14700
14820
|
return facades;
|
|
14701
14821
|
}
|
|
14702
|
-
|
|
14703
|
-
|
|
14704
|
-
|
|
14705
|
-
}
|
|
14706
|
-
const [pattern, patternName] = this.facadeModule && this.facadeModule.isUserDefinedEntryPoint
|
|
14707
|
-
? [options.entryFileNames, 'output.entryFileNames']
|
|
14708
|
-
: [options.chunkFileNames, 'output.chunkFileNames'];
|
|
14709
|
-
return makeUnique(renderNamePattern(typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, patternName, {
|
|
14710
|
-
format: () => options.format,
|
|
14711
|
-
hash: () => includeHash
|
|
14712
|
-
? this.computeContentHashWithDependencies(addons, options, existingNames)
|
|
14713
|
-
: '[hash]',
|
|
14714
|
-
name: () => this.getChunkName()
|
|
14715
|
-
}), existingNames);
|
|
14716
|
-
}
|
|
14717
|
-
generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
|
|
14718
|
-
const [{ id }] = this.orderedModules;
|
|
14719
|
-
const sanitizedId = this.outputOptions.sanitizeFileName(id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
14720
|
-
let path;
|
|
14721
|
-
const patternOpt = unsetOptions.has('entryFileNames')
|
|
14722
|
-
? '[name][assetExtname].js'
|
|
14723
|
-
: options.entryFileNames;
|
|
14724
|
-
const pattern = typeof patternOpt === 'function' ? patternOpt(this.getChunkInfo()) : patternOpt;
|
|
14725
|
-
if (isAbsolute(sanitizedId)) {
|
|
14726
|
-
const currentDir = require$$0.dirname(sanitizedId);
|
|
14727
|
-
const extension = require$$0.extname(sanitizedId);
|
|
14728
|
-
const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
|
|
14729
|
-
assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
|
|
14730
|
-
ext: () => extension.substring(1),
|
|
14731
|
-
extname: () => extension,
|
|
14732
|
-
format: () => options.format,
|
|
14733
|
-
name: () => this.getChunkName()
|
|
14734
|
-
});
|
|
14735
|
-
const currentPath = `${currentDir}/${fileName}`;
|
|
14736
|
-
const { preserveModulesRoot } = options;
|
|
14737
|
-
if (preserveModulesRoot && currentPath.startsWith(preserveModulesRoot)) {
|
|
14738
|
-
path = currentPath.slice(preserveModulesRoot.length).replace(/^[\\/]/, '');
|
|
14739
|
-
}
|
|
14740
|
-
else {
|
|
14741
|
-
path = relative(preserveModulesRelativeDir, currentPath);
|
|
14742
|
-
}
|
|
14743
|
-
}
|
|
14744
|
-
else {
|
|
14745
|
-
const extension = require$$0.extname(sanitizedId);
|
|
14746
|
-
const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
|
|
14747
|
-
assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
|
|
14748
|
-
ext: () => extension.substring(1),
|
|
14749
|
-
extname: () => extension,
|
|
14750
|
-
format: () => options.format,
|
|
14751
|
-
name: () => getAliasName(sanitizedId)
|
|
14752
|
-
});
|
|
14753
|
-
path = `_virtual/${fileName}`;
|
|
14754
|
-
}
|
|
14755
|
-
return makeUnique(normalize(path), existingNames);
|
|
14756
|
-
}
|
|
14757
|
-
getChunkInfo() {
|
|
14758
|
-
const facadeModule = this.facadeModule;
|
|
14759
|
-
const getChunkName = this.getChunkName.bind(this);
|
|
14822
|
+
generateOutputChunk(code, map, hashesByPlaceholder) {
|
|
14823
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
14824
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
14760
14825
|
return {
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14826
|
+
...renderedChunkInfo,
|
|
14827
|
+
code,
|
|
14828
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
14829
|
+
fileName: finalize(renderedChunkInfo.fileName),
|
|
14830
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
14831
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
14832
|
+
finalize(fileName),
|
|
14833
|
+
bindings
|
|
14834
|
+
])),
|
|
14835
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
14836
|
+
map,
|
|
14837
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
14771
14838
|
};
|
|
14772
14839
|
}
|
|
14773
|
-
getChunkInfoWithFileNames() {
|
|
14774
|
-
return Object.assign(this.getChunkInfo(), {
|
|
14775
|
-
code: undefined,
|
|
14776
|
-
dynamicImports: Array.from(this.dynamicDependencies, getId),
|
|
14777
|
-
fileName: this.id,
|
|
14778
|
-
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
|
|
14779
|
-
importedBindings: this.getImportedBindingsPerDependency(),
|
|
14780
|
-
imports: Array.from(this.dependencies, getId),
|
|
14781
|
-
map: undefined,
|
|
14782
|
-
referencedFiles: this.getReferencedFiles()
|
|
14783
|
-
});
|
|
14784
|
-
}
|
|
14785
14840
|
getChunkName() {
|
|
14786
14841
|
var _a;
|
|
14787
14842
|
return ((_a = this.name) !== null && _a !== void 0 ? _a : (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
@@ -14790,25 +14845,61 @@ class Chunk {
|
|
|
14790
14845
|
var _a;
|
|
14791
14846
|
return ((_a = this.sortedExportNames) !== null && _a !== void 0 ? _a : (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14792
14847
|
}
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14848
|
+
getFileName() {
|
|
14849
|
+
var _a;
|
|
14850
|
+
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14851
|
+
}
|
|
14852
|
+
getImportPath(importer) {
|
|
14853
|
+
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd', true));
|
|
14854
|
+
}
|
|
14855
|
+
getPreliminaryFileName() {
|
|
14856
|
+
var _a;
|
|
14857
|
+
if (this.preliminaryFileName) {
|
|
14858
|
+
return this.preliminaryFileName;
|
|
14859
|
+
}
|
|
14860
|
+
let fileName;
|
|
14861
|
+
let hashPlaceholder = null;
|
|
14862
|
+
const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
|
|
14863
|
+
if (file) {
|
|
14864
|
+
fileName = require$$0.basename(file);
|
|
14865
|
+
}
|
|
14866
|
+
else if (this.fileName !== null) {
|
|
14867
|
+
fileName = this.fileName;
|
|
14868
|
+
}
|
|
14869
|
+
else {
|
|
14870
|
+
const [pattern, patternName] = preserveModules || ((_a = this.facadeModule) === null || _a === void 0 ? void 0 : _a.isUserDefinedEntryPoint)
|
|
14871
|
+
? [entryFileNames, 'output.entryFileNames']
|
|
14872
|
+
: [chunkFileNames, 'output.chunkFileNames'];
|
|
14873
|
+
fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
14874
|
+
format: () => format,
|
|
14875
|
+
hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
|
|
14876
|
+
name: () => this.getChunkName()
|
|
14877
|
+
});
|
|
14878
|
+
if (!hashPlaceholder) {
|
|
14879
|
+
fileName = makeUnique(fileName, this.bundle);
|
|
14800
14880
|
}
|
|
14801
|
-
|
|
14881
|
+
}
|
|
14882
|
+
if (!hashPlaceholder) {
|
|
14883
|
+
this.bundle[fileName] = FILE_PLACEHOLDER;
|
|
14884
|
+
}
|
|
14885
|
+
// Caching is essential to not conflict with the file name reservation above
|
|
14886
|
+
return (this.preliminaryFileName = { fileName, hashPlaceholder });
|
|
14887
|
+
}
|
|
14888
|
+
getRenderedChunkInfo() {
|
|
14889
|
+
if (this.renderedChunkInfo) {
|
|
14890
|
+
return this.renderedChunkInfo;
|
|
14891
|
+
}
|
|
14892
|
+
const resolveFileName = (dependency) => dependency.getFileName();
|
|
14893
|
+
return (this.renderedChunkInfo = {
|
|
14894
|
+
...this.getPreRenderedChunkInfo(),
|
|
14895
|
+
dynamicImports: this.getDynamicDependencies().map(resolveFileName),
|
|
14896
|
+
fileName: this.getFileName(),
|
|
14897
|
+
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, resolveFileName),
|
|
14898
|
+
importedBindings: getImportedBindingsPerDependency(this.getRenderedDependencies(), resolveFileName),
|
|
14899
|
+
imports: Array.from(this.dependencies, resolveFileName),
|
|
14900
|
+
modules: this.renderedModules,
|
|
14901
|
+
referencedFiles: this.getReferencedFiles()
|
|
14802
14902
|
});
|
|
14803
|
-
hash.update(hashAugmentation);
|
|
14804
|
-
hash.update(this.renderedSource.toString());
|
|
14805
|
-
hash.update(this.getExportNames()
|
|
14806
|
-
.map(exportName => {
|
|
14807
|
-
const variable = this.exportsByName.get(exportName);
|
|
14808
|
-
return `${relativeId(variable.module.id).replace(/\\/g, '/')}:${variable.name}:${exportName}`;
|
|
14809
|
-
})
|
|
14810
|
-
.join(','));
|
|
14811
|
-
return (this.renderedHash = hash.digest('hex'));
|
|
14812
14903
|
}
|
|
14813
14904
|
getVariableExportName(variable) {
|
|
14814
14905
|
if (this.outputOptions.preserveModules && variable instanceof NamespaceVariable) {
|
|
@@ -14817,225 +14908,63 @@ class Chunk {
|
|
|
14817
14908
|
return this.exportNamesByVariable.get(variable)[0];
|
|
14818
14909
|
}
|
|
14819
14910
|
link() {
|
|
14820
|
-
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule);
|
|
14911
|
+
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule, this.externalChunkByModule);
|
|
14821
14912
|
for (const module of this.orderedModules) {
|
|
14822
|
-
this.
|
|
14823
|
-
this.addDependenciesToChunk(module.implicitlyLoadedBefore, this.implicitlyLoadedBefore);
|
|
14913
|
+
this.addImplicitlyLoadedBeforeFromModule(module);
|
|
14824
14914
|
this.setUpChunkImportsAndExportsForModule(module);
|
|
14825
14915
|
}
|
|
14826
14916
|
}
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
const {
|
|
14830
|
-
|
|
14831
|
-
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
dynamicImportFunction: options.dynamicImportFunction,
|
|
14835
|
-
exportNamesByVariable: this.exportNamesByVariable,
|
|
14836
|
-
format: options.format,
|
|
14837
|
-
freeze: options.freeze,
|
|
14838
|
-
indent: this.indentString,
|
|
14839
|
-
namespaceToStringTag: options.namespaceToStringTag,
|
|
14840
|
-
outputPluginDriver: this.pluginDriver,
|
|
14841
|
-
snippets
|
|
14842
|
-
};
|
|
14843
|
-
// for static and dynamic entry points, inline the execution list to avoid loading latency
|
|
14844
|
-
if (options.hoistTransitiveImports &&
|
|
14845
|
-
!this.outputOptions.preserveModules &&
|
|
14846
|
-
this.facadeModule !== null) {
|
|
14847
|
-
for (const dep of this.dependencies) {
|
|
14917
|
+
async render() {
|
|
14918
|
+
const { dependencies, exportMode, facadeModule, inputOptions: { onwarn }, outputOptions, pluginDriver, snippets } = this;
|
|
14919
|
+
const { format, hoistTransitiveImports, preserveModules } = outputOptions;
|
|
14920
|
+
// for static and dynamic entry points, add transitive dependencies to this
|
|
14921
|
+
// chunk's dependencies to avoid loading latency
|
|
14922
|
+
if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
|
|
14923
|
+
for (const dep of dependencies) {
|
|
14848
14924
|
if (dep instanceof Chunk)
|
|
14849
14925
|
this.inlineChunkDependencies(dep);
|
|
14850
14926
|
}
|
|
14851
14927
|
}
|
|
14852
|
-
this.
|
|
14853
|
-
this.
|
|
14854
|
-
|
|
14855
|
-
const
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
renderedLength = source.length();
|
|
14861
|
-
if (renderedLength) {
|
|
14862
|
-
if (options.compact && source.lastLine().includes('//'))
|
|
14863
|
-
source.append('\n');
|
|
14864
|
-
this.renderedModuleSources.set(module, source);
|
|
14865
|
-
magicString.addSource(source);
|
|
14866
|
-
this.usedModules.push(module);
|
|
14867
|
-
}
|
|
14868
|
-
const namespace = module.namespace;
|
|
14869
|
-
if (this.includedNamespaces.has(module) && !this.outputOptions.preserveModules) {
|
|
14870
|
-
const rendered = namespace.renderBlock(renderOptions);
|
|
14871
|
-
if (namespace.renderFirst())
|
|
14872
|
-
hoistedSource += n + rendered;
|
|
14873
|
-
else
|
|
14874
|
-
magicString.addSource(new MagicString(rendered));
|
|
14875
|
-
}
|
|
14876
|
-
}
|
|
14877
|
-
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
14878
|
-
const { renderedModuleSources } = this;
|
|
14879
|
-
renderedModules[module.id] = {
|
|
14880
|
-
get code() {
|
|
14881
|
-
var _a, _b;
|
|
14882
|
-
return (_b = (_a = renderedModuleSources.get(module)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null;
|
|
14883
|
-
},
|
|
14884
|
-
originalLength: module.originalCode.length,
|
|
14885
|
-
removedExports,
|
|
14886
|
-
renderedExports,
|
|
14887
|
-
renderedLength
|
|
14888
|
-
};
|
|
14889
|
-
}
|
|
14890
|
-
if (hoistedSource)
|
|
14891
|
-
magicString.prepend(hoistedSource + n + n);
|
|
14892
|
-
if (this.needsExportsShim) {
|
|
14893
|
-
magicString.prepend(`${n}${snippets.cnst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}`);
|
|
14894
|
-
}
|
|
14895
|
-
if (options.compact) {
|
|
14896
|
-
this.renderedSource = magicString;
|
|
14897
|
-
}
|
|
14898
|
-
else {
|
|
14899
|
-
this.renderedSource = magicString.trim();
|
|
14900
|
-
}
|
|
14901
|
-
this.renderedHash = undefined;
|
|
14902
|
-
if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) {
|
|
14903
|
-
const chunkName = this.getChunkName();
|
|
14904
|
-
this.inputOptions.onwarn({
|
|
14905
|
-
chunkName,
|
|
14906
|
-
code: 'EMPTY_BUNDLE',
|
|
14907
|
-
message: `Generated an empty chunk: "${chunkName}"`
|
|
14908
|
-
});
|
|
14909
|
-
}
|
|
14910
|
-
this.setExternalRenderPaths(options, inputBase);
|
|
14911
|
-
this.renderedDependencies = this.getChunkDependencyDeclarations(options, getPropertyAccess);
|
|
14912
|
-
this.renderedExports =
|
|
14913
|
-
this.exportMode === 'none'
|
|
14914
|
-
? []
|
|
14915
|
-
: this.getChunkExportDeclarations(options.format, getPropertyAccess);
|
|
14916
|
-
}
|
|
14917
|
-
async render(options, addons, outputChunk, snippets) {
|
|
14918
|
-
timeStart('render format', 2);
|
|
14919
|
-
const format = options.format;
|
|
14920
|
-
const finalise = finalisers[format];
|
|
14921
|
-
if (options.dynamicImportFunction && format !== 'es') {
|
|
14922
|
-
this.inputOptions.onwarn(errInvalidOption('output.dynamicImportFunction', 'outputdynamicImportFunction', 'this option is ignored for formats other than "es"'));
|
|
14923
|
-
}
|
|
14924
|
-
// populate ids in the rendered declarations only here
|
|
14925
|
-
// as chunk ids known only after prerender
|
|
14926
|
-
for (const dependency of this.dependencies) {
|
|
14927
|
-
const renderedDependency = this.renderedDependencies.get(dependency);
|
|
14928
|
-
if (dependency instanceof ExternalModule) {
|
|
14929
|
-
const originalId = dependency.renderPath;
|
|
14930
|
-
renderedDependency.id = escapeId(dependency.renormalizeRenderPath
|
|
14931
|
-
? getImportPath(this.id, originalId, false, false)
|
|
14932
|
-
: originalId);
|
|
14933
|
-
}
|
|
14934
|
-
else {
|
|
14935
|
-
renderedDependency.namedExportsMode = dependency.exportMode !== 'default';
|
|
14936
|
-
renderedDependency.id = escapeId(getImportPath(this.id, dependency.id, false, true));
|
|
14937
|
-
}
|
|
14938
|
-
}
|
|
14939
|
-
this.finaliseDynamicImports(options, snippets);
|
|
14940
|
-
this.finaliseImportMetas(format, snippets);
|
|
14941
|
-
const hasExports = this.renderedExports.length !== 0 ||
|
|
14942
|
-
[...this.renderedDependencies.values()].some(dep => (dep.reexports && dep.reexports.length !== 0));
|
|
14943
|
-
let topLevelAwaitModule = null;
|
|
14944
|
-
const accessedGlobals = new Set();
|
|
14945
|
-
for (const module of this.orderedModules) {
|
|
14946
|
-
if (module.usesTopLevelAwait) {
|
|
14947
|
-
topLevelAwaitModule = module.id;
|
|
14948
|
-
}
|
|
14949
|
-
const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
|
|
14950
|
-
if (accessedGlobalVariables) {
|
|
14951
|
-
for (const name of accessedGlobalVariables) {
|
|
14952
|
-
accessedGlobals.add(name);
|
|
14953
|
-
}
|
|
14954
|
-
}
|
|
14955
|
-
}
|
|
14956
|
-
if (topLevelAwaitModule !== null && format !== 'es' && format !== 'system') {
|
|
14957
|
-
return error({
|
|
14958
|
-
code: 'INVALID_TLA_FORMAT',
|
|
14959
|
-
id: topLevelAwaitModule,
|
|
14960
|
-
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
14961
|
-
});
|
|
14962
|
-
}
|
|
14963
|
-
/* istanbul ignore next */
|
|
14964
|
-
if (!this.id) {
|
|
14965
|
-
throw new Error('Internal Error: expecting chunk id');
|
|
14966
|
-
}
|
|
14967
|
-
const magicString = finalise(this.renderedSource, {
|
|
14928
|
+
const preliminaryFileName = this.getPreliminaryFileName();
|
|
14929
|
+
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
14930
|
+
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
14931
|
+
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
14932
|
+
const hasExports = renderedExports.length !== 0 ||
|
|
14933
|
+
renderedDependencies.some(dep => (dep.reexports && dep.reexports.length !== 0));
|
|
14934
|
+
const { intro, outro, banner, footer } = await createAddons(outputOptions, pluginDriver, this.getRenderedChunkInfo());
|
|
14935
|
+
finalisers[format](renderedSource, {
|
|
14968
14936
|
accessedGlobals,
|
|
14969
|
-
dependencies:
|
|
14970
|
-
exports:
|
|
14937
|
+
dependencies: renderedDependencies,
|
|
14938
|
+
exports: renderedExports,
|
|
14971
14939
|
hasExports,
|
|
14972
|
-
id:
|
|
14973
|
-
indent
|
|
14974
|
-
intro
|
|
14975
|
-
isEntryFacade:
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
outro
|
|
14940
|
+
id: preliminaryFileName.fileName,
|
|
14941
|
+
indent,
|
|
14942
|
+
intro,
|
|
14943
|
+
isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry),
|
|
14944
|
+
isModuleFacade: facadeModule !== null,
|
|
14945
|
+
namedExportsMode: exportMode !== 'default',
|
|
14946
|
+
onwarn,
|
|
14947
|
+
outro,
|
|
14980
14948
|
snippets,
|
|
14981
|
-
usesTopLevelAwait
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
code: prevCode,
|
|
14994
|
-
options,
|
|
14995
|
-
outputPluginDriver: this.pluginDriver,
|
|
14996
|
-
renderChunk: outputChunk,
|
|
14997
|
-
sourcemapChain: chunkSourcemapChain
|
|
14998
|
-
});
|
|
14999
|
-
if (options.sourcemap) {
|
|
15000
|
-
timeStart('sourcemap', 2);
|
|
15001
|
-
let file;
|
|
15002
|
-
if (options.file)
|
|
15003
|
-
file = require$$0.resolve(options.sourcemapFile || options.file);
|
|
15004
|
-
else if (options.dir)
|
|
15005
|
-
file = require$$0.resolve(options.dir, this.id);
|
|
15006
|
-
else
|
|
15007
|
-
file = require$$0.resolve(this.id);
|
|
15008
|
-
const decodedMap = magicString.generateDecodedMap({});
|
|
15009
|
-
map = collapseSourcemaps(file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources, this.inputOptions.onwarn);
|
|
15010
|
-
map.sources = map.sources
|
|
15011
|
-
.map(sourcePath => {
|
|
15012
|
-
const { sourcemapPathTransform } = options;
|
|
15013
|
-
if (sourcemapPathTransform) {
|
|
15014
|
-
const newSourcePath = sourcemapPathTransform(sourcePath, `${file}.map`);
|
|
15015
|
-
if (typeof newSourcePath !== 'string') {
|
|
15016
|
-
error(errFailedValidation(`sourcemapPathTransform function must return a string.`));
|
|
15017
|
-
}
|
|
15018
|
-
return newSourcePath;
|
|
15019
|
-
}
|
|
15020
|
-
return sourcePath;
|
|
15021
|
-
})
|
|
15022
|
-
.map(normalize);
|
|
15023
|
-
timeEnd('sourcemap', 2);
|
|
15024
|
-
}
|
|
15025
|
-
if (!options.compact && code[code.length - 1] !== '\n')
|
|
15026
|
-
code += '\n';
|
|
15027
|
-
return { code, map };
|
|
14949
|
+
usesTopLevelAwait
|
|
14950
|
+
}, outputOptions);
|
|
14951
|
+
if (banner)
|
|
14952
|
+
magicString.prepend(banner);
|
|
14953
|
+
if (footer)
|
|
14954
|
+
magicString.append(footer);
|
|
14955
|
+
return {
|
|
14956
|
+
chunk: this,
|
|
14957
|
+
magicString,
|
|
14958
|
+
preliminaryFileName,
|
|
14959
|
+
usedModules
|
|
14960
|
+
};
|
|
15028
14961
|
}
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
}
|
|
15036
|
-
}
|
|
15037
|
-
else {
|
|
15038
|
-
chunkDependencies.add(module);
|
|
14962
|
+
addImplicitlyLoadedBeforeFromModule(baseModule) {
|
|
14963
|
+
const { implicitlyLoadedBefore } = this;
|
|
14964
|
+
for (const module of baseModule.implicitlyLoadedBefore) {
|
|
14965
|
+
const chunk = this.chunkByModule.get(module);
|
|
14966
|
+
if (chunk && chunk !== this) {
|
|
14967
|
+
implicitlyLoadedBefore.add(chunk);
|
|
15039
14968
|
}
|
|
15040
14969
|
}
|
|
15041
14970
|
}
|
|
@@ -15048,12 +14977,15 @@ class Chunk {
|
|
|
15048
14977
|
}
|
|
15049
14978
|
}
|
|
15050
14979
|
}
|
|
15051
|
-
assignFacadeName({ fileName, name }, facadedModule) {
|
|
14980
|
+
assignFacadeName({ fileName, name }, facadedModule, preservePath) {
|
|
15052
14981
|
if (fileName) {
|
|
15053
14982
|
this.fileName = fileName;
|
|
15054
14983
|
}
|
|
15055
14984
|
else {
|
|
15056
|
-
this.name = this.outputOptions.sanitizeFileName(name ||
|
|
14985
|
+
this.name = this.outputOptions.sanitizeFileName(name ||
|
|
14986
|
+
(preservePath
|
|
14987
|
+
? this.getPreserveModulesChunkNameFromModule(facadedModule)
|
|
14988
|
+
: getChunkNameFromModule(facadedModule)));
|
|
15057
14989
|
}
|
|
15058
14990
|
}
|
|
15059
14991
|
checkCircularDependencyImport(variable, importingModule) {
|
|
@@ -15073,27 +15005,6 @@ class Chunk {
|
|
|
15073
15005
|
} while (alternativeReexportModule);
|
|
15074
15006
|
}
|
|
15075
15007
|
}
|
|
15076
|
-
computeContentHashWithDependencies(addons, options, existingNames) {
|
|
15077
|
-
const hash = createHash();
|
|
15078
|
-
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].join(':'));
|
|
15079
|
-
hash.update(options.format);
|
|
15080
|
-
const dependenciesForHashing = new Set([this]);
|
|
15081
|
-
for (const current of dependenciesForHashing) {
|
|
15082
|
-
if (current instanceof ExternalModule) {
|
|
15083
|
-
hash.update(`:${current.renderPath}`);
|
|
15084
|
-
}
|
|
15085
|
-
else {
|
|
15086
|
-
hash.update(current.getRenderedHash());
|
|
15087
|
-
hash.update(current.generateId(addons, options, existingNames, false));
|
|
15088
|
-
}
|
|
15089
|
-
if (current instanceof ExternalModule)
|
|
15090
|
-
continue;
|
|
15091
|
-
for (const dependency of [...current.dependencies, ...current.dynamicDependencies]) {
|
|
15092
|
-
dependenciesForHashing.add(dependency);
|
|
15093
|
-
}
|
|
15094
|
-
}
|
|
15095
|
-
return hash.digest('hex').substr(0, 8);
|
|
15096
|
-
}
|
|
15097
15008
|
ensureReexportsAreAvailableForModule(module) {
|
|
15098
15009
|
const includedReexports = [];
|
|
15099
15010
|
const map = module.getExportNamesByVariable();
|
|
@@ -15121,35 +15032,6 @@ class Chunk {
|
|
|
15121
15032
|
this.includedReexportsByModule.set(module, includedReexports);
|
|
15122
15033
|
}
|
|
15123
15034
|
}
|
|
15124
|
-
finaliseDynamicImports(options, snippets) {
|
|
15125
|
-
const stripKnownJsExtensions = options.format === 'amd';
|
|
15126
|
-
for (const [module, code] of this.renderedModuleSources) {
|
|
15127
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
15128
|
-
const chunk = this.chunkByModule.get(resolution);
|
|
15129
|
-
const facadeChunk = this.facadeChunkByModule.get(resolution);
|
|
15130
|
-
if (!resolution || !node.included || chunk === this) {
|
|
15131
|
-
continue;
|
|
15132
|
-
}
|
|
15133
|
-
const renderedResolution = resolution instanceof Module
|
|
15134
|
-
? `'${escapeId(getImportPath(this.id, (facadeChunk || chunk).id, stripKnownJsExtensions, true))}'`
|
|
15135
|
-
: resolution instanceof ExternalModule
|
|
15136
|
-
? `'${escapeId(resolution.renormalizeRenderPath
|
|
15137
|
-
? getImportPath(this.id, resolution.renderPath, stripKnownJsExtensions, false)
|
|
15138
|
-
: resolution.renderPath)}'`
|
|
15139
|
-
: resolution;
|
|
15140
|
-
node.renderFinalResolution(code, renderedResolution, resolution instanceof Module &&
|
|
15141
|
-
!(facadeChunk === null || facadeChunk === void 0 ? void 0 : facadeChunk.strictFacade) &&
|
|
15142
|
-
chunk.exportNamesByVariable.get(resolution.namespace)[0], snippets);
|
|
15143
|
-
}
|
|
15144
|
-
}
|
|
15145
|
-
}
|
|
15146
|
-
finaliseImportMetas(format, snippets) {
|
|
15147
|
-
for (const [module, code] of this.renderedModuleSources) {
|
|
15148
|
-
for (const importMeta of module.importMetas) {
|
|
15149
|
-
importMeta.renderFinalMechanism(code, this.id, format, snippets, this.pluginDriver);
|
|
15150
|
-
}
|
|
15151
|
-
}
|
|
15152
|
-
}
|
|
15153
15035
|
generateVariableName() {
|
|
15154
15036
|
if (this.manualChunkAlias) {
|
|
15155
15037
|
return this.manualChunkAlias;
|
|
@@ -15163,31 +15045,7 @@ class Chunk {
|
|
|
15163
15045
|
}
|
|
15164
15046
|
return 'chunk';
|
|
15165
15047
|
}
|
|
15166
|
-
|
|
15167
|
-
const importSpecifiers = this.getImportSpecifiers(getPropertyAccess);
|
|
15168
|
-
const reexportSpecifiers = this.getReexportSpecifiers();
|
|
15169
|
-
const dependencyDeclaration = new Map();
|
|
15170
|
-
for (const dep of this.dependencies) {
|
|
15171
|
-
const imports = importSpecifiers.get(dep) || null;
|
|
15172
|
-
const reexports = reexportSpecifiers.get(dep) || null;
|
|
15173
|
-
const namedExportsMode = dep instanceof ExternalModule || dep.exportMode !== 'default';
|
|
15174
|
-
dependencyDeclaration.set(dep, {
|
|
15175
|
-
defaultVariableName: dep.defaultVariableName,
|
|
15176
|
-
globalName: (dep instanceof ExternalModule &&
|
|
15177
|
-
(options.format === 'umd' || options.format === 'iife') &&
|
|
15178
|
-
getGlobalName(dep, options.globals, (imports || reexports) !== null, this.inputOptions.onwarn)),
|
|
15179
|
-
id: undefined,
|
|
15180
|
-
imports,
|
|
15181
|
-
isChunk: dep instanceof Chunk,
|
|
15182
|
-
name: dep.variableName,
|
|
15183
|
-
namedExportsMode,
|
|
15184
|
-
namespaceVariableName: dep.namespaceVariableName,
|
|
15185
|
-
reexports
|
|
15186
|
-
});
|
|
15187
|
-
}
|
|
15188
|
-
return dependencyDeclaration;
|
|
15189
|
-
}
|
|
15190
|
-
getChunkExportDeclarations(format, getPropertyAccess) {
|
|
15048
|
+
getChunkExportDeclarations(format) {
|
|
15191
15049
|
const exports = [];
|
|
15192
15050
|
for (const exportName of this.getExportNames()) {
|
|
15193
15051
|
if (exportName[0] === '*')
|
|
@@ -15200,7 +15058,7 @@ class Chunk {
|
|
|
15200
15058
|
}
|
|
15201
15059
|
let expression = null;
|
|
15202
15060
|
let hoisted = false;
|
|
15203
|
-
let local = variable.getName(getPropertyAccess);
|
|
15061
|
+
let local = variable.getName(this.snippets.getPropertyAccess);
|
|
15204
15062
|
if (variable instanceof LocalVariable) {
|
|
15205
15063
|
for (const declaration of variable.declarations) {
|
|
15206
15064
|
if (declaration.parent instanceof FunctionDeclaration ||
|
|
@@ -15234,16 +15092,17 @@ class Chunk {
|
|
|
15234
15092
|
if (addNonNamespacesAndInteropHelpers || variable.isNamespace) {
|
|
15235
15093
|
const module = variable.module;
|
|
15236
15094
|
if (module instanceof ExternalModule) {
|
|
15237
|
-
|
|
15095
|
+
const chunk = this.externalChunkByModule.get(module);
|
|
15096
|
+
dependencies.add(chunk);
|
|
15238
15097
|
if (addNonNamespacesAndInteropHelpers) {
|
|
15239
15098
|
if (variable.name === 'default') {
|
|
15240
15099
|
if (defaultInteropHelpersByInteropType[String(interop(module.id))]) {
|
|
15241
|
-
deconflictedDefault.add(
|
|
15100
|
+
deconflictedDefault.add(chunk);
|
|
15242
15101
|
}
|
|
15243
15102
|
}
|
|
15244
15103
|
else if (variable.name === '*') {
|
|
15245
15104
|
if (namespaceInteropHelpersByInteropType[String(interop(module.id))]) {
|
|
15246
|
-
deconflictedNamespace.add(
|
|
15105
|
+
deconflictedNamespace.add(chunk);
|
|
15247
15106
|
}
|
|
15248
15107
|
}
|
|
15249
15108
|
}
|
|
@@ -15268,6 +15127,15 @@ class Chunk {
|
|
|
15268
15127
|
}
|
|
15269
15128
|
return { deconflictedDefault, deconflictedNamespace, dependencies };
|
|
15270
15129
|
}
|
|
15130
|
+
getDynamicDependencies() {
|
|
15131
|
+
return this.getIncludedDynamicImports()
|
|
15132
|
+
.map(resolvedDynamicImport => resolvedDynamicImport.facadeChunk ||
|
|
15133
|
+
resolvedDynamicImport.chunk ||
|
|
15134
|
+
resolvedDynamicImport.externalChunk ||
|
|
15135
|
+
resolvedDynamicImport.resolution)
|
|
15136
|
+
.filter((resolution) => resolution !== this &&
|
|
15137
|
+
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
15138
|
+
}
|
|
15271
15139
|
getFallbackChunkName() {
|
|
15272
15140
|
if (this.manualChunkAlias) {
|
|
15273
15141
|
return this.manualChunkAlias;
|
|
@@ -15280,7 +15148,7 @@ class Chunk {
|
|
|
15280
15148
|
}
|
|
15281
15149
|
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
|
|
15282
15150
|
}
|
|
15283
|
-
getImportSpecifiers(
|
|
15151
|
+
getImportSpecifiers() {
|
|
15284
15152
|
const { interop } = this.outputOptions;
|
|
15285
15153
|
const importsByDependency = new Map();
|
|
15286
15154
|
for (const variable of this.imports) {
|
|
@@ -15288,7 +15156,7 @@ class Chunk {
|
|
|
15288
15156
|
let dependency;
|
|
15289
15157
|
let imported;
|
|
15290
15158
|
if (module instanceof ExternalModule) {
|
|
15291
|
-
dependency = module;
|
|
15159
|
+
dependency = this.externalChunkByModule.get(module);
|
|
15292
15160
|
imported = variable.name;
|
|
15293
15161
|
if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
|
|
15294
15162
|
return error(errUnexpectedNamedImport(module.id, imported, false));
|
|
@@ -15300,28 +15168,76 @@ class Chunk {
|
|
|
15300
15168
|
}
|
|
15301
15169
|
getOrCreate(importsByDependency, dependency, () => []).push({
|
|
15302
15170
|
imported,
|
|
15303
|
-
local: variable.getName(getPropertyAccess)
|
|
15171
|
+
local: variable.getName(this.snippets.getPropertyAccess)
|
|
15304
15172
|
});
|
|
15305
15173
|
}
|
|
15306
15174
|
return importsByDependency;
|
|
15307
15175
|
}
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
if (declaration.reexports) {
|
|
15318
|
-
for (const { imported } of declaration.reexports) {
|
|
15319
|
-
specifiers.add(imported);
|
|
15176
|
+
getIncludedDynamicImports() {
|
|
15177
|
+
if (this.includedDynamicImports) {
|
|
15178
|
+
return this.includedDynamicImports;
|
|
15179
|
+
}
|
|
15180
|
+
const includedDynamicImports = [];
|
|
15181
|
+
for (const module of this.orderedModules) {
|
|
15182
|
+
for (const { node, resolution } of module.dynamicImports) {
|
|
15183
|
+
if (!node.included) {
|
|
15184
|
+
continue;
|
|
15320
15185
|
}
|
|
15186
|
+
includedDynamicImports.push(resolution instanceof Module
|
|
15187
|
+
? {
|
|
15188
|
+
chunk: this.chunkByModule.get(resolution),
|
|
15189
|
+
externalChunk: null,
|
|
15190
|
+
facadeChunk: this.facadeChunkByModule.get(resolution),
|
|
15191
|
+
node,
|
|
15192
|
+
resolution
|
|
15193
|
+
}
|
|
15194
|
+
: resolution instanceof ExternalModule
|
|
15195
|
+
? {
|
|
15196
|
+
chunk: null,
|
|
15197
|
+
externalChunk: this.externalChunkByModule.get(resolution),
|
|
15198
|
+
facadeChunk: null,
|
|
15199
|
+
node,
|
|
15200
|
+
resolution
|
|
15201
|
+
}
|
|
15202
|
+
: { chunk: null, externalChunk: null, facadeChunk: null, node, resolution });
|
|
15321
15203
|
}
|
|
15322
|
-
importSpecifiers[dependency.id] = [...specifiers];
|
|
15323
15204
|
}
|
|
15324
|
-
return
|
|
15205
|
+
return (this.includedDynamicImports = includedDynamicImports);
|
|
15206
|
+
}
|
|
15207
|
+
getPreRenderedChunkInfo() {
|
|
15208
|
+
if (this.preRenderedChunkInfo) {
|
|
15209
|
+
return this.preRenderedChunkInfo;
|
|
15210
|
+
}
|
|
15211
|
+
const { facadeModule } = this;
|
|
15212
|
+
return (this.preRenderedChunkInfo = {
|
|
15213
|
+
exports: this.getExportNames(),
|
|
15214
|
+
facadeModuleId: facadeModule && facadeModule.id,
|
|
15215
|
+
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
15216
|
+
isEntry: !!(facadeModule === null || facadeModule === void 0 ? void 0 : facadeModule.info.isEntry),
|
|
15217
|
+
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
15218
|
+
moduleIds: this.orderedModules.map(({ id }) => id),
|
|
15219
|
+
name: this.getChunkName(),
|
|
15220
|
+
type: 'chunk'
|
|
15221
|
+
});
|
|
15222
|
+
}
|
|
15223
|
+
getPreserveModulesChunkNameFromModule(module) {
|
|
15224
|
+
const predefinedChunkName = getPredefinedChunkNameFromModule(module);
|
|
15225
|
+
if (predefinedChunkName)
|
|
15226
|
+
return predefinedChunkName;
|
|
15227
|
+
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
15228
|
+
const sanitizedId = sanitizeFileName(module.id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
15229
|
+
const extName = require$$0.extname(sanitizedId);
|
|
15230
|
+
const idWithoutExtension = NON_ASSET_EXTENSIONS.includes(extName)
|
|
15231
|
+
? sanitizedId.slice(0, -extName.length)
|
|
15232
|
+
: sanitizedId;
|
|
15233
|
+
if (isAbsolute(idWithoutExtension)) {
|
|
15234
|
+
return preserveModulesRoot && idWithoutExtension.startsWith(preserveModulesRoot)
|
|
15235
|
+
? idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[\\/]/, '')
|
|
15236
|
+
: relative(this.inputBase, idWithoutExtension);
|
|
15237
|
+
}
|
|
15238
|
+
else {
|
|
15239
|
+
return `_virtual/${require$$0.basename(idWithoutExtension)}`;
|
|
15240
|
+
}
|
|
15325
15241
|
}
|
|
15326
15242
|
getReexportSpecifiers() {
|
|
15327
15243
|
const { externalLiveBindings, interop } = this.outputOptions;
|
|
@@ -15336,7 +15252,7 @@ class Chunk {
|
|
|
15336
15252
|
this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id));
|
|
15337
15253
|
}
|
|
15338
15254
|
needsLiveBinding = externalLiveBindings;
|
|
15339
|
-
dependency = this.modulesById.get(id);
|
|
15255
|
+
dependency = this.externalChunkByModule.get(this.modulesById.get(id));
|
|
15340
15256
|
imported = exportName = '*';
|
|
15341
15257
|
}
|
|
15342
15258
|
else {
|
|
@@ -15352,7 +15268,7 @@ class Chunk {
|
|
|
15352
15268
|
needsLiveBinding = variable.isReassigned;
|
|
15353
15269
|
}
|
|
15354
15270
|
else {
|
|
15355
|
-
dependency = module;
|
|
15271
|
+
dependency = this.externalChunkByModule.get(module);
|
|
15356
15272
|
imported = variable.name;
|
|
15357
15273
|
if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
|
|
15358
15274
|
return error(errUnexpectedNamedImport(module.id, imported, true));
|
|
@@ -15371,16 +15287,45 @@ class Chunk {
|
|
|
15371
15287
|
return reexportSpecifiers;
|
|
15372
15288
|
}
|
|
15373
15289
|
getReferencedFiles() {
|
|
15374
|
-
const referencedFiles =
|
|
15290
|
+
const referencedFiles = new Set();
|
|
15375
15291
|
for (const module of this.orderedModules) {
|
|
15376
15292
|
for (const meta of module.importMetas) {
|
|
15377
15293
|
const fileName = meta.getReferencedFileName(this.pluginDriver);
|
|
15378
15294
|
if (fileName) {
|
|
15379
|
-
referencedFiles.
|
|
15295
|
+
referencedFiles.add(fileName);
|
|
15380
15296
|
}
|
|
15381
15297
|
}
|
|
15382
15298
|
}
|
|
15383
|
-
return referencedFiles;
|
|
15299
|
+
return [...referencedFiles];
|
|
15300
|
+
}
|
|
15301
|
+
getRenderedDependencies() {
|
|
15302
|
+
if (this.renderedDependencies) {
|
|
15303
|
+
return this.renderedDependencies;
|
|
15304
|
+
}
|
|
15305
|
+
const importSpecifiers = this.getImportSpecifiers();
|
|
15306
|
+
const reexportSpecifiers = this.getReexportSpecifiers();
|
|
15307
|
+
const renderedDependencies = new Map();
|
|
15308
|
+
const fileName = this.getFileName();
|
|
15309
|
+
for (const dep of this.dependencies) {
|
|
15310
|
+
const imports = importSpecifiers.get(dep) || null;
|
|
15311
|
+
const reexports = reexportSpecifiers.get(dep) || null;
|
|
15312
|
+
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
15313
|
+
const importPath = dep.getImportPath(fileName);
|
|
15314
|
+
renderedDependencies.set(dep, {
|
|
15315
|
+
defaultVariableName: dep.defaultVariableName,
|
|
15316
|
+
globalName: dep instanceof ExternalChunk &&
|
|
15317
|
+
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
15318
|
+
getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onwarn),
|
|
15319
|
+
importPath,
|
|
15320
|
+
imports,
|
|
15321
|
+
isChunk: dep instanceof Chunk,
|
|
15322
|
+
name: dep.variableName,
|
|
15323
|
+
namedExportsMode,
|
|
15324
|
+
namespaceVariableName: dep.namespaceVariableName,
|
|
15325
|
+
reexports
|
|
15326
|
+
});
|
|
15327
|
+
}
|
|
15328
|
+
return (this.renderedDependencies = renderedDependencies);
|
|
15384
15329
|
}
|
|
15385
15330
|
inlineChunkDependencies(chunk) {
|
|
15386
15331
|
for (const dep of chunk.dependencies) {
|
|
@@ -15392,42 +15337,111 @@ class Chunk {
|
|
|
15392
15337
|
}
|
|
15393
15338
|
}
|
|
15394
15339
|
}
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
const
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
|
|
15403
|
-
|
|
15404
|
-
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15408
|
-
|
|
15409
|
-
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15340
|
+
// This method changes properties on the AST before rendering and must not be async
|
|
15341
|
+
renderModules(fileName) {
|
|
15342
|
+
const { dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onwarn }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
|
|
15343
|
+
const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag, preserveModules } = outputOptions;
|
|
15344
|
+
const { _, n } = snippets;
|
|
15345
|
+
this.setDynamicImportResolutions(fileName);
|
|
15346
|
+
this.setImportMetaResolutions(fileName);
|
|
15347
|
+
this.setIdentifierRenderResolutions();
|
|
15348
|
+
const magicString = new Bundle$1({ separator: `${n}${n}` });
|
|
15349
|
+
const indent = getIndentString(orderedModules, outputOptions);
|
|
15350
|
+
const usedModules = [];
|
|
15351
|
+
let hoistedSource = '';
|
|
15352
|
+
const accessedGlobals = new Set();
|
|
15353
|
+
const renderedModuleSources = new Map();
|
|
15354
|
+
const renderOptions = {
|
|
15355
|
+
dynamicImportFunction,
|
|
15356
|
+
exportNamesByVariable,
|
|
15357
|
+
format,
|
|
15358
|
+
freeze,
|
|
15359
|
+
indent,
|
|
15360
|
+
namespaceToStringTag,
|
|
15361
|
+
pluginDriver,
|
|
15362
|
+
snippets
|
|
15363
|
+
};
|
|
15364
|
+
let usesTopLevelAwait = false;
|
|
15365
|
+
for (const module of orderedModules) {
|
|
15366
|
+
let renderedLength = 0;
|
|
15367
|
+
let source;
|
|
15368
|
+
if (module.isIncluded() || includedNamespaces.has(module)) {
|
|
15369
|
+
const rendered = module.render(renderOptions);
|
|
15370
|
+
({ source } = rendered);
|
|
15371
|
+
usesTopLevelAwait || (usesTopLevelAwait = rendered.usesTopLevelAwait);
|
|
15372
|
+
renderedLength = source.length();
|
|
15373
|
+
if (renderedLength) {
|
|
15374
|
+
if (compact && source.lastLine().includes('//'))
|
|
15375
|
+
source.append('\n');
|
|
15376
|
+
renderedModuleSources.set(module, source);
|
|
15377
|
+
magicString.addSource(source);
|
|
15378
|
+
usedModules.push(module);
|
|
15379
|
+
}
|
|
15380
|
+
const namespace = module.namespace;
|
|
15381
|
+
if (includedNamespaces.has(module) && !preserveModules) {
|
|
15382
|
+
const rendered = namespace.renderBlock(renderOptions);
|
|
15383
|
+
if (namespace.renderFirst())
|
|
15384
|
+
hoistedSource += n + rendered;
|
|
15385
|
+
else
|
|
15386
|
+
magicString.addSource(new MagicString(rendered));
|
|
15387
|
+
}
|
|
15388
|
+
const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
|
|
15389
|
+
if (accessedGlobalVariables) {
|
|
15390
|
+
for (const name of accessedGlobalVariables) {
|
|
15391
|
+
accessedGlobals.add(name);
|
|
15392
|
+
}
|
|
15393
|
+
}
|
|
15420
15394
|
}
|
|
15395
|
+
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
15396
|
+
renderedModules[module.id] = {
|
|
15397
|
+
get code() {
|
|
15398
|
+
var _a;
|
|
15399
|
+
return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
|
|
15400
|
+
},
|
|
15401
|
+
originalLength: module.originalCode.length,
|
|
15402
|
+
removedExports,
|
|
15403
|
+
renderedExports,
|
|
15404
|
+
renderedLength
|
|
15405
|
+
};
|
|
15406
|
+
}
|
|
15407
|
+
if (hoistedSource)
|
|
15408
|
+
magicString.prepend(hoistedSource + n + n);
|
|
15409
|
+
if (this.needsExportsShim) {
|
|
15410
|
+
magicString.prepend(`${n}${snippets.cnst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}`);
|
|
15411
|
+
}
|
|
15412
|
+
const renderedSource = compact ? magicString : magicString.trim();
|
|
15413
|
+
if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
|
|
15414
|
+
const chunkName = this.getChunkName();
|
|
15415
|
+
onwarn({
|
|
15416
|
+
chunkName,
|
|
15417
|
+
code: 'EMPTY_BUNDLE',
|
|
15418
|
+
message: `Generated an empty chunk: "${chunkName}"`
|
|
15419
|
+
});
|
|
15421
15420
|
}
|
|
15421
|
+
return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
|
|
15422
15422
|
}
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15423
|
+
setDynamicImportResolutions(fileName) {
|
|
15424
|
+
const { accessedGlobalsByScope, outputOptions, pluginDriver, snippets } = this;
|
|
15425
|
+
for (const resolvedDynamicImport of this.getIncludedDynamicImports()) {
|
|
15426
|
+
if (resolvedDynamicImport.chunk) {
|
|
15427
|
+
const { chunk, facadeChunk, node, resolution } = resolvedDynamicImport;
|
|
15428
|
+
if (chunk === this) {
|
|
15429
|
+
node.setInternalResolution(resolution.namespace);
|
|
15430
|
+
}
|
|
15431
|
+
else {
|
|
15432
|
+
node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !(facadeChunk === null || facadeChunk === void 0 ? void 0 : facadeChunk.strictFacade) && chunk.exportNamesByVariable.get(resolution.namespace)[0]);
|
|
15433
|
+
}
|
|
15434
|
+
}
|
|
15435
|
+
else {
|
|
15436
|
+
const { resolution } = resolvedDynamicImport;
|
|
15437
|
+
resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolution instanceof ExternalModule
|
|
15438
|
+
? `'${this.externalChunkByModule.get(resolution).getImportPath(fileName)}'`
|
|
15439
|
+
: resolution || '', false);
|
|
15427
15440
|
}
|
|
15428
15441
|
}
|
|
15429
15442
|
}
|
|
15430
|
-
setIdentifierRenderResolutions(
|
|
15443
|
+
setIdentifierRenderResolutions() {
|
|
15444
|
+
const { format, interop, namespaceToStringTag } = this.outputOptions;
|
|
15431
15445
|
const syntheticExports = new Set();
|
|
15432
15446
|
for (const exportName of this.getExportNames()) {
|
|
15433
15447
|
const exportVariable = this.exportsByName.get(exportName);
|
|
@@ -15472,7 +15486,18 @@ class Chunk {
|
|
|
15472
15486
|
usedNames.add(helper);
|
|
15473
15487
|
}
|
|
15474
15488
|
}
|
|
15475
|
-
deconflictChunk(this.orderedModules, this.getDependenciesToBeDeconflicted(format !== 'es' && format !== 'system', format === 'amd' || format === 'umd' || format === 'iife', interop), this.imports, usedNames, format, interop, this.outputOptions.preserveModules, this.outputOptions.externalLiveBindings, this.chunkByModule, syntheticExports, this.exportNamesByVariable, this.accessedGlobalsByScope, this.includedNamespaces);
|
|
15489
|
+
deconflictChunk(this.orderedModules, this.getDependenciesToBeDeconflicted(format !== 'es' && format !== 'system', format === 'amd' || format === 'umd' || format === 'iife', interop), this.imports, usedNames, format, interop, this.outputOptions.preserveModules, this.outputOptions.externalLiveBindings, this.chunkByModule, this.externalChunkByModule, syntheticExports, this.exportNamesByVariable, this.accessedGlobalsByScope, this.includedNamespaces);
|
|
15490
|
+
}
|
|
15491
|
+
setImportMetaResolutions(fileName) {
|
|
15492
|
+
const { accessedGlobalsByScope, includedNamespaces, outputOptions: { format, preserveModules } } = this;
|
|
15493
|
+
for (const module of this.orderedModules) {
|
|
15494
|
+
for (const importMeta of module.importMetas) {
|
|
15495
|
+
importMeta.setResolution(format, accessedGlobalsByScope, fileName);
|
|
15496
|
+
}
|
|
15497
|
+
if (includedNamespaces.has(module) && !preserveModules) {
|
|
15498
|
+
module.namespace.prepare(accessedGlobalsByScope);
|
|
15499
|
+
}
|
|
15500
|
+
}
|
|
15476
15501
|
}
|
|
15477
15502
|
setUpChunkImportsAndExportsForModule(module) {
|
|
15478
15503
|
const moduleImports = new Set(module.includedImports);
|
|
@@ -15520,325 +15545,89 @@ class Chunk {
|
|
|
15520
15545
|
}
|
|
15521
15546
|
}
|
|
15522
15547
|
function getChunkNameFromModule(module) {
|
|
15523
|
-
var _a
|
|
15524
|
-
return (
|
|
15548
|
+
var _a;
|
|
15549
|
+
return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
|
|
15525
15550
|
}
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
15530
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
15531
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
15532
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
15533
|
-
ext: () => require$$0.extname(emittedName).substring(1),
|
|
15534
|
-
extname: () => require$$0.extname(emittedName),
|
|
15535
|
-
hash() {
|
|
15536
|
-
return createHash()
|
|
15537
|
-
.update(emittedName)
|
|
15538
|
-
.update(':')
|
|
15539
|
-
.update(source)
|
|
15540
|
-
.digest('hex')
|
|
15541
|
-
.substring(0, 8);
|
|
15542
|
-
},
|
|
15543
|
-
name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
|
|
15544
|
-
}), bundle);
|
|
15551
|
+
function getPredefinedChunkNameFromModule(module) {
|
|
15552
|
+
var _a, _b, _c;
|
|
15553
|
+
return ((_b = (_a = module.chunkNames.find(({ isUserDefined }) => isUserDefined)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = module.chunkNames[0]) === null || _c === void 0 ? void 0 : _c.name);
|
|
15545
15554
|
}
|
|
15546
|
-
function
|
|
15547
|
-
|
|
15548
|
-
|
|
15555
|
+
function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
|
|
15556
|
+
const importedBindingsPerDependency = {};
|
|
15557
|
+
for (const [dependency, declaration] of renderedDependencies) {
|
|
15558
|
+
const specifiers = new Set();
|
|
15559
|
+
if (declaration.imports) {
|
|
15560
|
+
for (const { imported } of declaration.imports) {
|
|
15561
|
+
specifiers.add(imported);
|
|
15562
|
+
}
|
|
15563
|
+
}
|
|
15564
|
+
if (declaration.reexports) {
|
|
15565
|
+
for (const { imported } of declaration.reexports) {
|
|
15566
|
+
specifiers.add(imported);
|
|
15567
|
+
}
|
|
15568
|
+
}
|
|
15569
|
+
importedBindingsPerDependency[resolveFileName(dependency)] = [...specifiers];
|
|
15549
15570
|
}
|
|
15550
|
-
|
|
15551
|
-
}
|
|
15552
|
-
const FILE_PLACEHOLDER = {
|
|
15553
|
-
type: 'placeholder'
|
|
15554
|
-
};
|
|
15555
|
-
function hasValidType(emittedFile) {
|
|
15556
|
-
return Boolean(emittedFile &&
|
|
15557
|
-
(emittedFile.type === 'asset' ||
|
|
15558
|
-
emittedFile.type === 'chunk'));
|
|
15559
|
-
}
|
|
15560
|
-
function hasValidName(emittedFile) {
|
|
15561
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
15562
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
15571
|
+
return importedBindingsPerDependency;
|
|
15563
15572
|
}
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15567
|
-
|
|
15573
|
+
const QUERY_HASH_REGEX = /[?#]/;
|
|
15574
|
+
|
|
15575
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
15576
|
+
const chunkDefinitions = [];
|
|
15577
|
+
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
15578
|
+
const manualChunkModulesByAlias = Object.create(null);
|
|
15579
|
+
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
15580
|
+
const chunkModules = (manualChunkModulesByAlias[alias] =
|
|
15581
|
+
manualChunkModulesByAlias[alias] || []);
|
|
15582
|
+
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15568
15583
|
}
|
|
15569
|
-
|
|
15570
|
-
}
|
|
15571
|
-
function getAssetFileName(file, referenceId) {
|
|
15572
|
-
if (typeof file.fileName !== 'string') {
|
|
15573
|
-
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
15584
|
+
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15585
|
+
chunkDefinitions.push({ alias, modules });
|
|
15574
15586
|
}
|
|
15575
|
-
|
|
15576
|
-
}
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
this.graph = graph;
|
|
15587
|
-
this.options = options;
|
|
15588
|
-
this.bundle = null;
|
|
15589
|
-
this.facadeChunkByModule = null;
|
|
15590
|
-
this.outputOptions = null;
|
|
15591
|
-
this.assertAssetsFinalized = () => {
|
|
15592
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
15593
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
15594
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
15595
|
-
}
|
|
15596
|
-
};
|
|
15597
|
-
this.emitFile = (emittedFile) => {
|
|
15598
|
-
if (!hasValidType(emittedFile)) {
|
|
15599
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
15600
|
-
}
|
|
15601
|
-
if (!hasValidName(emittedFile)) {
|
|
15602
|
-
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
15603
|
-
}
|
|
15604
|
-
if (emittedFile.type === 'chunk') {
|
|
15605
|
-
return this.emitChunk(emittedFile);
|
|
15606
|
-
}
|
|
15607
|
-
return this.emitAsset(emittedFile);
|
|
15608
|
-
};
|
|
15609
|
-
this.getFileName = (fileReferenceId) => {
|
|
15610
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
15611
|
-
if (!emittedFile)
|
|
15612
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
15613
|
-
if (emittedFile.type === 'chunk') {
|
|
15614
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
15615
|
-
}
|
|
15616
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
15617
|
-
};
|
|
15618
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
15619
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
15620
|
-
if (!consumedFile)
|
|
15621
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
15622
|
-
if (consumedFile.type !== 'asset') {
|
|
15623
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
15624
|
-
}
|
|
15625
|
-
if (consumedFile.source !== undefined) {
|
|
15626
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
15627
|
-
}
|
|
15628
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
15629
|
-
if (this.bundle) {
|
|
15630
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
15587
|
+
const assignedEntryPointsByModule = new Map();
|
|
15588
|
+
const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
|
|
15589
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
|
|
15590
|
+
const staticEntries = new Set(entryModules);
|
|
15591
|
+
function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
|
|
15592
|
+
const modulesToHandle = new Set([entry]);
|
|
15593
|
+
for (const module of modulesToHandle) {
|
|
15594
|
+
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
15595
|
+
if (dynamicDependentEntryPoints &&
|
|
15596
|
+
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
15597
|
+
continue;
|
|
15631
15598
|
}
|
|
15632
15599
|
else {
|
|
15633
|
-
|
|
15634
|
-
}
|
|
15635
|
-
};
|
|
15636
|
-
this.setOutputBundle = (outputBundle, outputOptions, facadeChunkByModule) => {
|
|
15637
|
-
this.outputOptions = outputOptions;
|
|
15638
|
-
this.bundle = outputBundle;
|
|
15639
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
15640
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
15641
|
-
if (emittedFile.fileName) {
|
|
15642
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
15643
|
-
}
|
|
15600
|
+
assignedEntryPoints.add(entry);
|
|
15644
15601
|
}
|
|
15645
|
-
for (const
|
|
15646
|
-
if (
|
|
15647
|
-
|
|
15602
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15603
|
+
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15604
|
+
modulesToHandle.add(dependency);
|
|
15648
15605
|
}
|
|
15649
15606
|
}
|
|
15650
|
-
}
|
|
15651
|
-
this.filesByReferenceId = baseFileEmitter
|
|
15652
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
15653
|
-
: new Map();
|
|
15654
|
-
}
|
|
15655
|
-
assignReferenceId(file, idBase) {
|
|
15656
|
-
let referenceId;
|
|
15657
|
-
do {
|
|
15658
|
-
referenceId = createHash()
|
|
15659
|
-
.update(referenceId || idBase)
|
|
15660
|
-
.digest('hex')
|
|
15661
|
-
.substring(0, 8);
|
|
15662
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
15663
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
15664
|
-
return referenceId;
|
|
15607
|
+
}
|
|
15665
15608
|
}
|
|
15666
|
-
|
|
15667
|
-
const
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
15677
|
-
if (this.bundle) {
|
|
15678
|
-
if (emittedAsset.fileName) {
|
|
15679
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
15680
|
-
}
|
|
15681
|
-
if (source !== undefined) {
|
|
15682
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
15609
|
+
function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
|
|
15610
|
+
const entriesToCheck = new Set(entryPoints);
|
|
15611
|
+
for (const entry of entriesToCheck) {
|
|
15612
|
+
if (!containedIn.has(entry)) {
|
|
15613
|
+
if (staticEntries.has(entry))
|
|
15614
|
+
return false;
|
|
15615
|
+
const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
|
|
15616
|
+
for (const dependentEntry of dynamicallyDependentEntryPoints) {
|
|
15617
|
+
entriesToCheck.add(dependentEntry);
|
|
15618
|
+
}
|
|
15683
15619
|
}
|
|
15684
15620
|
}
|
|
15685
|
-
return
|
|
15621
|
+
return true;
|
|
15686
15622
|
}
|
|
15687
|
-
|
|
15688
|
-
if (
|
|
15689
|
-
|
|
15623
|
+
for (const entry of entryModules) {
|
|
15624
|
+
if (!modulesInManualChunks.has(entry)) {
|
|
15625
|
+
assignEntryToStaticDependencies(entry, null);
|
|
15690
15626
|
}
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
fileName: emittedChunk.fileName,
|
|
15696
|
-
module: null,
|
|
15697
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
15698
|
-
type: 'chunk'
|
|
15699
|
-
};
|
|
15700
|
-
this.graph.moduleLoader
|
|
15701
|
-
.emitChunk(emittedChunk)
|
|
15702
|
-
.then(module => (consumedChunk.module = module))
|
|
15703
|
-
.catch(() => {
|
|
15704
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
15705
|
-
// once module loading has finished
|
|
15706
|
-
});
|
|
15707
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
15708
|
-
}
|
|
15709
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
15710
|
-
const fileName = consumedFile.fileName ||
|
|
15711
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
15712
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
15713
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
15714
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
15715
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
15716
|
-
const { options } = this;
|
|
15717
|
-
bundle[fileName] = {
|
|
15718
|
-
fileName,
|
|
15719
|
-
get isAsset() {
|
|
15720
|
-
warnDeprecation('Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', true, options);
|
|
15721
|
-
return true;
|
|
15722
|
-
},
|
|
15723
|
-
name: consumedFile.name,
|
|
15724
|
-
source,
|
|
15725
|
-
type: 'asset'
|
|
15726
|
-
};
|
|
15727
|
-
}
|
|
15728
|
-
}
|
|
15729
|
-
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
15730
|
-
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
15731
|
-
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
15732
|
-
return fileName;
|
|
15733
|
-
}
|
|
15734
|
-
return null;
|
|
15735
|
-
}
|
|
15736
|
-
function areSourcesEqual(sourceA, sourceB) {
|
|
15737
|
-
if (typeof sourceA === 'string') {
|
|
15738
|
-
return sourceA === sourceB;
|
|
15739
|
-
}
|
|
15740
|
-
if (typeof sourceB === 'string') {
|
|
15741
|
-
return false;
|
|
15742
|
-
}
|
|
15743
|
-
if ('equals' in sourceA) {
|
|
15744
|
-
return sourceA.equals(sourceB);
|
|
15745
|
-
}
|
|
15746
|
-
if (sourceA.length !== sourceB.length) {
|
|
15747
|
-
return false;
|
|
15748
|
-
}
|
|
15749
|
-
for (let index = 0; index < sourceA.length; index++) {
|
|
15750
|
-
if (sourceA[index] !== sourceB[index]) {
|
|
15751
|
-
return false;
|
|
15752
|
-
}
|
|
15753
|
-
}
|
|
15754
|
-
return true;
|
|
15755
|
-
}
|
|
15756
|
-
|
|
15757
|
-
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
15758
|
-
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
15759
|
-
async function createAddons(options, outputPluginDriver) {
|
|
15760
|
-
try {
|
|
15761
|
-
let [banner, footer, intro, outro] = await Promise.all([
|
|
15762
|
-
outputPluginDriver.hookReduceValue('banner', options.banner(), [], concatSep),
|
|
15763
|
-
outputPluginDriver.hookReduceValue('footer', options.footer(), [], concatSep),
|
|
15764
|
-
outputPluginDriver.hookReduceValue('intro', options.intro(), [], concatDblSep),
|
|
15765
|
-
outputPluginDriver.hookReduceValue('outro', options.outro(), [], concatDblSep)
|
|
15766
|
-
]);
|
|
15767
|
-
if (intro)
|
|
15768
|
-
intro += '\n\n';
|
|
15769
|
-
if (outro)
|
|
15770
|
-
outro = `\n\n${outro}`;
|
|
15771
|
-
if (banner.length)
|
|
15772
|
-
banner += '\n';
|
|
15773
|
-
if (footer.length)
|
|
15774
|
-
footer = '\n' + footer;
|
|
15775
|
-
return { banner, footer, intro, outro };
|
|
15776
|
-
}
|
|
15777
|
-
catch (err) {
|
|
15778
|
-
return error({
|
|
15779
|
-
code: 'ADDON_ERROR',
|
|
15780
|
-
message: `Could not retrieve ${err.hook}. Check configuration of plugin ${err.plugin}.
|
|
15781
|
-
\tError Message: ${err.message}`
|
|
15782
|
-
});
|
|
15783
|
-
}
|
|
15784
|
-
}
|
|
15785
|
-
|
|
15786
|
-
function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
15787
|
-
const chunkDefinitions = [];
|
|
15788
|
-
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
15789
|
-
const manualChunkModulesByAlias = Object.create(null);
|
|
15790
|
-
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
15791
|
-
const chunkModules = (manualChunkModulesByAlias[alias] =
|
|
15792
|
-
manualChunkModulesByAlias[alias] || []);
|
|
15793
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15794
|
-
}
|
|
15795
|
-
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15796
|
-
chunkDefinitions.push({ alias, modules });
|
|
15797
|
-
}
|
|
15798
|
-
const assignedEntryPointsByModule = new Map();
|
|
15799
|
-
const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
|
|
15800
|
-
const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
|
|
15801
|
-
const staticEntries = new Set(entryModules);
|
|
15802
|
-
function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
|
|
15803
|
-
const modulesToHandle = new Set([entry]);
|
|
15804
|
-
for (const module of modulesToHandle) {
|
|
15805
|
-
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
15806
|
-
if (dynamicDependentEntryPoints &&
|
|
15807
|
-
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
15808
|
-
continue;
|
|
15809
|
-
}
|
|
15810
|
-
else {
|
|
15811
|
-
assignedEntryPoints.add(entry);
|
|
15812
|
-
}
|
|
15813
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15814
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15815
|
-
modulesToHandle.add(dependency);
|
|
15816
|
-
}
|
|
15817
|
-
}
|
|
15818
|
-
}
|
|
15819
|
-
}
|
|
15820
|
-
function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
|
|
15821
|
-
const entriesToCheck = new Set(entryPoints);
|
|
15822
|
-
for (const entry of entriesToCheck) {
|
|
15823
|
-
if (!containedIn.has(entry)) {
|
|
15824
|
-
if (staticEntries.has(entry))
|
|
15825
|
-
return false;
|
|
15826
|
-
const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
|
|
15827
|
-
for (const dependentEntry of dynamicallyDependentEntryPoints) {
|
|
15828
|
-
entriesToCheck.add(dependentEntry);
|
|
15829
|
-
}
|
|
15830
|
-
}
|
|
15831
|
-
}
|
|
15832
|
-
return true;
|
|
15833
|
-
}
|
|
15834
|
-
for (const entry of entryModules) {
|
|
15835
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
15836
|
-
assignEntryToStaticDependencies(entry, null);
|
|
15837
|
-
}
|
|
15838
|
-
}
|
|
15839
|
-
for (const entry of dynamicEntryModules) {
|
|
15840
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
15841
|
-
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15627
|
+
}
|
|
15628
|
+
for (const entry of dynamicEntryModules) {
|
|
15629
|
+
if (!modulesInManualChunks.has(entry)) {
|
|
15630
|
+
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15842
15631
|
}
|
|
15843
15632
|
}
|
|
15844
15633
|
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
@@ -15913,156 +15702,500 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
|
15913
15702
|
chunkModules[chunkSignature] = [module];
|
|
15914
15703
|
}
|
|
15915
15704
|
}
|
|
15916
|
-
return Object.values(chunkModules).map(modules => ({
|
|
15917
|
-
alias: null,
|
|
15918
|
-
modules
|
|
15919
|
-
}));
|
|
15705
|
+
return Object.values(chunkModules).map(modules => ({
|
|
15706
|
+
alias: null,
|
|
15707
|
+
modules
|
|
15708
|
+
}));
|
|
15709
|
+
}
|
|
15710
|
+
|
|
15711
|
+
// ported from https://github.com/substack/node-commondir
|
|
15712
|
+
function commondir(files) {
|
|
15713
|
+
if (files.length === 0)
|
|
15714
|
+
return '/';
|
|
15715
|
+
if (files.length === 1)
|
|
15716
|
+
return require$$0.dirname(files[0]);
|
|
15717
|
+
const commonSegments = files.slice(1).reduce((commonSegments, file) => {
|
|
15718
|
+
const pathSegements = file.split(/\/+|\\+/);
|
|
15719
|
+
let i;
|
|
15720
|
+
for (i = 0; commonSegments[i] === pathSegements[i] &&
|
|
15721
|
+
i < Math.min(commonSegments.length, pathSegements.length); i++)
|
|
15722
|
+
;
|
|
15723
|
+
return commonSegments.slice(0, i);
|
|
15724
|
+
}, files[0].split(/\/+|\\+/));
|
|
15725
|
+
// Windows correctly handles paths with forward-slashes
|
|
15726
|
+
return commonSegments.length > 1 ? commonSegments.join('/') : '/';
|
|
15727
|
+
}
|
|
15728
|
+
|
|
15729
|
+
const compareExecIndex = (unitA, unitB) => unitA.execIndex > unitB.execIndex ? 1 : -1;
|
|
15730
|
+
function sortByExecutionOrder(units) {
|
|
15731
|
+
units.sort(compareExecIndex);
|
|
15732
|
+
}
|
|
15733
|
+
function analyseModuleExecution(entryModules) {
|
|
15734
|
+
let nextExecIndex = 0;
|
|
15735
|
+
const cyclePaths = [];
|
|
15736
|
+
const analysedModules = new Set();
|
|
15737
|
+
const dynamicImports = new Set();
|
|
15738
|
+
const parents = new Map();
|
|
15739
|
+
const orderedModules = [];
|
|
15740
|
+
const analyseModule = (module) => {
|
|
15741
|
+
if (module instanceof Module) {
|
|
15742
|
+
for (const dependency of module.dependencies) {
|
|
15743
|
+
if (parents.has(dependency)) {
|
|
15744
|
+
if (!analysedModules.has(dependency)) {
|
|
15745
|
+
cyclePaths.push(getCyclePath(dependency, module, parents));
|
|
15746
|
+
}
|
|
15747
|
+
continue;
|
|
15748
|
+
}
|
|
15749
|
+
parents.set(dependency, module);
|
|
15750
|
+
analyseModule(dependency);
|
|
15751
|
+
}
|
|
15752
|
+
for (const dependency of module.implicitlyLoadedBefore) {
|
|
15753
|
+
dynamicImports.add(dependency);
|
|
15754
|
+
}
|
|
15755
|
+
for (const { resolution } of module.dynamicImports) {
|
|
15756
|
+
if (resolution instanceof Module) {
|
|
15757
|
+
dynamicImports.add(resolution);
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
orderedModules.push(module);
|
|
15761
|
+
}
|
|
15762
|
+
module.execIndex = nextExecIndex++;
|
|
15763
|
+
analysedModules.add(module);
|
|
15764
|
+
};
|
|
15765
|
+
for (const curEntry of entryModules) {
|
|
15766
|
+
if (!parents.has(curEntry)) {
|
|
15767
|
+
parents.set(curEntry, null);
|
|
15768
|
+
analyseModule(curEntry);
|
|
15769
|
+
}
|
|
15770
|
+
}
|
|
15771
|
+
for (const curEntry of dynamicImports) {
|
|
15772
|
+
if (!parents.has(curEntry)) {
|
|
15773
|
+
parents.set(curEntry, null);
|
|
15774
|
+
analyseModule(curEntry);
|
|
15775
|
+
}
|
|
15776
|
+
}
|
|
15777
|
+
return { cyclePaths, orderedModules };
|
|
15778
|
+
}
|
|
15779
|
+
function getCyclePath(module, parent, parents) {
|
|
15780
|
+
const cycleSymbol = Symbol(module.id);
|
|
15781
|
+
const path = [relativeId(module.id)];
|
|
15782
|
+
let nextModule = parent;
|
|
15783
|
+
module.cycles.add(cycleSymbol);
|
|
15784
|
+
while (nextModule !== module) {
|
|
15785
|
+
nextModule.cycles.add(cycleSymbol);
|
|
15786
|
+
path.push(relativeId(nextModule.id));
|
|
15787
|
+
nextModule = parents.get(nextModule);
|
|
15788
|
+
}
|
|
15789
|
+
path.push(path[0]);
|
|
15790
|
+
path.reverse();
|
|
15791
|
+
return path;
|
|
15792
|
+
}
|
|
15793
|
+
|
|
15794
|
+
function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, constBindings, objectShorthand, reservedNamesAsProps } }) {
|
|
15795
|
+
const { _, n, s } = compact ? { _: '', n: '', s: '' } : { _: ' ', n: '\n', s: ';' };
|
|
15796
|
+
const cnst = constBindings ? 'const' : 'var';
|
|
15797
|
+
const getNonArrowFunctionIntro = (params, { isAsync, name }) => `${isAsync ? `async ` : ''}function${name ? ` ${name}` : ''}${_}(${params.join(`,${_}`)})${_}`;
|
|
15798
|
+
const getFunctionIntro = arrowFunctions
|
|
15799
|
+
? (params, { isAsync, name }) => {
|
|
15800
|
+
const singleParam = params.length === 1;
|
|
15801
|
+
const asyncString = isAsync ? `async${singleParam ? ' ' : _}` : '';
|
|
15802
|
+
return `${name ? `${cnst} ${name}${_}=${_}` : ''}${asyncString}${singleParam ? params[0] : `(${params.join(`,${_}`)})`}${_}=>${_}`;
|
|
15803
|
+
}
|
|
15804
|
+
: getNonArrowFunctionIntro;
|
|
15805
|
+
const getDirectReturnFunction = (params, { functionReturn, lineBreakIndent, name }) => [
|
|
15806
|
+
`${getFunctionIntro(params, {
|
|
15807
|
+
isAsync: false,
|
|
15808
|
+
name
|
|
15809
|
+
})}${arrowFunctions
|
|
15810
|
+
? lineBreakIndent
|
|
15811
|
+
? `${n}${lineBreakIndent.base}${lineBreakIndent.t}`
|
|
15812
|
+
: ''
|
|
15813
|
+
: `{${lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _}${functionReturn ? 'return ' : ''}`}`,
|
|
15814
|
+
arrowFunctions
|
|
15815
|
+
? `${name ? ';' : ''}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : ''}`
|
|
15816
|
+
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
15817
|
+
];
|
|
15818
|
+
const isValidPropName = reservedNamesAsProps
|
|
15819
|
+
? (name) => validPropName.test(name)
|
|
15820
|
+
: (name) => !RESERVED_NAMES$1.has(name) && validPropName.test(name);
|
|
15821
|
+
return {
|
|
15822
|
+
_,
|
|
15823
|
+
cnst,
|
|
15824
|
+
getDirectReturnFunction,
|
|
15825
|
+
getDirectReturnIifeLeft: (params, returned, { needsArrowReturnParens, needsWrappedFunction }) => {
|
|
15826
|
+
const [left, right] = getDirectReturnFunction(params, {
|
|
15827
|
+
functionReturn: true,
|
|
15828
|
+
lineBreakIndent: null,
|
|
15829
|
+
name: null
|
|
15830
|
+
});
|
|
15831
|
+
return `${wrapIfNeeded(`${left}${wrapIfNeeded(returned, arrowFunctions && needsArrowReturnParens)}${right}`, arrowFunctions || needsWrappedFunction)}(`;
|
|
15832
|
+
},
|
|
15833
|
+
getFunctionIntro,
|
|
15834
|
+
getNonArrowFunctionIntro,
|
|
15835
|
+
getObject(fields, { lineBreakIndent }) {
|
|
15836
|
+
const prefix = lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _;
|
|
15837
|
+
return `{${fields
|
|
15838
|
+
.map(([key, value]) => {
|
|
15839
|
+
if (key === null)
|
|
15840
|
+
return `${prefix}${value}`;
|
|
15841
|
+
const needsQuotes = !isValidPropName(key);
|
|
15842
|
+
return key === value && objectShorthand && !needsQuotes
|
|
15843
|
+
? prefix + key
|
|
15844
|
+
: `${prefix}${needsQuotes ? `'${key}'` : key}:${_}${value}`;
|
|
15845
|
+
})
|
|
15846
|
+
.join(`,`)}${fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`;
|
|
15847
|
+
},
|
|
15848
|
+
getPropertyAccess: (name) => isValidPropName(name) ? `.${name}` : `[${JSON.stringify(name)}]`,
|
|
15849
|
+
n,
|
|
15850
|
+
s
|
|
15851
|
+
};
|
|
15852
|
+
}
|
|
15853
|
+
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
15854
|
+
const validPropName = /^(?!\d)[\w$]+$/;
|
|
15855
|
+
|
|
15856
|
+
class Source {
|
|
15857
|
+
constructor(filename, content) {
|
|
15858
|
+
this.isOriginal = true;
|
|
15859
|
+
this.filename = filename;
|
|
15860
|
+
this.content = content;
|
|
15861
|
+
}
|
|
15862
|
+
traceSegment(line, column, name) {
|
|
15863
|
+
return { column, line, name, source: this };
|
|
15864
|
+
}
|
|
15865
|
+
}
|
|
15866
|
+
class Link {
|
|
15867
|
+
constructor(map, sources) {
|
|
15868
|
+
this.sources = sources;
|
|
15869
|
+
this.names = map.names;
|
|
15870
|
+
this.mappings = map.mappings;
|
|
15871
|
+
}
|
|
15872
|
+
traceMappings() {
|
|
15873
|
+
const sources = [];
|
|
15874
|
+
const sourceIndexMap = new Map();
|
|
15875
|
+
const sourcesContent = [];
|
|
15876
|
+
const names = [];
|
|
15877
|
+
const nameIndexMap = new Map();
|
|
15878
|
+
const mappings = [];
|
|
15879
|
+
for (const line of this.mappings) {
|
|
15880
|
+
const tracedLine = [];
|
|
15881
|
+
for (const segment of line) {
|
|
15882
|
+
if (segment.length === 1)
|
|
15883
|
+
continue;
|
|
15884
|
+
const source = this.sources[segment[1]];
|
|
15885
|
+
if (!source)
|
|
15886
|
+
continue;
|
|
15887
|
+
const traced = source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : '');
|
|
15888
|
+
if (traced) {
|
|
15889
|
+
const { column, line, name, source: { content, filename } } = traced;
|
|
15890
|
+
let sourceIndex = sourceIndexMap.get(filename);
|
|
15891
|
+
if (sourceIndex === undefined) {
|
|
15892
|
+
sourceIndex = sources.length;
|
|
15893
|
+
sources.push(filename);
|
|
15894
|
+
sourceIndexMap.set(filename, sourceIndex);
|
|
15895
|
+
sourcesContent[sourceIndex] = content;
|
|
15896
|
+
}
|
|
15897
|
+
else if (sourcesContent[sourceIndex] == null) {
|
|
15898
|
+
sourcesContent[sourceIndex] = content;
|
|
15899
|
+
}
|
|
15900
|
+
else if (content != null && sourcesContent[sourceIndex] !== content) {
|
|
15901
|
+
return error({
|
|
15902
|
+
message: `Multiple conflicting contents for sourcemap source ${filename}`
|
|
15903
|
+
});
|
|
15904
|
+
}
|
|
15905
|
+
const tracedSegment = [segment[0], sourceIndex, line, column];
|
|
15906
|
+
if (name) {
|
|
15907
|
+
let nameIndex = nameIndexMap.get(name);
|
|
15908
|
+
if (nameIndex === undefined) {
|
|
15909
|
+
nameIndex = names.length;
|
|
15910
|
+
names.push(name);
|
|
15911
|
+
nameIndexMap.set(name, nameIndex);
|
|
15912
|
+
}
|
|
15913
|
+
tracedSegment[4] = nameIndex;
|
|
15914
|
+
}
|
|
15915
|
+
tracedLine.push(tracedSegment);
|
|
15916
|
+
}
|
|
15917
|
+
}
|
|
15918
|
+
mappings.push(tracedLine);
|
|
15919
|
+
}
|
|
15920
|
+
return { mappings, names, sources, sourcesContent };
|
|
15921
|
+
}
|
|
15922
|
+
traceSegment(line, column, name) {
|
|
15923
|
+
const segments = this.mappings[line];
|
|
15924
|
+
if (!segments)
|
|
15925
|
+
return null;
|
|
15926
|
+
// binary search through segments for the given column
|
|
15927
|
+
let searchStart = 0;
|
|
15928
|
+
let searchEnd = segments.length - 1;
|
|
15929
|
+
while (searchStart <= searchEnd) {
|
|
15930
|
+
const m = (searchStart + searchEnd) >> 1;
|
|
15931
|
+
const segment = segments[m];
|
|
15932
|
+
// If a sourcemap does not have sufficient resolution to contain a
|
|
15933
|
+
// necessary mapping, e.g. because it only contains line information, we
|
|
15934
|
+
// use the best approximation we could find
|
|
15935
|
+
if (segment[0] === column || searchStart === searchEnd) {
|
|
15936
|
+
if (segment.length == 1)
|
|
15937
|
+
return null;
|
|
15938
|
+
const source = this.sources[segment[1]];
|
|
15939
|
+
if (!source)
|
|
15940
|
+
return null;
|
|
15941
|
+
return source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : name);
|
|
15942
|
+
}
|
|
15943
|
+
if (segment[0] > column) {
|
|
15944
|
+
searchEnd = m - 1;
|
|
15945
|
+
}
|
|
15946
|
+
else {
|
|
15947
|
+
searchStart = m + 1;
|
|
15948
|
+
}
|
|
15949
|
+
}
|
|
15950
|
+
return null;
|
|
15951
|
+
}
|
|
15952
|
+
}
|
|
15953
|
+
function getLinkMap(warn) {
|
|
15954
|
+
return function linkMap(source, map) {
|
|
15955
|
+
if (map.mappings) {
|
|
15956
|
+
return new Link(map, [source]);
|
|
15957
|
+
}
|
|
15958
|
+
warn({
|
|
15959
|
+
code: 'SOURCEMAP_BROKEN',
|
|
15960
|
+
message: `Sourcemap is likely to be incorrect: a plugin (${map.plugin}) was used to transform ` +
|
|
15961
|
+
"files, but didn't generate a sourcemap for the transformation. Consult the plugin " +
|
|
15962
|
+
'documentation for help',
|
|
15963
|
+
plugin: map.plugin,
|
|
15964
|
+
url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect`
|
|
15965
|
+
});
|
|
15966
|
+
return new Link({
|
|
15967
|
+
mappings: [],
|
|
15968
|
+
names: []
|
|
15969
|
+
}, [source]);
|
|
15970
|
+
};
|
|
15971
|
+
}
|
|
15972
|
+
function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, linkMap) {
|
|
15973
|
+
let source;
|
|
15974
|
+
if (!originalSourcemap) {
|
|
15975
|
+
source = new Source(id, originalCode);
|
|
15976
|
+
}
|
|
15977
|
+
else {
|
|
15978
|
+
const sources = originalSourcemap.sources;
|
|
15979
|
+
const sourcesContent = originalSourcemap.sourcesContent || [];
|
|
15980
|
+
const directory = require$$0.dirname(id) || '.';
|
|
15981
|
+
const sourceRoot = originalSourcemap.sourceRoot || '.';
|
|
15982
|
+
const baseSources = sources.map((source, i) => new Source(require$$0.resolve(directory, sourceRoot, source), sourcesContent[i]));
|
|
15983
|
+
source = new Link(originalSourcemap, baseSources);
|
|
15984
|
+
}
|
|
15985
|
+
return sourcemapChain.reduce(linkMap, source);
|
|
15986
|
+
}
|
|
15987
|
+
function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, warn) {
|
|
15988
|
+
const linkMap = getLinkMap(warn);
|
|
15989
|
+
const moduleSources = modules
|
|
15990
|
+
.filter(module => !module.excludeFromSourcemap)
|
|
15991
|
+
.map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
|
|
15992
|
+
const link = new Link(map, moduleSources);
|
|
15993
|
+
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
15994
|
+
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
15995
|
+
if (file) {
|
|
15996
|
+
const directory = require$$0.dirname(file);
|
|
15997
|
+
sources = sources.map((source) => require$$0.relative(directory, source));
|
|
15998
|
+
file = require$$0.basename(file);
|
|
15999
|
+
}
|
|
16000
|
+
sourcesContent = (excludeContent ? null : sourcesContent);
|
|
16001
|
+
return new SourceMap({ file, mappings, names, sources, sourcesContent });
|
|
16002
|
+
}
|
|
16003
|
+
function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn) {
|
|
16004
|
+
if (!sourcemapChain.length) {
|
|
16005
|
+
return originalSourcemap;
|
|
16006
|
+
}
|
|
16007
|
+
const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(warn));
|
|
16008
|
+
const map = source.traceMappings();
|
|
16009
|
+
return { version: 3, ...map };
|
|
15920
16010
|
}
|
|
15921
16011
|
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
}
|
|
15936
|
-
|
|
15937
|
-
return
|
|
16012
|
+
function decodedSourcemap(map) {
|
|
16013
|
+
if (!map)
|
|
16014
|
+
return null;
|
|
16015
|
+
if (typeof map === 'string') {
|
|
16016
|
+
map = JSON.parse(map);
|
|
16017
|
+
}
|
|
16018
|
+
if (map.mappings === '') {
|
|
16019
|
+
return {
|
|
16020
|
+
mappings: [],
|
|
16021
|
+
names: [],
|
|
16022
|
+
sources: [],
|
|
16023
|
+
version: 3
|
|
16024
|
+
};
|
|
16025
|
+
}
|
|
16026
|
+
const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
|
|
16027
|
+
return { ...map, mappings };
|
|
15938
16028
|
}
|
|
15939
16029
|
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
16030
|
+
async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, onwarn) {
|
|
16031
|
+
timeStart('render chunks', 2);
|
|
16032
|
+
reserveEntryChunksInBundle(chunks);
|
|
16033
|
+
const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
|
|
16034
|
+
timeEnd('render chunks', 2);
|
|
16035
|
+
timeStart('transform chunks', 2);
|
|
16036
|
+
const chunkGraph = getChunkGraph(chunks);
|
|
16037
|
+
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
16038
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle);
|
|
16039
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders);
|
|
16040
|
+
timeEnd('transform chunks', 2);
|
|
15943
16041
|
}
|
|
15944
|
-
function
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
16042
|
+
function reserveEntryChunksInBundle(chunks) {
|
|
16043
|
+
for (const chunk of chunks) {
|
|
16044
|
+
if (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint) {
|
|
16045
|
+
// reserves name in bundle as side effect if it does not contain a hash
|
|
16046
|
+
chunk.getPreliminaryFileName();
|
|
16047
|
+
}
|
|
16048
|
+
}
|
|
16049
|
+
}
|
|
16050
|
+
function getChunkGraph(chunks) {
|
|
16051
|
+
return Object.fromEntries(chunks.map(chunk => {
|
|
16052
|
+
const renderedChunkInfo = chunk.getRenderedChunkInfo();
|
|
16053
|
+
return [renderedChunkInfo.fileName, renderedChunkInfo];
|
|
16054
|
+
}));
|
|
16055
|
+
}
|
|
16056
|
+
async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, onwarn) {
|
|
16057
|
+
let map = null;
|
|
16058
|
+
const sourcemapChain = [];
|
|
16059
|
+
let code = await outputPluginDriver.hookReduceArg0('renderChunk', [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], (code, result, plugin) => {
|
|
16060
|
+
if (result == null)
|
|
16061
|
+
return code;
|
|
16062
|
+
if (typeof result === 'string')
|
|
16063
|
+
result = {
|
|
16064
|
+
code: result,
|
|
16065
|
+
map: undefined
|
|
16066
|
+
};
|
|
16067
|
+
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
|
|
16068
|
+
if (result.map !== null) {
|
|
16069
|
+
const map = decodedSourcemap(result.map);
|
|
16070
|
+
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
|
|
16071
|
+
}
|
|
16072
|
+
return result.code;
|
|
16073
|
+
});
|
|
16074
|
+
const { compact, sourcemap, sourcemapPathTransform } = options;
|
|
16075
|
+
if (!compact && code[code.length - 1] !== '\n')
|
|
16076
|
+
code += '\n';
|
|
16077
|
+
if (sourcemap) {
|
|
16078
|
+
timeStart('sourcemaps', 3);
|
|
16079
|
+
let file;
|
|
16080
|
+
if (options.file)
|
|
16081
|
+
file = require$$0.resolve(options.sourcemapFile || options.file);
|
|
16082
|
+
else if (options.dir)
|
|
16083
|
+
file = require$$0.resolve(options.dir, fileName);
|
|
16084
|
+
else
|
|
16085
|
+
file = require$$0.resolve(fileName);
|
|
16086
|
+
const decodedMap = magicString.generateDecodedMap({});
|
|
16087
|
+
map = collapseSourcemaps(file, decodedMap, usedModules, sourcemapChain, options.sourcemapExcludeSources, onwarn);
|
|
16088
|
+
map.sources = map.sources
|
|
16089
|
+
.map(sourcePath => {
|
|
16090
|
+
if (sourcemapPathTransform) {
|
|
16091
|
+
const newSourcePath = sourcemapPathTransform(sourcePath, `${file}.map`);
|
|
16092
|
+
if (typeof newSourcePath !== 'string') {
|
|
16093
|
+
error(errFailedValidation(`sourcemapPathTransform function must return a string.`));
|
|
15959
16094
|
}
|
|
15960
|
-
|
|
15961
|
-
analyseModule(dependency);
|
|
16095
|
+
return newSourcePath;
|
|
15962
16096
|
}
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
16097
|
+
return sourcePath;
|
|
16098
|
+
})
|
|
16099
|
+
.map(normalize);
|
|
16100
|
+
timeEnd('sourcemaps', 3);
|
|
16101
|
+
}
|
|
16102
|
+
return {
|
|
16103
|
+
code,
|
|
16104
|
+
map
|
|
16105
|
+
};
|
|
16106
|
+
}
|
|
16107
|
+
async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn) {
|
|
16108
|
+
const nonHashedChunksWithPlaceholders = [];
|
|
16109
|
+
const renderedChunksByPlaceholder = new Map();
|
|
16110
|
+
const hashDependenciesByPlaceholder = new Map();
|
|
16111
|
+
const placeholders = new Set();
|
|
16112
|
+
for (const { preliminaryFileName: { hashPlaceholder } } of renderedChunks) {
|
|
16113
|
+
if (hashPlaceholder)
|
|
16114
|
+
placeholders.add(hashPlaceholder);
|
|
16115
|
+
}
|
|
16116
|
+
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, magicString, usedModules }) => {
|
|
16117
|
+
const transformedChunk = {
|
|
16118
|
+
chunk,
|
|
16119
|
+
fileName,
|
|
16120
|
+
...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, onwarn))
|
|
16121
|
+
};
|
|
16122
|
+
const { code } = transformedChunk;
|
|
16123
|
+
if (hashPlaceholder) {
|
|
16124
|
+
const hash = createHash();
|
|
16125
|
+
// To create a reproducible content-only hash, all placeholders are
|
|
16126
|
+
// replaced with the same value before hashing
|
|
16127
|
+
const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
|
|
16128
|
+
hash.update(transformedCode);
|
|
16129
|
+
const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
|
|
16130
|
+
if (pluginHash) {
|
|
16131
|
+
augmentation += pluginHash;
|
|
15969
16132
|
}
|
|
16133
|
+
return augmentation;
|
|
16134
|
+
});
|
|
16135
|
+
if (hashAugmentation) {
|
|
16136
|
+
hash.update(hashAugmentation);
|
|
15970
16137
|
}
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
for (const curEntry of entryModules) {
|
|
15977
|
-
if (!parents.has(curEntry)) {
|
|
15978
|
-
parents.set(curEntry, null);
|
|
15979
|
-
analyseModule(curEntry);
|
|
16138
|
+
renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
|
|
16139
|
+
hashDependenciesByPlaceholder.set(hashPlaceholder, {
|
|
16140
|
+
containedPlaceholders,
|
|
16141
|
+
contentHash: hash.digest('hex')
|
|
16142
|
+
});
|
|
15980
16143
|
}
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
if (!parents.has(curEntry)) {
|
|
15984
|
-
parents.set(curEntry, null);
|
|
15985
|
-
analyseModule(curEntry);
|
|
16144
|
+
else {
|
|
16145
|
+
nonHashedChunksWithPlaceholders.push(transformedChunk);
|
|
15986
16146
|
}
|
|
15987
|
-
}
|
|
15988
|
-
return {
|
|
16147
|
+
}));
|
|
16148
|
+
return {
|
|
16149
|
+
hashDependenciesByPlaceholder,
|
|
16150
|
+
nonHashedChunksWithPlaceholders,
|
|
16151
|
+
renderedChunksByPlaceholder
|
|
16152
|
+
};
|
|
15989
16153
|
}
|
|
15990
|
-
function
|
|
15991
|
-
const
|
|
15992
|
-
const
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
16154
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle) {
|
|
16155
|
+
const hashesByPlaceholder = new Map();
|
|
16156
|
+
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
16157
|
+
let hash = createHash();
|
|
16158
|
+
const hashDependencyPlaceholders = new Set([placeholder]);
|
|
16159
|
+
for (const dependencyPlaceholder of hashDependencyPlaceholders) {
|
|
16160
|
+
const { containedPlaceholders, contentHash } = hashDependenciesByPlaceholder.get(dependencyPlaceholder);
|
|
16161
|
+
hash.update(contentHash);
|
|
16162
|
+
for (const containedPlaceholder of containedPlaceholders) {
|
|
16163
|
+
// When looping over a map, setting an entry only causes a new iteration if the key is new
|
|
16164
|
+
hashDependencyPlaceholders.add(containedPlaceholder);
|
|
16165
|
+
}
|
|
16166
|
+
}
|
|
16167
|
+
let finalFileName;
|
|
16168
|
+
let finalHash;
|
|
16169
|
+
do {
|
|
16170
|
+
// In case of a hash collision, create a hash of the hash
|
|
16171
|
+
if (finalHash) {
|
|
16172
|
+
hash = createHash();
|
|
16173
|
+
hash.update(finalHash);
|
|
16174
|
+
}
|
|
16175
|
+
finalHash = hash.digest('hex').slice(0, placeholder.length);
|
|
16176
|
+
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
16177
|
+
} while (outputBundle[finalFileName]);
|
|
16178
|
+
outputBundle[finalFileName] = FILE_PLACEHOLDER;
|
|
16179
|
+
hashesByPlaceholder.set(placeholder, finalHash.slice(0, placeholder.length));
|
|
15999
16180
|
}
|
|
16000
|
-
|
|
16001
|
-
path.reverse();
|
|
16002
|
-
return path;
|
|
16181
|
+
return hashesByPlaceholder;
|
|
16003
16182
|
}
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
? (params, { isAsync, name }) => {
|
|
16011
|
-
const singleParam = params.length === 1;
|
|
16012
|
-
const asyncString = isAsync ? `async${singleParam ? ' ' : _}` : '';
|
|
16013
|
-
return `${name ? `${cnst} ${name}${_}=${_}` : ''}${asyncString}${singleParam ? params[0] : `(${params.join(`,${_}`)})`}${_}=>${_}`;
|
|
16183
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders) {
|
|
16184
|
+
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16185
|
+
const updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16186
|
+
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
16187
|
+
if (map) {
|
|
16188
|
+
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16014
16189
|
}
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
: ''
|
|
16024
|
-
: `{${lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _}${functionReturn ? 'return ' : ''}`}`,
|
|
16025
|
-
arrowFunctions
|
|
16026
|
-
? `${name ? ';' : ''}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : ''}`
|
|
16027
|
-
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
16028
|
-
];
|
|
16029
|
-
const isValidPropName = reservedNamesAsProps
|
|
16030
|
-
? (name) => validPropName.test(name)
|
|
16031
|
-
: (name) => !RESERVED_NAMES$1.has(name) && validPropName.test(name);
|
|
16032
|
-
return {
|
|
16033
|
-
_,
|
|
16034
|
-
cnst,
|
|
16035
|
-
getDirectReturnFunction,
|
|
16036
|
-
getDirectReturnIifeLeft: (params, returned, { needsArrowReturnParens, needsWrappedFunction }) => {
|
|
16037
|
-
const [left, right] = getDirectReturnFunction(params, {
|
|
16038
|
-
functionReturn: true,
|
|
16039
|
-
lineBreakIndent: null,
|
|
16040
|
-
name: null
|
|
16041
|
-
});
|
|
16042
|
-
return `${wrapIfNeeded(`${left}${wrapIfNeeded(returned, arrowFunctions && needsArrowReturnParens)}${right}`, arrowFunctions || needsWrappedFunction)}(`;
|
|
16043
|
-
},
|
|
16044
|
-
getFunctionIntro,
|
|
16045
|
-
getNonArrowFunctionIntro,
|
|
16046
|
-
getObject(fields, { lineBreakIndent }) {
|
|
16047
|
-
const prefix = lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _;
|
|
16048
|
-
return `{${fields
|
|
16049
|
-
.map(([key, value]) => {
|
|
16050
|
-
if (key === null)
|
|
16051
|
-
return `${prefix}${value}`;
|
|
16052
|
-
const needsQuotes = !isValidPropName(key);
|
|
16053
|
-
return key === value && objectShorthand && !needsQuotes
|
|
16054
|
-
? prefix + key
|
|
16055
|
-
: `${prefix}${needsQuotes ? `'${key}'` : key}:${_}${value}`;
|
|
16056
|
-
})
|
|
16057
|
-
.join(`,`)}${fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`;
|
|
16058
|
-
},
|
|
16059
|
-
getPropertyAccess: (name) => isValidPropName(name) ? `.${name}` : `[${JSON.stringify(name)}]`,
|
|
16060
|
-
n,
|
|
16061
|
-
s
|
|
16062
|
-
};
|
|
16190
|
+
outputBundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16191
|
+
}
|
|
16192
|
+
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16193
|
+
const updatedCode = hashesByPlaceholder.size
|
|
16194
|
+
? replacePlaceholders(code, hashesByPlaceholder)
|
|
16195
|
+
: code;
|
|
16196
|
+
outputBundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16197
|
+
}
|
|
16063
16198
|
}
|
|
16064
|
-
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
16065
|
-
const validPropName = /^(?!\d)[\w$]+$/;
|
|
16066
16199
|
|
|
16067
16200
|
class Bundle {
|
|
16068
16201
|
constructor(outputOptions, unsetOptions, inputOptions, pluginDriver, graph) {
|
|
@@ -16077,48 +16210,39 @@ class Bundle {
|
|
|
16077
16210
|
async generate(isWrite) {
|
|
16078
16211
|
timeStart('GENERATE', 1);
|
|
16079
16212
|
const outputBundle = Object.create(null);
|
|
16080
|
-
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions
|
|
16213
|
+
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
|
|
16081
16214
|
try {
|
|
16215
|
+
timeStart('initialize render', 2);
|
|
16082
16216
|
await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
|
|
16217
|
+
timeEnd('initialize render', 2);
|
|
16083
16218
|
timeStart('generate chunks', 2);
|
|
16084
|
-
const
|
|
16219
|
+
const getHashPlaceholder = getHashPlaceholderGenerator();
|
|
16220
|
+
const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
|
|
16085
16221
|
if (chunks.length > 1) {
|
|
16086
16222
|
validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
|
|
16087
16223
|
}
|
|
16088
|
-
|
|
16224
|
+
this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
|
|
16225
|
+
for (const chunk of chunks) {
|
|
16226
|
+
chunk.generateExports();
|
|
16227
|
+
}
|
|
16089
16228
|
timeEnd('generate chunks', 2);
|
|
16090
|
-
|
|
16091
|
-
// We need to create addons before prerender because at the moment, there
|
|
16092
|
-
// can be no async code between prerender and render due to internal state
|
|
16093
|
-
const addons = await createAddons(this.outputOptions, this.pluginDriver);
|
|
16094
|
-
const snippets = getGenerateCodeSnippets(this.outputOptions);
|
|
16095
|
-
this.prerenderChunks(chunks, inputBase, snippets);
|
|
16096
|
-
timeEnd('render modules', 2);
|
|
16097
|
-
await this.addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle, snippets);
|
|
16229
|
+
await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
|
|
16098
16230
|
}
|
|
16099
16231
|
catch (err) {
|
|
16100
16232
|
await this.pluginDriver.hookParallel('renderError', [err]);
|
|
16101
16233
|
throw err;
|
|
16102
16234
|
}
|
|
16235
|
+
timeStart('generate bundle', 2);
|
|
16103
16236
|
await this.pluginDriver.hookSeq('generateBundle', [
|
|
16104
16237
|
this.outputOptions,
|
|
16105
16238
|
outputBundle,
|
|
16106
16239
|
isWrite
|
|
16107
16240
|
]);
|
|
16108
16241
|
this.finaliseAssets(outputBundle);
|
|
16242
|
+
timeEnd('generate bundle', 2);
|
|
16109
16243
|
timeEnd('GENERATE', 1);
|
|
16110
16244
|
return outputBundle;
|
|
16111
16245
|
}
|
|
16112
|
-
async addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle, snippets) {
|
|
16113
|
-
this.assignChunkIds(chunks, inputBase, addons, outputBundle);
|
|
16114
|
-
for (const chunk of chunks) {
|
|
16115
|
-
outputBundle[chunk.id] = chunk.getChunkInfoWithFileNames();
|
|
16116
|
-
}
|
|
16117
|
-
await Promise.all(chunks.map(async (chunk) => {
|
|
16118
|
-
const outputChunk = outputBundle[chunk.id];
|
|
16119
|
-
Object.assign(outputChunk, await chunk.render(this.outputOptions, addons, outputChunk, snippets));
|
|
16120
|
-
}));
|
|
16121
|
-
}
|
|
16122
16246
|
async addManualChunks(manualChunks) {
|
|
16123
16247
|
const manualChunkAliasByEntry = new Map();
|
|
16124
16248
|
const chunkEntries = await Promise.all(Object.entries(manualChunks).map(async ([alias, files]) => ({
|
|
@@ -16132,29 +16256,6 @@ class Bundle {
|
|
|
16132
16256
|
}
|
|
16133
16257
|
return manualChunkAliasByEntry;
|
|
16134
16258
|
}
|
|
16135
|
-
assignChunkIds(chunks, inputBase, addons, bundle) {
|
|
16136
|
-
const entryChunks = [];
|
|
16137
|
-
const otherChunks = [];
|
|
16138
|
-
for (const chunk of chunks) {
|
|
16139
|
-
(chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint
|
|
16140
|
-
? entryChunks
|
|
16141
|
-
: otherChunks).push(chunk);
|
|
16142
|
-
}
|
|
16143
|
-
// make sure entry chunk names take precedence with regard to deconflicting
|
|
16144
|
-
const chunksForNaming = entryChunks.concat(otherChunks);
|
|
16145
|
-
for (const chunk of chunksForNaming) {
|
|
16146
|
-
if (this.outputOptions.file) {
|
|
16147
|
-
chunk.id = require$$0.basename(this.outputOptions.file);
|
|
16148
|
-
}
|
|
16149
|
-
else if (this.outputOptions.preserveModules) {
|
|
16150
|
-
chunk.id = chunk.generateIdPreserveModules(inputBase, this.outputOptions, bundle, this.unsetOptions);
|
|
16151
|
-
}
|
|
16152
|
-
else {
|
|
16153
|
-
chunk.id = chunk.generateId(addons, this.outputOptions, bundle, true);
|
|
16154
|
-
}
|
|
16155
|
-
bundle[chunk.id] = FILE_PLACEHOLDER;
|
|
16156
|
-
}
|
|
16157
|
-
}
|
|
16158
16259
|
assignManualChunks(getManualChunk) {
|
|
16159
16260
|
const manualChunkAliasesWithEntry = [];
|
|
16160
16261
|
const manualChunksApi = {
|
|
@@ -16178,10 +16279,6 @@ class Bundle {
|
|
|
16178
16279
|
}
|
|
16179
16280
|
finaliseAssets(outputBundle) {
|
|
16180
16281
|
for (const file of Object.values(outputBundle)) {
|
|
16181
|
-
if (!file.type) {
|
|
16182
|
-
warnDeprecation('A plugin is directly adding properties to the bundle object in the "generateBundle" hook. This is deprecated and will be removed in a future Rollup version, please use "this.emitFile" instead.', true, this.inputOptions);
|
|
16183
|
-
file.type = 'asset';
|
|
16184
|
-
}
|
|
16185
16282
|
if (this.outputOptions.validate && 'code' in file) {
|
|
16186
16283
|
try {
|
|
16187
16284
|
this.graph.contextParse(file.code, {
|
|
@@ -16196,27 +16293,25 @@ class Bundle {
|
|
|
16196
16293
|
}
|
|
16197
16294
|
this.pluginDriver.finaliseAssets();
|
|
16198
16295
|
}
|
|
16199
|
-
async generateChunks() {
|
|
16200
|
-
const { manualChunks } = this.outputOptions;
|
|
16296
|
+
async generateChunks(bundle, getHashPlaceholder) {
|
|
16297
|
+
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16201
16298
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16202
16299
|
? await this.addManualChunks(manualChunks)
|
|
16203
16300
|
: this.assignManualChunks(manualChunks);
|
|
16301
|
+
const snippets = getGenerateCodeSnippets(this.outputOptions);
|
|
16302
|
+
const includedModules = getIncludedModules(this.graph.modulesById);
|
|
16303
|
+
const inputBase = commondir(getAbsoluteEntryModulePaths(includedModules, preserveModules));
|
|
16304
|
+
const externalChunkByModule = getExternalChunkByModule(this.graph.modulesById, this.outputOptions, inputBase);
|
|
16204
16305
|
const chunks = [];
|
|
16205
16306
|
const chunkByModule = new Map();
|
|
16206
|
-
for (const { alias, modules } of
|
|
16207
|
-
? [{ alias: null, modules:
|
|
16208
|
-
:
|
|
16209
|
-
?
|
|
16210
|
-
alias: null,
|
|
16211
|
-
modules: [module]
|
|
16212
|
-
}))
|
|
16307
|
+
for (const { alias, modules } of inlineDynamicImports
|
|
16308
|
+
? [{ alias: null, modules: includedModules }]
|
|
16309
|
+
: preserveModules
|
|
16310
|
+
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16213
16311
|
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
16214
16312
|
sortByExecutionOrder(modules);
|
|
16215
|
-
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias);
|
|
16313
|
+
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
|
|
16216
16314
|
chunks.push(chunk);
|
|
16217
|
-
for (const module of modules) {
|
|
16218
|
-
chunkByModule.set(module, chunk);
|
|
16219
|
-
}
|
|
16220
16315
|
}
|
|
16221
16316
|
for (const chunk of chunks) {
|
|
16222
16317
|
chunk.link();
|
|
@@ -16227,25 +16322,6 @@ class Bundle {
|
|
|
16227
16322
|
}
|
|
16228
16323
|
return [...chunks, ...facades];
|
|
16229
16324
|
}
|
|
16230
|
-
prerenderChunks(chunks, inputBase, snippets) {
|
|
16231
|
-
for (const chunk of chunks) {
|
|
16232
|
-
chunk.generateExports();
|
|
16233
|
-
}
|
|
16234
|
-
for (const chunk of chunks) {
|
|
16235
|
-
chunk.preRender(this.outputOptions, inputBase, snippets);
|
|
16236
|
-
}
|
|
16237
|
-
}
|
|
16238
|
-
}
|
|
16239
|
-
function getAbsoluteEntryModulePaths(chunks) {
|
|
16240
|
-
const absoluteEntryModulePaths = [];
|
|
16241
|
-
for (const chunk of chunks) {
|
|
16242
|
-
for (const entryModule of chunk.entryModules) {
|
|
16243
|
-
if (isAbsolute(entryModule.id)) {
|
|
16244
|
-
absoluteEntryModulePaths.push(entryModule.id);
|
|
16245
|
-
}
|
|
16246
|
-
}
|
|
16247
|
-
}
|
|
16248
|
-
return absoluteEntryModulePaths;
|
|
16249
16325
|
}
|
|
16250
16326
|
function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
|
|
16251
16327
|
if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
|
|
@@ -16258,8 +16334,32 @@ function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
|
|
|
16258
16334
|
onWarn(errInvalidOption('output.amd.id', 'outputamd', 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
|
|
16259
16335
|
}
|
|
16260
16336
|
function getIncludedModules(modulesById) {
|
|
16261
|
-
|
|
16262
|
-
|
|
16337
|
+
const includedModules = [];
|
|
16338
|
+
for (const module of modulesById.values()) {
|
|
16339
|
+
if (module instanceof Module &&
|
|
16340
|
+
(module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0)) {
|
|
16341
|
+
includedModules.push(module);
|
|
16342
|
+
}
|
|
16343
|
+
}
|
|
16344
|
+
return includedModules;
|
|
16345
|
+
}
|
|
16346
|
+
function getAbsoluteEntryModulePaths(includedModules, preserveModules) {
|
|
16347
|
+
const absoluteEntryModulePaths = [];
|
|
16348
|
+
for (const module of includedModules) {
|
|
16349
|
+
if ((module.info.isEntry || preserveModules) && isAbsolute(module.id)) {
|
|
16350
|
+
absoluteEntryModulePaths.push(module.id);
|
|
16351
|
+
}
|
|
16352
|
+
}
|
|
16353
|
+
return absoluteEntryModulePaths;
|
|
16354
|
+
}
|
|
16355
|
+
function getExternalChunkByModule(modulesById, outputOptions, inputBase) {
|
|
16356
|
+
const externalChunkByModule = new Map();
|
|
16357
|
+
for (const module of modulesById.values()) {
|
|
16358
|
+
if (module instanceof ExternalModule) {
|
|
16359
|
+
externalChunkByModule.set(module, new ExternalChunk(module, outputOptions, inputBase));
|
|
16360
|
+
}
|
|
16361
|
+
}
|
|
16362
|
+
return externalChunkByModule;
|
|
16263
16363
|
}
|
|
16264
16364
|
function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
16265
16365
|
const existingAlias = manualChunkAliasByEntry.get(module);
|
|
@@ -21870,7 +21970,7 @@ async function findFile(file, preserveSymlinks) {
|
|
|
21870
21970
|
return file;
|
|
21871
21971
|
}
|
|
21872
21972
|
}
|
|
21873
|
-
catch
|
|
21973
|
+
catch {
|
|
21874
21974
|
// suppress
|
|
21875
21975
|
}
|
|
21876
21976
|
}
|
|
@@ -21893,21 +21993,6 @@ function throwPluginError(err, plugin, { hook, id } = {}) {
|
|
|
21893
21993
|
}
|
|
21894
21994
|
return error(err);
|
|
21895
21995
|
}
|
|
21896
|
-
const deprecatedHooks = [
|
|
21897
|
-
{ active: true, deprecated: 'resolveAssetUrl', replacement: 'resolveFileUrl' }
|
|
21898
|
-
];
|
|
21899
|
-
function warnDeprecatedHooks(plugins, options) {
|
|
21900
|
-
for (const { active, deprecated, replacement } of deprecatedHooks) {
|
|
21901
|
-
for (const plugin of plugins) {
|
|
21902
|
-
if (deprecated in plugin) {
|
|
21903
|
-
warnDeprecation({
|
|
21904
|
-
message: `The "${deprecated}" hook used by plugin ${plugin.name} is deprecated. The "${replacement}" hook should be used instead.`,
|
|
21905
|
-
plugin: plugin.name
|
|
21906
|
-
}, active, options);
|
|
21907
|
-
}
|
|
21908
|
-
}
|
|
21909
|
-
}
|
|
21910
|
-
}
|
|
21911
21996
|
|
|
21912
21997
|
function createPluginCache(cache) {
|
|
21913
21998
|
return {
|
|
@@ -22049,14 +22134,6 @@ async function transform(source, module, pluginDriver, warn) {
|
|
|
22049
22134
|
cache: customTransformCache
|
|
22050
22135
|
? pluginContext.cache
|
|
22051
22136
|
: getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
|
|
22052
|
-
emitAsset(name, source) {
|
|
22053
|
-
emittedFiles.push({ name, source, type: 'asset' });
|
|
22054
|
-
return pluginContext.emitAsset(name, source);
|
|
22055
|
-
},
|
|
22056
|
-
emitChunk(id, options) {
|
|
22057
|
-
emittedFiles.push({ id, name: options && options.name, type: 'chunk' });
|
|
22058
|
-
return pluginContext.emitChunk(id, options);
|
|
22059
|
-
},
|
|
22060
22137
|
emitFile(emittedFile) {
|
|
22061
22138
|
emittedFiles.push(emittedFile);
|
|
22062
22139
|
return pluginDriver.emitFile(emittedFile);
|
|
@@ -22220,13 +22297,11 @@ class ModuleLoader {
|
|
|
22220
22297
|
}));
|
|
22221
22298
|
}
|
|
22222
22299
|
async addModuleSource(id, importer, module) {
|
|
22223
|
-
timeStart('load modules', 3);
|
|
22224
22300
|
let source;
|
|
22225
22301
|
try {
|
|
22226
22302
|
source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await require$$0$1.promises.readFile(id, 'utf8')); });
|
|
22227
22303
|
}
|
|
22228
22304
|
catch (err) {
|
|
22229
|
-
timeEnd('load modules', 3);
|
|
22230
22305
|
let msg = `Could not load ${id}`;
|
|
22231
22306
|
if (importer)
|
|
22232
22307
|
msg += ` (imported by ${relativeId(importer)})`;
|
|
@@ -22234,7 +22309,6 @@ class ModuleLoader {
|
|
|
22234
22309
|
err.message = msg;
|
|
22235
22310
|
throw err;
|
|
22236
22311
|
}
|
|
22237
|
-
timeEnd('load modules', 3);
|
|
22238
22312
|
const sourceDescription = typeof source === 'string'
|
|
22239
22313
|
? { code: source }
|
|
22240
22314
|
: source != null && typeof source === 'object' && typeof source.code === 'string'
|
|
@@ -22565,19 +22639,6 @@ class GlobalScope extends Scope$1 {
|
|
|
22565
22639
|
}
|
|
22566
22640
|
}
|
|
22567
22641
|
|
|
22568
|
-
function getDeprecatedContextHandler(handler, handlerName, newHandlerName, pluginName, activeDeprecation, options) {
|
|
22569
|
-
let deprecationWarningShown = false;
|
|
22570
|
-
return ((...args) => {
|
|
22571
|
-
if (!deprecationWarningShown) {
|
|
22572
|
-
deprecationWarningShown = true;
|
|
22573
|
-
warnDeprecation({
|
|
22574
|
-
message: `The "this.${handlerName}" plugin context function used by plugin ${pluginName} is deprecated. The "this.${newHandlerName}" plugin context function should be used instead.`,
|
|
22575
|
-
plugin: pluginName
|
|
22576
|
-
}, activeDeprecation, options);
|
|
22577
|
-
}
|
|
22578
|
-
return handler(...args);
|
|
22579
|
-
});
|
|
22580
|
-
}
|
|
22581
22642
|
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
22582
22643
|
let cacheable = true;
|
|
22583
22644
|
if (typeof plugin.cacheKey !== 'string') {
|
|
@@ -22609,19 +22670,14 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22609
22670
|
graph.watchFiles[id] = true;
|
|
22610
22671
|
},
|
|
22611
22672
|
cache: cacheInstance,
|
|
22612
|
-
emitAsset: getDeprecatedContextHandler((name, source) => fileEmitter.emitFile({ name, source, type: 'asset' }), 'emitAsset', 'emitFile', plugin.name, true, options),
|
|
22613
|
-
emitChunk: getDeprecatedContextHandler((id, options) => fileEmitter.emitFile({ id, name: options && options.name, type: 'chunk' }), 'emitChunk', 'emitFile', plugin.name, true, options),
|
|
22614
22673
|
emitFile: fileEmitter.emitFile.bind(fileEmitter),
|
|
22615
22674
|
error(err) {
|
|
22616
22675
|
return throwPluginError(err, plugin.name);
|
|
22617
22676
|
},
|
|
22618
|
-
getAssetFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getAssetFileName', 'getFileName', plugin.name, true, options),
|
|
22619
|
-
getChunkFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getChunkFileName', 'getFileName', plugin.name, true, options),
|
|
22620
22677
|
getFileName: fileEmitter.getFileName,
|
|
22621
22678
|
getModuleIds: () => graph.modulesById.keys(),
|
|
22622
22679
|
getModuleInfo: graph.getModuleInfo,
|
|
22623
22680
|
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
22624
|
-
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
22625
22681
|
load(resolvedId) {
|
|
22626
22682
|
return graph.moduleLoader.preloadModule(resolvedId);
|
|
22627
22683
|
},
|
|
@@ -22635,7 +22691,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22635
22691
|
warnDeprecation({
|
|
22636
22692
|
message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
|
|
22637
22693
|
plugin: plugin.name
|
|
22638
|
-
},
|
|
22694
|
+
}, true, options);
|
|
22639
22695
|
yield* moduleIds;
|
|
22640
22696
|
}
|
|
22641
22697
|
const moduleIds = graph.modulesById.keys();
|
|
@@ -22645,9 +22701,6 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22645
22701
|
resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
|
|
22646
22702
|
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22647
22703
|
},
|
|
22648
|
-
resolveId: getDeprecatedContextHandler((source, importer) => graph.moduleLoader
|
|
22649
|
-
.resolveId(source, importer, BLANK, undefined)
|
|
22650
|
-
.then(resolveId => resolveId && resolveId.id), 'resolveId', 'resolve', plugin.name, true, options),
|
|
22651
22704
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22652
22705
|
warn(warning) {
|
|
22653
22706
|
if (typeof warning === 'string')
|
|
@@ -22688,14 +22741,14 @@ class PluginDriver {
|
|
|
22688
22741
|
this.graph = graph;
|
|
22689
22742
|
this.options = options;
|
|
22690
22743
|
this.unfulfilledActions = new Set();
|
|
22691
|
-
warnDeprecatedHooks(userPlugins, options);
|
|
22692
22744
|
this.pluginCache = pluginCache;
|
|
22693
22745
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
22694
22746
|
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
22695
22747
|
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
22696
|
-
this.finaliseAssets = this.fileEmitter.
|
|
22748
|
+
this.finaliseAssets = this.fileEmitter.finaliseAssets.bind(this.fileEmitter);
|
|
22749
|
+
this.setChunkInformation = this.fileEmitter.setChunkInformation.bind(this.fileEmitter);
|
|
22697
22750
|
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
|
|
22698
|
-
this.plugins =
|
|
22751
|
+
this.plugins = (basePluginDriver ? basePluginDriver.plugins : []).concat(userPlugins);
|
|
22699
22752
|
const existingPluginNames = new Set();
|
|
22700
22753
|
this.pluginContexts = new Map(this.plugins.map(plugin => [
|
|
22701
22754
|
plugin,
|
|
@@ -22980,10 +23033,10 @@ class Graph {
|
|
|
22980
23033
|
timeStart('generate module graph', 2);
|
|
22981
23034
|
await this.generateModuleGraph();
|
|
22982
23035
|
timeEnd('generate module graph', 2);
|
|
22983
|
-
timeStart('sort modules', 2);
|
|
23036
|
+
timeStart('sort and bind modules', 2);
|
|
22984
23037
|
this.phase = BuildPhase.ANALYSE;
|
|
22985
23038
|
this.sortModules();
|
|
22986
|
-
timeEnd('sort modules', 2);
|
|
23039
|
+
timeEnd('sort and bind modules', 2);
|
|
22987
23040
|
timeStart('mark included statements', 2);
|
|
22988
23041
|
this.includeStatements();
|
|
22989
23042
|
timeEnd('mark included statements', 2);
|
|
@@ -23164,7 +23217,7 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
23164
23217
|
}
|
|
23165
23218
|
|
|
23166
23219
|
function normalizeInputOptions(config) {
|
|
23167
|
-
var _a, _b, _c;
|
|
23220
|
+
var _a, _b, _c, _d;
|
|
23168
23221
|
// These are options that may trigger special warnings or behaviour later
|
|
23169
23222
|
// if the user did not select an explicit value
|
|
23170
23223
|
const unsetOptions = new Set();
|
|
@@ -23181,7 +23234,7 @@ function normalizeInputOptions(config) {
|
|
|
23181
23234
|
external: getIdMatcher(config.external),
|
|
23182
23235
|
inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
|
|
23183
23236
|
input: getInput(config),
|
|
23184
|
-
makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c :
|
|
23237
|
+
makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : 'ifRelativeSource',
|
|
23185
23238
|
manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
|
|
23186
23239
|
maxParallelFileOps,
|
|
23187
23240
|
maxParallelFileReads: maxParallelFileOps,
|
|
@@ -23189,12 +23242,12 @@ function normalizeInputOptions(config) {
|
|
|
23189
23242
|
onwarn,
|
|
23190
23243
|
perf: config.perf || false,
|
|
23191
23244
|
plugins: ensureArray$1(config.plugins),
|
|
23192
|
-
preserveEntrySignatures:
|
|
23245
|
+
preserveEntrySignatures: (_d = config.preserveEntrySignatures) !== null && _d !== void 0 ? _d : 'exports-only',
|
|
23193
23246
|
preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
|
|
23194
23247
|
preserveSymlinks: config.preserveSymlinks || false,
|
|
23195
23248
|
shimMissingExports: config.shimMissingExports || false,
|
|
23196
23249
|
strictDeprecations,
|
|
23197
|
-
treeshake: getTreeshake(config
|
|
23250
|
+
treeshake: getTreeshake(config)
|
|
23198
23251
|
};
|
|
23199
23252
|
warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', options.onwarn, /^(output)$/);
|
|
23200
23253
|
return { options, unsetOptions };
|
|
@@ -23250,7 +23303,7 @@ const getIdMatcher = (option) => {
|
|
|
23250
23303
|
const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
|
|
23251
23304
|
const configInlineDynamicImports = config.inlineDynamicImports;
|
|
23252
23305
|
if (configInlineDynamicImports) {
|
|
23253
|
-
warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.',
|
|
23306
|
+
warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', true, warn, strictDeprecations);
|
|
23254
23307
|
}
|
|
23255
23308
|
return configInlineDynamicImports;
|
|
23256
23309
|
};
|
|
@@ -23261,7 +23314,7 @@ const getInput = (config) => {
|
|
|
23261
23314
|
const getManualChunks$1 = (config, warn, strictDeprecations) => {
|
|
23262
23315
|
const configManualChunks = config.manualChunks;
|
|
23263
23316
|
if (configManualChunks) {
|
|
23264
|
-
warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.',
|
|
23317
|
+
warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', true, warn, strictDeprecations);
|
|
23265
23318
|
}
|
|
23266
23319
|
return configManualChunks;
|
|
23267
23320
|
};
|
|
@@ -23269,7 +23322,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
|
23269
23322
|
var _a;
|
|
23270
23323
|
const maxParallelFileReads = config.maxParallelFileReads;
|
|
23271
23324
|
if (typeof maxParallelFileReads === 'number') {
|
|
23272
|
-
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.',
|
|
23325
|
+
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
|
|
23273
23326
|
}
|
|
23274
23327
|
const maxParallelFileOps = (_a = config.maxParallelFileOps) !== null && _a !== void 0 ? _a : maxParallelFileReads;
|
|
23275
23328
|
if (typeof maxParallelFileOps === 'number') {
|
|
@@ -23293,35 +23346,23 @@ const getModuleContext = (config, context) => {
|
|
|
23293
23346
|
}
|
|
23294
23347
|
return () => context;
|
|
23295
23348
|
};
|
|
23296
|
-
const getPreserveEntrySignatures = (config, unsetOptions) => {
|
|
23297
|
-
const configPreserveEntrySignatures = config.preserveEntrySignatures;
|
|
23298
|
-
if (configPreserveEntrySignatures == null) {
|
|
23299
|
-
unsetOptions.add('preserveEntrySignatures');
|
|
23300
|
-
}
|
|
23301
|
-
return configPreserveEntrySignatures !== null && configPreserveEntrySignatures !== void 0 ? configPreserveEntrySignatures : 'strict';
|
|
23302
|
-
};
|
|
23303
23349
|
const getPreserveModules$1 = (config, warn, strictDeprecations) => {
|
|
23304
23350
|
const configPreserveModules = config.preserveModules;
|
|
23305
23351
|
if (configPreserveModules) {
|
|
23306
|
-
warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.',
|
|
23352
|
+
warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', true, warn, strictDeprecations);
|
|
23307
23353
|
}
|
|
23308
23354
|
return configPreserveModules;
|
|
23309
23355
|
};
|
|
23310
|
-
const getTreeshake = (config
|
|
23356
|
+
const getTreeshake = (config) => {
|
|
23311
23357
|
const configTreeshake = config.treeshake;
|
|
23312
23358
|
if (configTreeshake === false) {
|
|
23313
23359
|
return false;
|
|
23314
23360
|
}
|
|
23315
23361
|
const configWithPreset = getOptionWithPreset(config.treeshake, treeshakePresets, 'treeshake', 'false, true, ');
|
|
23316
|
-
if (typeof configWithPreset.pureExternalModules !== 'undefined') {
|
|
23317
|
-
warnDeprecationWithOptions(`The "treeshake.pureExternalModules" option is deprecated. The "treeshake.moduleSideEffects" option should be used instead. "treeshake.pureExternalModules: true" is equivalent to "treeshake.moduleSideEffects: 'no-external'"`, true, warn, strictDeprecations);
|
|
23318
|
-
}
|
|
23319
23362
|
return {
|
|
23320
23363
|
annotations: configWithPreset.annotations !== false,
|
|
23321
23364
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
23322
|
-
moduleSideEffects:
|
|
23323
|
-
? getHasModuleSideEffects(configTreeshake.moduleSideEffects, configTreeshake.pureExternalModules)
|
|
23324
|
-
: getHasModuleSideEffects(configWithPreset.moduleSideEffects, undefined),
|
|
23365
|
+
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
23325
23366
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
23326
23367
|
? 'always'
|
|
23327
23368
|
: configWithPreset.propertyReadSideEffects !== false,
|
|
@@ -23329,7 +23370,7 @@ const getTreeshake = (config, warn, strictDeprecations) => {
|
|
|
23329
23370
|
unknownGlobalSideEffects: configWithPreset.unknownGlobalSideEffects !== false
|
|
23330
23371
|
};
|
|
23331
23372
|
};
|
|
23332
|
-
const getHasModuleSideEffects = (moduleSideEffectsOption
|
|
23373
|
+
const getHasModuleSideEffects = (moduleSideEffectsOption) => {
|
|
23333
23374
|
if (typeof moduleSideEffectsOption === 'boolean') {
|
|
23334
23375
|
return () => moduleSideEffectsOption;
|
|
23335
23376
|
}
|
|
@@ -23346,8 +23387,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules) =
|
|
|
23346
23387
|
if (moduleSideEffectsOption) {
|
|
23347
23388
|
error(errInvalidOption('treeshake.moduleSideEffects', 'treeshake', 'please use one of false, "no-external", a function or an array'));
|
|
23348
23389
|
}
|
|
23349
|
-
|
|
23350
|
-
return (id, external) => !(external && isPureExternalModule(id));
|
|
23390
|
+
return () => true;
|
|
23351
23391
|
};
|
|
23352
23392
|
|
|
23353
23393
|
// https://datatracker.ietf.org/doc/html/rfc2396
|
|
@@ -23391,7 +23431,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23391
23431
|
chunkFileNames: (_b = config.chunkFileNames) !== null && _b !== void 0 ? _b : '[name]-[hash].js',
|
|
23392
23432
|
compact,
|
|
23393
23433
|
dir: getDir(config, file),
|
|
23394
|
-
dynamicImportFunction: getDynamicImportFunction(config, inputOptions),
|
|
23434
|
+
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
23395
23435
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23396
23436
|
esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : true,
|
|
23397
23437
|
exports: getExports(config, unsetOptions),
|
|
@@ -23497,7 +23537,7 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
|
|
|
23497
23537
|
const getPreferConst = (config, inputOptions) => {
|
|
23498
23538
|
const configPreferConst = config.preferConst;
|
|
23499
23539
|
if (configPreferConst != null) {
|
|
23500
|
-
warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`,
|
|
23540
|
+
warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`, true, inputOptions);
|
|
23501
23541
|
}
|
|
23502
23542
|
return !!configPreferConst;
|
|
23503
23543
|
};
|
|
@@ -23552,10 +23592,13 @@ const getDir = (config, file) => {
|
|
|
23552
23592
|
}
|
|
23553
23593
|
return dir;
|
|
23554
23594
|
};
|
|
23555
|
-
const getDynamicImportFunction = (config, inputOptions) => {
|
|
23595
|
+
const getDynamicImportFunction = (config, inputOptions, format) => {
|
|
23556
23596
|
const configDynamicImportFunction = config.dynamicImportFunction;
|
|
23557
23597
|
if (configDynamicImportFunction) {
|
|
23558
|
-
warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`,
|
|
23598
|
+
warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, true, inputOptions);
|
|
23599
|
+
if (format !== 'es') {
|
|
23600
|
+
inputOptions.onwarn(errInvalidOption('output.dynamicImportFunction', 'outputdynamicImportFunction', 'this option is ignored for formats other than "es"'));
|
|
23601
|
+
}
|
|
23559
23602
|
}
|
|
23560
23603
|
return configDynamicImportFunction;
|
|
23561
23604
|
};
|
|
@@ -23582,7 +23625,7 @@ const getGeneratedCode = (config, preferConst) => {
|
|
|
23582
23625
|
arrowFunctions: configWithPreset.arrowFunctions === true,
|
|
23583
23626
|
constBindings: configWithPreset.constBindings === true || preferConst,
|
|
23584
23627
|
objectShorthand: configWithPreset.objectShorthand === true,
|
|
23585
|
-
reservedNamesAsProps: configWithPreset.reservedNamesAsProps
|
|
23628
|
+
reservedNamesAsProps: configWithPreset.reservedNamesAsProps !== false,
|
|
23586
23629
|
symbols: configWithPreset.symbols === true
|
|
23587
23630
|
};
|
|
23588
23631
|
};
|
|
@@ -23614,7 +23657,7 @@ const getInterop = (config, inputOptions) => {
|
|
|
23614
23657
|
warnDeprecation({
|
|
23615
23658
|
message: `The boolean value "${interop}" for the "output.interop" option is deprecated. Use ${interop ? '"auto"' : '"esModule", "default" or "defaultOnly"'} instead.`,
|
|
23616
23659
|
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
23617
|
-
},
|
|
23660
|
+
}, true, inputOptions);
|
|
23618
23661
|
}
|
|
23619
23662
|
}
|
|
23620
23663
|
return interop;
|
|
@@ -23646,7 +23689,7 @@ const getMinifyInternalExports = (config, format, compact) => { var _a; return (
|
|
|
23646
23689
|
const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
23647
23690
|
const configNamespaceToStringTag = config.namespaceToStringTag;
|
|
23648
23691
|
if (configNamespaceToStringTag != null) {
|
|
23649
|
-
warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`,
|
|
23692
|
+
warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, true, inputOptions);
|
|
23650
23693
|
return configNamespaceToStringTag;
|
|
23651
23694
|
}
|
|
23652
23695
|
return generatedCode.symbols || false;
|
|
@@ -23675,7 +23718,9 @@ async function rollupInternal(rawInputOptions, watcher) {
|
|
|
23675
23718
|
timeStart('BUILD', 1);
|
|
23676
23719
|
await catchUnfinishedHookActions(graph.pluginDriver, async () => {
|
|
23677
23720
|
try {
|
|
23721
|
+
timeStart('initialize', 2);
|
|
23678
23722
|
await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
|
|
23723
|
+
timeEnd('initialize', 2);
|
|
23679
23724
|
await graph.build();
|
|
23680
23725
|
}
|
|
23681
23726
|
catch (err) {
|
|
@@ -23745,6 +23790,7 @@ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutput
|
|
|
23745
23790
|
const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
|
|
23746
23791
|
const generated = await bundle.generate(isWrite);
|
|
23747
23792
|
if (isWrite) {
|
|
23793
|
+
timeStart('WRITE', 1);
|
|
23748
23794
|
if (!outputOptions.dir && !outputOptions.file) {
|
|
23749
23795
|
return error({
|
|
23750
23796
|
code: 'MISSING_OPTION',
|
|
@@ -23753,6 +23799,7 @@ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutput
|
|
|
23753
23799
|
}
|
|
23754
23800
|
await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
|
|
23755
23801
|
await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
|
|
23802
|
+
timeEnd('WRITE', 1);
|
|
23756
23803
|
}
|
|
23757
23804
|
return createOutput(generated);
|
|
23758
23805
|
});
|