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/es/shared/rollup.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import require$$0, { resolve,
|
|
10
|
+
import require$$0, { resolve, extname, basename, dirname, relative as relative$1, win32, posix, isAbsolute as isAbsolute$1 } from 'path';
|
|
11
11
|
import process$1 from 'process';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
13
|
import { createHash as createHash$1 } from 'crypto';
|
|
14
14
|
import { promises } from 'fs';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
|
|
17
|
-
var version$1 = "
|
|
17
|
+
var version$1 = "3.0.0-2";
|
|
18
18
|
|
|
19
19
|
var charToInteger = {};
|
|
20
20
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1510,6 +1510,88 @@ function relative(from, to) {
|
|
|
1510
1510
|
return toParts.join('/');
|
|
1511
1511
|
}
|
|
1512
1512
|
|
|
1513
|
+
const needsEscapeRegEx = /[\\'\r\n\u2028\u2029]/;
|
|
1514
|
+
const quoteNewlineRegEx = /(['\r\n\u2028\u2029])/g;
|
|
1515
|
+
const backSlashRegEx = /\\/g;
|
|
1516
|
+
function escapeId(id) {
|
|
1517
|
+
if (!id.match(needsEscapeRegEx))
|
|
1518
|
+
return id;
|
|
1519
|
+
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
|
1523
|
+
const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
|
|
1524
|
+
function isAbsolute(path) {
|
|
1525
|
+
return ABSOLUTE_PATH_REGEX.test(path);
|
|
1526
|
+
}
|
|
1527
|
+
function isRelative(path) {
|
|
1528
|
+
return RELATIVE_PATH_REGEX.test(path);
|
|
1529
|
+
}
|
|
1530
|
+
const BACKSLASH_REGEX = /\\/g;
|
|
1531
|
+
function normalize(path) {
|
|
1532
|
+
return path.replace(BACKSLASH_REGEX, '/');
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
function getAliasName(id) {
|
|
1536
|
+
const base = basename(id);
|
|
1537
|
+
return base.substring(0, base.length - extname(id).length);
|
|
1538
|
+
}
|
|
1539
|
+
function relativeId(id) {
|
|
1540
|
+
if (!isAbsolute(id))
|
|
1541
|
+
return id;
|
|
1542
|
+
return relative(resolve(), id);
|
|
1543
|
+
}
|
|
1544
|
+
function isPathFragment(name) {
|
|
1545
|
+
// starting with "/", "./", "../", "C:/"
|
|
1546
|
+
return (name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name));
|
|
1547
|
+
}
|
|
1548
|
+
const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
|
|
1549
|
+
function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
|
|
1550
|
+
let relativePath = normalize(relative(dirname(importerId), targetPath));
|
|
1551
|
+
if (stripJsExtension && relativePath.endsWith('.js')) {
|
|
1552
|
+
relativePath = relativePath.slice(0, -3);
|
|
1553
|
+
}
|
|
1554
|
+
if (ensureFileName) {
|
|
1555
|
+
if (relativePath === '')
|
|
1556
|
+
return '../' + basename(targetPath);
|
|
1557
|
+
if (UPPER_DIR_REGEX.test(relativePath)) {
|
|
1558
|
+
return relativePath
|
|
1559
|
+
.split('/')
|
|
1560
|
+
.concat(['..', basename(targetPath)])
|
|
1561
|
+
.join('/');
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
return !relativePath ? '.' : relativePath.startsWith('..') ? relativePath : './' + relativePath;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
class ExternalChunk {
|
|
1568
|
+
constructor(module, options, inputBase) {
|
|
1569
|
+
this.options = options;
|
|
1570
|
+
this.inputBase = inputBase;
|
|
1571
|
+
this.defaultVariableName = '';
|
|
1572
|
+
this.namespaceVariableName = '';
|
|
1573
|
+
this.variableName = '';
|
|
1574
|
+
this.fileName = null;
|
|
1575
|
+
this.id = module.id;
|
|
1576
|
+
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
1577
|
+
this.suggestedVariableName = module.suggestedVariableName;
|
|
1578
|
+
}
|
|
1579
|
+
getFileName() {
|
|
1580
|
+
if (this.fileName) {
|
|
1581
|
+
return this.fileName;
|
|
1582
|
+
}
|
|
1583
|
+
const { paths } = this.options;
|
|
1584
|
+
return (this.fileName =
|
|
1585
|
+
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
1586
|
+
(this.renormalizeRenderPath ? normalize(relative$1(this.inputBase, this.id)) : this.id));
|
|
1587
|
+
}
|
|
1588
|
+
getImportPath(importer) {
|
|
1589
|
+
return escapeId(this.renormalizeRenderPath
|
|
1590
|
+
? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
|
|
1591
|
+
: this.getFileName());
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1513
1595
|
function getOrCreate(map, key, init) {
|
|
1514
1596
|
const existing = map.get(key);
|
|
1515
1597
|
if (existing) {
|
|
@@ -1808,51 +1890,6 @@ function printQuotedStringList(list, verbs) {
|
|
|
1808
1890
|
return output;
|
|
1809
1891
|
}
|
|
1810
1892
|
|
|
1811
|
-
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
|
1812
|
-
const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
|
|
1813
|
-
function isAbsolute(path) {
|
|
1814
|
-
return ABSOLUTE_PATH_REGEX.test(path);
|
|
1815
|
-
}
|
|
1816
|
-
function isRelative(path) {
|
|
1817
|
-
return RELATIVE_PATH_REGEX.test(path);
|
|
1818
|
-
}
|
|
1819
|
-
const BACKSLASH_REGEX = /\\/g;
|
|
1820
|
-
function normalize(path) {
|
|
1821
|
-
return path.replace(BACKSLASH_REGEX, '/');
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
function getAliasName(id) {
|
|
1825
|
-
const base = basename(id);
|
|
1826
|
-
return base.substring(0, base.length - extname(id).length);
|
|
1827
|
-
}
|
|
1828
|
-
function relativeId(id) {
|
|
1829
|
-
if (!isAbsolute(id))
|
|
1830
|
-
return id;
|
|
1831
|
-
return relative(resolve(), id);
|
|
1832
|
-
}
|
|
1833
|
-
function isPathFragment(name) {
|
|
1834
|
-
// starting with "/", "./", "../", "C:/"
|
|
1835
|
-
return (name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name));
|
|
1836
|
-
}
|
|
1837
|
-
const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
|
|
1838
|
-
function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
|
|
1839
|
-
let relativePath = normalize(relative(dirname(importerId), targetPath));
|
|
1840
|
-
if (stripJsExtension && relativePath.endsWith('.js')) {
|
|
1841
|
-
relativePath = relativePath.slice(0, -3);
|
|
1842
|
-
}
|
|
1843
|
-
if (ensureFileName) {
|
|
1844
|
-
if (relativePath === '')
|
|
1845
|
-
return '../' + basename(targetPath);
|
|
1846
|
-
if (UPPER_DIR_REGEX.test(relativePath)) {
|
|
1847
|
-
return relativePath
|
|
1848
|
-
.split('/')
|
|
1849
|
-
.concat(['..', basename(targetPath)])
|
|
1850
|
-
.join('/');
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
return !relativePath ? '.' : relativePath.startsWith('..') ? relativePath : './' + relativePath;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
1893
|
function error(base) {
|
|
1857
1894
|
if (!(base instanceof Error))
|
|
1858
1895
|
base = Object.assign(new Error(base.message), base);
|
|
@@ -1875,6 +1912,7 @@ function augmentCodeLocation(props, pos, source, id) {
|
|
|
1875
1912
|
}
|
|
1876
1913
|
var Errors;
|
|
1877
1914
|
(function (Errors) {
|
|
1915
|
+
Errors["ADDON_ERROR"] = "ADDON_ERROR";
|
|
1878
1916
|
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
1879
1917
|
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
1880
1918
|
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
@@ -1897,6 +1935,7 @@ var Errors;
|
|
|
1897
1935
|
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
1898
1936
|
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
1899
1937
|
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
1938
|
+
Errors["INVALID_TLA_FORMAT"] = "INVALID_TLA_FORMAT";
|
|
1900
1939
|
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
1901
1940
|
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
1902
1941
|
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
@@ -1911,10 +1950,17 @@ var Errors;
|
|
|
1911
1950
|
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
1912
1951
|
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
1913
1952
|
})(Errors || (Errors = {}));
|
|
1953
|
+
function errAddonNotGenerated(message, hook, plugin) {
|
|
1954
|
+
return {
|
|
1955
|
+
code: Errors.ADDON_ERROR,
|
|
1956
|
+
message: `Could not retrieve ${hook}. Check configuration of plugin ${plugin}.
|
|
1957
|
+
\tError Message: ${message}`
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1914
1960
|
function errAssetNotFinalisedForFileName(name) {
|
|
1915
1961
|
return {
|
|
1916
1962
|
code: Errors.ASSET_NOT_FINALISED,
|
|
1917
|
-
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
1963
|
+
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.`
|
|
1918
1964
|
};
|
|
1919
1965
|
}
|
|
1920
1966
|
function errCannotEmitFromOptionsHook() {
|
|
@@ -1926,7 +1972,7 @@ function errCannotEmitFromOptionsHook() {
|
|
|
1926
1972
|
function errChunkNotGeneratedForFileName(name) {
|
|
1927
1973
|
return {
|
|
1928
1974
|
code: Errors.CHUNK_NOT_GENERATED,
|
|
1929
|
-
message: `Plugin error - Unable to get file name for chunk "${name}".
|
|
1975
|
+
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.`
|
|
1930
1976
|
};
|
|
1931
1977
|
}
|
|
1932
1978
|
function errChunkInvalid({ fileName, code }, exception) {
|
|
@@ -2045,6 +2091,13 @@ function errInvalidRollupPhaseForChunkEmission() {
|
|
|
2045
2091
|
message: `Cannot emit chunks after module loading has finished.`
|
|
2046
2092
|
};
|
|
2047
2093
|
}
|
|
2094
|
+
function errInvalidFormatForTopLevelAwait(id, format) {
|
|
2095
|
+
return {
|
|
2096
|
+
code: Errors.INVALID_TLA_FORMAT,
|
|
2097
|
+
id,
|
|
2098
|
+
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2048
2101
|
function errMissingExport(exportName, importingModule, importedModule) {
|
|
2049
2102
|
return {
|
|
2050
2103
|
code: Errors.MISSING_EXPORT,
|
|
@@ -2272,19 +2325,15 @@ class ExternalModule {
|
|
|
2272
2325
|
this.options = options;
|
|
2273
2326
|
this.id = id;
|
|
2274
2327
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
2275
|
-
this.declarations = new Map();
|
|
2276
|
-
this.defaultVariableName = '';
|
|
2277
2328
|
this.dynamicImporters = [];
|
|
2278
2329
|
this.execIndex = Infinity;
|
|
2279
2330
|
this.exportedVariables = new Map();
|
|
2280
2331
|
this.importers = [];
|
|
2281
|
-
this.mostCommonSuggestion = 0;
|
|
2282
|
-
this.nameSuggestions = new Map();
|
|
2283
|
-
this.namespaceVariableName = '';
|
|
2284
2332
|
this.reexported = false;
|
|
2285
|
-
this.renderPath = undefined;
|
|
2286
2333
|
this.used = false;
|
|
2287
|
-
this.
|
|
2334
|
+
this.declarations = new Map();
|
|
2335
|
+
this.mostCommonSuggestion = 0;
|
|
2336
|
+
this.nameSuggestions = new Map();
|
|
2288
2337
|
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2289
2338
|
const { importers, dynamicImporters } = this;
|
|
2290
2339
|
const info = (this.info = {
|
|
@@ -2297,7 +2346,7 @@ class ExternalModule {
|
|
|
2297
2346
|
},
|
|
2298
2347
|
hasDefaultExport: null,
|
|
2299
2348
|
get hasModuleSideEffects() {
|
|
2300
|
-
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
|
|
2349
|
+
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
|
|
2301
2350
|
return info.moduleSideEffects;
|
|
2302
2351
|
},
|
|
2303
2352
|
id,
|
|
@@ -2329,15 +2378,6 @@ class ExternalModule {
|
|
|
2329
2378
|
this.exportedVariables.set(externalVariable, name);
|
|
2330
2379
|
return [externalVariable];
|
|
2331
2380
|
}
|
|
2332
|
-
setRenderPath(options, inputBase) {
|
|
2333
|
-
this.renderPath =
|
|
2334
|
-
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
2335
|
-
if (!this.renderPath) {
|
|
2336
|
-
this.renderPath = this.renormalizeRenderPath
|
|
2337
|
-
? normalize(relative$1(inputBase, this.id))
|
|
2338
|
-
: this.id;
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
2381
|
suggestName(name) {
|
|
2342
2382
|
var _a;
|
|
2343
2383
|
const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
@@ -10213,7 +10253,9 @@ class ImportExpression extends NodeBase {
|
|
|
10213
10253
|
super(...arguments);
|
|
10214
10254
|
this.inlineNamespace = null;
|
|
10215
10255
|
this.mechanism = null;
|
|
10256
|
+
this.namespaceExportName = undefined;
|
|
10216
10257
|
this.resolution = null;
|
|
10258
|
+
this.resolutionString = null;
|
|
10217
10259
|
}
|
|
10218
10260
|
hasEffects() {
|
|
10219
10261
|
return true;
|
|
@@ -10230,8 +10272,8 @@ class ImportExpression extends NodeBase {
|
|
|
10230
10272
|
this.context.addDynamicImport(this);
|
|
10231
10273
|
}
|
|
10232
10274
|
render(code, options) {
|
|
10275
|
+
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10233
10276
|
if (this.inlineNamespace) {
|
|
10234
|
-
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10235
10277
|
const [left, right] = getDirectReturnFunction([], {
|
|
10236
10278
|
functionReturn: true,
|
|
10237
10279
|
lineBreakIndent: null,
|
|
@@ -10244,22 +10286,26 @@ class ImportExpression extends NodeBase {
|
|
|
10244
10286
|
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
|
|
10245
10287
|
code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
|
|
10246
10288
|
}
|
|
10247
|
-
this.
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
}
|
|
10257
|
-
|
|
10289
|
+
if (this.resolutionString) {
|
|
10290
|
+
code.overwrite(this.source.start, this.source.end, this.resolutionString);
|
|
10291
|
+
if (this.namespaceExportName) {
|
|
10292
|
+
const [left, right] = getDirectReturnFunction(['n'], {
|
|
10293
|
+
functionReturn: true,
|
|
10294
|
+
lineBreakIndent: null,
|
|
10295
|
+
name: null
|
|
10296
|
+
});
|
|
10297
|
+
code.prependLeft(this.end, `.then(${left}n.${this.namespaceExportName}${right})`);
|
|
10298
|
+
}
|
|
10299
|
+
}
|
|
10300
|
+
else {
|
|
10301
|
+
this.source.render(code, options);
|
|
10258
10302
|
}
|
|
10259
10303
|
}
|
|
10260
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope) {
|
|
10304
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
|
|
10261
10305
|
const { format } = options;
|
|
10262
10306
|
this.resolution = resolution;
|
|
10307
|
+
this.resolutionString = resolutionString;
|
|
10308
|
+
this.namespaceExportName = namespaceExportName;
|
|
10263
10309
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
10264
10310
|
let helper;
|
|
10265
10311
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -10554,25 +10600,17 @@ class LogicalExpression extends NodeBase {
|
|
|
10554
10600
|
}
|
|
10555
10601
|
}
|
|
10556
10602
|
|
|
10557
|
-
const ASSET_PREFIX = 'ROLLUP_ASSET_URL_';
|
|
10558
|
-
const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_';
|
|
10559
10603
|
const FILE_PREFIX = 'ROLLUP_FILE_URL_';
|
|
10560
10604
|
class MetaProperty extends NodeBase {
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
metaProperty.startsWith(CHUNK_PREFIX))
|
|
10567
|
-
? accessedFileUrlGlobals
|
|
10568
|
-
: accessedMetaUrlGlobals)[format];
|
|
10569
|
-
if (accessedGlobals.length > 0) {
|
|
10570
|
-
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
10571
|
-
}
|
|
10605
|
+
constructor() {
|
|
10606
|
+
super(...arguments);
|
|
10607
|
+
this.metaProperty = null;
|
|
10608
|
+
this.preliminaryChunkId = null;
|
|
10609
|
+
this.referenceId = null;
|
|
10572
10610
|
}
|
|
10573
10611
|
getReferencedFileName(outputPluginDriver) {
|
|
10574
|
-
const metaProperty = this
|
|
10575
|
-
if (metaProperty
|
|
10612
|
+
const { metaProperty } = this;
|
|
10613
|
+
if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
|
|
10576
10614
|
return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
|
|
10577
10615
|
}
|
|
10578
10616
|
return null;
|
|
@@ -10589,71 +10627,37 @@ class MetaProperty extends NodeBase {
|
|
|
10589
10627
|
if (this.meta.name === 'import') {
|
|
10590
10628
|
this.context.addImportMeta(this);
|
|
10591
10629
|
const parent = this.parent;
|
|
10592
|
-
this.metaProperty =
|
|
10630
|
+
const metaProperty = (this.metaProperty =
|
|
10593
10631
|
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
10594
10632
|
? parent.propertyKey
|
|
10595
|
-
: null;
|
|
10633
|
+
: null);
|
|
10634
|
+
if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
|
|
10635
|
+
this.referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
10636
|
+
}
|
|
10596
10637
|
}
|
|
10597
10638
|
}
|
|
10598
10639
|
}
|
|
10599
|
-
|
|
10640
|
+
render(code, { format, pluginDriver, snippets }) {
|
|
10600
10641
|
var _a;
|
|
10601
|
-
const parent = this
|
|
10602
|
-
const
|
|
10603
|
-
if (
|
|
10604
|
-
|
|
10605
|
-
metaProperty.startsWith(ASSET_PREFIX) ||
|
|
10606
|
-
metaProperty.startsWith(CHUNK_PREFIX))) {
|
|
10607
|
-
let referenceId = null;
|
|
10608
|
-
let assetReferenceId = null;
|
|
10609
|
-
let chunkReferenceId = null;
|
|
10610
|
-
let fileName;
|
|
10611
|
-
if (metaProperty.startsWith(FILE_PREFIX)) {
|
|
10612
|
-
referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
10613
|
-
fileName = outputPluginDriver.getFileName(referenceId);
|
|
10614
|
-
}
|
|
10615
|
-
else if (metaProperty.startsWith(ASSET_PREFIX)) {
|
|
10616
|
-
warnDeprecation(`Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
|
|
10617
|
-
assetReferenceId = metaProperty.substring(ASSET_PREFIX.length);
|
|
10618
|
-
fileName = outputPluginDriver.getFileName(assetReferenceId);
|
|
10619
|
-
}
|
|
10620
|
-
else {
|
|
10621
|
-
warnDeprecation(`Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
|
|
10622
|
-
chunkReferenceId = metaProperty.substring(CHUNK_PREFIX.length);
|
|
10623
|
-
fileName = outputPluginDriver.getFileName(chunkReferenceId);
|
|
10624
|
-
}
|
|
10642
|
+
const { metaProperty, parent, referenceId } = this;
|
|
10643
|
+
const chunkId = this.preliminaryChunkId;
|
|
10644
|
+
if (referenceId) {
|
|
10645
|
+
const fileName = pluginDriver.getFileName(referenceId);
|
|
10625
10646
|
const relativePath = normalize(relative$1(dirname(chunkId), fileName));
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
]);
|
|
10637
|
-
}
|
|
10638
|
-
if (!replacement) {
|
|
10639
|
-
replacement =
|
|
10640
|
-
outputPluginDriver.hookFirstSync('resolveFileUrl', [
|
|
10641
|
-
{
|
|
10642
|
-
assetReferenceId,
|
|
10643
|
-
chunkId,
|
|
10644
|
-
chunkReferenceId,
|
|
10645
|
-
fileName,
|
|
10646
|
-
format,
|
|
10647
|
-
moduleId: this.context.module.id,
|
|
10648
|
-
referenceId: referenceId || assetReferenceId || chunkReferenceId,
|
|
10649
|
-
relativePath
|
|
10650
|
-
}
|
|
10651
|
-
]) || relativeUrlMechanisms[format](relativePath);
|
|
10652
|
-
}
|
|
10647
|
+
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
10648
|
+
{
|
|
10649
|
+
chunkId,
|
|
10650
|
+
fileName,
|
|
10651
|
+
format,
|
|
10652
|
+
moduleId: this.context.module.id,
|
|
10653
|
+
referenceId,
|
|
10654
|
+
relativePath
|
|
10655
|
+
}
|
|
10656
|
+
]) || relativeUrlMechanisms[format](relativePath);
|
|
10653
10657
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
10654
10658
|
return;
|
|
10655
10659
|
}
|
|
10656
|
-
const replacement =
|
|
10660
|
+
const replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
10657
10661
|
metaProperty,
|
|
10658
10662
|
{
|
|
10659
10663
|
chunkId,
|
|
@@ -10670,6 +10674,14 @@ class MetaProperty extends NodeBase {
|
|
|
10670
10674
|
}
|
|
10671
10675
|
}
|
|
10672
10676
|
}
|
|
10677
|
+
setResolution(format, accessedGlobalsByScope, preliminaryChunkId) {
|
|
10678
|
+
var _a;
|
|
10679
|
+
this.preliminaryChunkId = preliminaryChunkId;
|
|
10680
|
+
const accessedGlobals = (((_a = this.metaProperty) === null || _a === void 0 ? void 0 : _a.startsWith(FILE_PREFIX)) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
|
|
10681
|
+
if (accessedGlobals.length > 0) {
|
|
10682
|
+
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
10683
|
+
}
|
|
10684
|
+
}
|
|
10673
10685
|
}
|
|
10674
10686
|
const accessedMetaUrlGlobals = {
|
|
10675
10687
|
amd: ['document', 'module', 'URL'],
|
|
@@ -12183,7 +12195,26 @@ function getTimings() {
|
|
|
12183
12195
|
}
|
|
12184
12196
|
let timeStart = NOOP;
|
|
12185
12197
|
let timeEnd = NOOP;
|
|
12186
|
-
const TIMED_PLUGIN_HOOKS = [
|
|
12198
|
+
const TIMED_PLUGIN_HOOKS = [
|
|
12199
|
+
'augmentChunkHash',
|
|
12200
|
+
'buildEnd',
|
|
12201
|
+
'buildStart',
|
|
12202
|
+
'generateBundle',
|
|
12203
|
+
'load',
|
|
12204
|
+
'moduleParsed',
|
|
12205
|
+
'options',
|
|
12206
|
+
'outputOptions',
|
|
12207
|
+
'renderChunk',
|
|
12208
|
+
'renderDynamicImport',
|
|
12209
|
+
'renderStart',
|
|
12210
|
+
'resolveDynamicImport',
|
|
12211
|
+
'resolveFileUrl',
|
|
12212
|
+
'resolveId',
|
|
12213
|
+
'resolveImportMeta',
|
|
12214
|
+
'shouldTransformCachedModule',
|
|
12215
|
+
'transform',
|
|
12216
|
+
'writeBundle'
|
|
12217
|
+
];
|
|
12187
12218
|
function getPluginWithTimers(plugin, index) {
|
|
12188
12219
|
for (const hook of TIMED_PLUGIN_HOOKS) {
|
|
12189
12220
|
if (hook in plugin) {
|
|
@@ -12197,13 +12228,6 @@ function getPluginWithTimers(plugin, index) {
|
|
|
12197
12228
|
timeStart(timerLabel, 4);
|
|
12198
12229
|
const result = func.apply(this, args);
|
|
12199
12230
|
timeEnd(timerLabel, 4);
|
|
12200
|
-
if (result && typeof result.then === 'function') {
|
|
12201
|
-
timeStart(`${timerLabel} (async)`, 4);
|
|
12202
|
-
return result.then((hookResult) => {
|
|
12203
|
-
timeEnd(`${timerLabel} (async)`, 4);
|
|
12204
|
-
return hookResult;
|
|
12205
|
-
});
|
|
12206
|
-
}
|
|
12207
12231
|
return result;
|
|
12208
12232
|
};
|
|
12209
12233
|
}
|
|
@@ -12315,7 +12339,6 @@ class Module {
|
|
|
12315
12339
|
this.needsExportShim = false;
|
|
12316
12340
|
this.sideEffectDependenciesByVariable = new Map();
|
|
12317
12341
|
this.sources = new Set();
|
|
12318
|
-
this.usesTopLevelAwait = false;
|
|
12319
12342
|
this.allExportNames = null;
|
|
12320
12343
|
this.ast = null;
|
|
12321
12344
|
this.exportAllModules = [];
|
|
@@ -12360,7 +12383,7 @@ class Module {
|
|
|
12360
12383
|
return module.exports.has('default') || reexportDescriptions.has('default');
|
|
12361
12384
|
},
|
|
12362
12385
|
get hasModuleSideEffects() {
|
|
12363
|
-
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
|
|
12386
|
+
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
|
|
12364
12387
|
return this.moduleSideEffects;
|
|
12365
12388
|
},
|
|
12366
12389
|
id,
|
|
@@ -12672,12 +12695,17 @@ class Module {
|
|
|
12672
12695
|
this.exportAllModules.push(...externalExportAllModules);
|
|
12673
12696
|
}
|
|
12674
12697
|
render(options) {
|
|
12675
|
-
const
|
|
12676
|
-
this.ast.render(
|
|
12677
|
-
|
|
12678
|
-
|
|
12698
|
+
const source = this.magicString.clone();
|
|
12699
|
+
this.ast.render(source, options);
|
|
12700
|
+
source.trim();
|
|
12701
|
+
const { usesTopLevelAwait } = this.astContext;
|
|
12702
|
+
if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') {
|
|
12703
|
+
return error(errInvalidFormatForTopLevelAwait(this.id, options.format));
|
|
12704
|
+
}
|
|
12705
|
+
return { source, usesTopLevelAwait };
|
|
12679
12706
|
}
|
|
12680
12707
|
setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
|
|
12708
|
+
timeStart('generate ast', 3);
|
|
12681
12709
|
this.info.code = code;
|
|
12682
12710
|
this.originalCode = originalCode;
|
|
12683
12711
|
this.originalSourcemap = originalSourcemap;
|
|
@@ -12688,11 +12716,11 @@ class Module {
|
|
|
12688
12716
|
this.transformDependencies = transformDependencies;
|
|
12689
12717
|
this.customTransformCache = customTransformCache;
|
|
12690
12718
|
this.updateOptions(moduleOptions);
|
|
12691
|
-
timeStart('generate ast', 3);
|
|
12692
12719
|
if (!ast) {
|
|
12693
12720
|
ast = this.tryParse();
|
|
12694
12721
|
}
|
|
12695
12722
|
timeEnd('generate ast', 3);
|
|
12723
|
+
timeStart('analyze ast', 3);
|
|
12696
12724
|
this.resolvedIds = resolvedIds || Object.create(null);
|
|
12697
12725
|
// By default, `id` is the file name. Custom resolvers and loaders
|
|
12698
12726
|
// can change that, but it makes sense to use it for the source file name
|
|
@@ -12701,7 +12729,6 @@ class Module {
|
|
|
12701
12729
|
filename: (this.excludeFromSourcemap ? null : fileName),
|
|
12702
12730
|
indentExclusionRanges: []
|
|
12703
12731
|
});
|
|
12704
|
-
timeStart('analyse ast', 3);
|
|
12705
12732
|
this.astContext = {
|
|
12706
12733
|
addDynamicImport: this.addDynamicImport.bind(this),
|
|
12707
12734
|
addExport: this.addExport.bind(this),
|
|
@@ -12734,7 +12761,7 @@ class Module {
|
|
|
12734
12761
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
12735
12762
|
this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
|
|
12736
12763
|
this.info.ast = ast;
|
|
12737
|
-
timeEnd('
|
|
12764
|
+
timeEnd('analyze ast', 3);
|
|
12738
12765
|
}
|
|
12739
12766
|
toJSON() {
|
|
12740
12767
|
return {
|
|
@@ -13109,11 +13136,11 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
13109
13136
|
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
13110
13137
|
}
|
|
13111
13138
|
let exportBlock = '';
|
|
13112
|
-
for (const { defaultVariableName,
|
|
13139
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13113
13140
|
if (reexports && namedExportsMode) {
|
|
13114
13141
|
for (const specifier of reexports) {
|
|
13115
13142
|
if (specifier.reexported !== '*') {
|
|
13116
|
-
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop,
|
|
13143
|
+
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
13117
13144
|
if (exportBlock)
|
|
13118
13145
|
exportBlock += n;
|
|
13119
13146
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
@@ -13171,9 +13198,9 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
|
|
|
13171
13198
|
return exports[0].local;
|
|
13172
13199
|
}
|
|
13173
13200
|
else {
|
|
13174
|
-
for (const { defaultVariableName,
|
|
13201
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13175
13202
|
if (reexports) {
|
|
13176
|
-
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop,
|
|
13203
|
+
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
13177
13204
|
}
|
|
13178
13205
|
}
|
|
13179
13206
|
}
|
|
@@ -13248,7 +13275,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13248
13275
|
neededInteropHelpers.add(helper);
|
|
13249
13276
|
interopStatements.push(`${cnst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
13250
13277
|
};
|
|
13251
|
-
for (const { defaultVariableName, imports,
|
|
13278
|
+
for (const { defaultVariableName, imports, importPath, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
13252
13279
|
if (isChunk) {
|
|
13253
13280
|
for (const { imported, reexported } of [
|
|
13254
13281
|
...(imports || []),
|
|
@@ -13263,7 +13290,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13263
13290
|
}
|
|
13264
13291
|
}
|
|
13265
13292
|
else {
|
|
13266
|
-
const moduleInterop = String(interop(
|
|
13293
|
+
const moduleInterop = String(interop(importPath));
|
|
13267
13294
|
let hasDefault = false;
|
|
13268
13295
|
let hasNamespace = false;
|
|
13269
13296
|
for (const { imported, reexported } of [
|
|
@@ -13328,7 +13355,9 @@ const builtins = {
|
|
|
13328
13355
|
zlib: true
|
|
13329
13356
|
};
|
|
13330
13357
|
function warnOnBuiltins(warn, dependencies) {
|
|
13331
|
-
const externalBuiltins = dependencies
|
|
13358
|
+
const externalBuiltins = dependencies
|
|
13359
|
+
.map(({ importPath }) => importPath)
|
|
13360
|
+
.filter(importPath => importPath in builtins);
|
|
13332
13361
|
if (!externalBuiltins.length)
|
|
13333
13362
|
return;
|
|
13334
13363
|
warn({
|
|
@@ -13338,9 +13367,9 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
13338
13367
|
});
|
|
13339
13368
|
}
|
|
13340
13369
|
|
|
13341
|
-
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets,
|
|
13342
|
-
warnOnBuiltins(
|
|
13343
|
-
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.
|
|
13370
|
+
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13371
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13372
|
+
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
|
|
13344
13373
|
const args = dependencies.map(m => m.name);
|
|
13345
13374
|
const { n, getNonArrowFunctionIntro, _ } = snippets;
|
|
13346
13375
|
if (namedExportsMode && hasExports) {
|
|
@@ -13365,8 +13394,8 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13365
13394
|
if (namespaceMarkers) {
|
|
13366
13395
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13367
13396
|
}
|
|
13368
|
-
magicString
|
|
13369
|
-
|
|
13397
|
+
magicString
|
|
13398
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
13370
13399
|
.indent(t)
|
|
13371
13400
|
// factory function should be wrapped by parentheses to avoid lazy parsing,
|
|
13372
13401
|
// cf. https://v8.dev/blog/preparser#pife
|
|
@@ -13374,7 +13403,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13374
13403
|
isAsync: false,
|
|
13375
13404
|
name: null
|
|
13376
13405
|
})}{${useStrict}${n}${n}`)
|
|
13377
|
-
.append(`${n}${n}}));`)
|
|
13406
|
+
.append(`${n}${n}}));`);
|
|
13378
13407
|
}
|
|
13379
13408
|
|
|
13380
13409
|
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
@@ -13388,23 +13417,23 @@ function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13388
13417
|
const interopBlock = getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets);
|
|
13389
13418
|
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
13390
13419
|
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
13391
|
-
|
|
13420
|
+
magicString.append(`${exportBlock}${outro}`);
|
|
13392
13421
|
}
|
|
13393
13422
|
function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
13394
13423
|
let importBlock = '';
|
|
13395
13424
|
let definingVariable = false;
|
|
13396
|
-
for (const {
|
|
13425
|
+
for (const { importPath, name, reexports, imports } of dependencies) {
|
|
13397
13426
|
if (!reexports && !imports) {
|
|
13398
13427
|
if (importBlock) {
|
|
13399
13428
|
importBlock += compact && !definingVariable ? ',' : `;${n}`;
|
|
13400
13429
|
}
|
|
13401
13430
|
definingVariable = false;
|
|
13402
|
-
importBlock += `require('${
|
|
13431
|
+
importBlock += `require('${importPath}')`;
|
|
13403
13432
|
}
|
|
13404
13433
|
else {
|
|
13405
13434
|
importBlock += compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${cnst} `;
|
|
13406
13435
|
definingVariable = true;
|
|
13407
|
-
importBlock += `${name}${_}=${_}require('${
|
|
13436
|
+
importBlock += `${name}${_}=${_}require('${importPath}')`;
|
|
13408
13437
|
}
|
|
13409
13438
|
}
|
|
13410
13439
|
if (importBlock) {
|
|
@@ -13426,13 +13455,13 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
13426
13455
|
magicString.append(n + n + exportBlock.join(n).trim());
|
|
13427
13456
|
if (outro)
|
|
13428
13457
|
magicString.append(outro);
|
|
13429
|
-
|
|
13458
|
+
magicString.trim();
|
|
13430
13459
|
}
|
|
13431
13460
|
function getImportBlock(dependencies, _) {
|
|
13432
13461
|
const importBlock = [];
|
|
13433
|
-
for (const {
|
|
13462
|
+
for (const { importPath, reexports, imports, name } of dependencies) {
|
|
13434
13463
|
if (!reexports && !imports) {
|
|
13435
|
-
importBlock.push(`import${_}'${
|
|
13464
|
+
importBlock.push(`import${_}'${importPath}';`);
|
|
13436
13465
|
continue;
|
|
13437
13466
|
}
|
|
13438
13467
|
if (imports) {
|
|
@@ -13451,10 +13480,10 @@ function getImportBlock(dependencies, _) {
|
|
|
13451
13480
|
}
|
|
13452
13481
|
}
|
|
13453
13482
|
if (starImport) {
|
|
13454
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${
|
|
13483
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${importPath}';`);
|
|
13455
13484
|
}
|
|
13456
13485
|
if (defaultImport && importedNames.length === 0) {
|
|
13457
|
-
importBlock.push(`import ${defaultImport.local} from${_}'${
|
|
13486
|
+
importBlock.push(`import ${defaultImport.local} from${_}'${importPath}';`);
|
|
13458
13487
|
}
|
|
13459
13488
|
else if (importedNames.length > 0) {
|
|
13460
13489
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
@@ -13466,7 +13495,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13466
13495
|
return `${specifier.imported} as ${specifier.local}`;
|
|
13467
13496
|
}
|
|
13468
13497
|
})
|
|
13469
|
-
.join(`,${_}`)}${_}}${_}from${_}'${
|
|
13498
|
+
.join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
|
|
13470
13499
|
}
|
|
13471
13500
|
}
|
|
13472
13501
|
if (reexports) {
|
|
@@ -13485,12 +13514,12 @@ function getImportBlock(dependencies, _) {
|
|
|
13485
13514
|
}
|
|
13486
13515
|
}
|
|
13487
13516
|
if (starExport) {
|
|
13488
|
-
importBlock.push(`export${_}*${_}from${_}'${
|
|
13517
|
+
importBlock.push(`export${_}*${_}from${_}'${importPath}';`);
|
|
13489
13518
|
}
|
|
13490
13519
|
if (namespaceReexports.length > 0) {
|
|
13491
13520
|
if (!imports ||
|
|
13492
13521
|
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
13493
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}'${
|
|
13522
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}'${importPath}';`);
|
|
13494
13523
|
}
|
|
13495
13524
|
for (const specifier of namespaceReexports) {
|
|
13496
13525
|
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
@@ -13506,7 +13535,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13506
13535
|
return `${specifier.imported} as ${specifier.reexported}`;
|
|
13507
13536
|
}
|
|
13508
13537
|
})
|
|
13509
|
-
.join(`,${_}`)}${_}}${_}from${_}'${
|
|
13538
|
+
.join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
|
|
13510
13539
|
}
|
|
13511
13540
|
}
|
|
13512
13541
|
}
|
|
@@ -13572,7 +13601,7 @@ function trimEmptyImports(dependencies) {
|
|
|
13572
13601
|
return [];
|
|
13573
13602
|
}
|
|
13574
13603
|
|
|
13575
|
-
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets,
|
|
13604
|
+
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
|
|
13576
13605
|
const { _, cnst, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
|
|
13577
13606
|
const isNamespaced = name && name.includes('.');
|
|
13578
13607
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
@@ -13582,12 +13611,12 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13582
13611
|
message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
|
|
13583
13612
|
});
|
|
13584
13613
|
}
|
|
13585
|
-
warnOnBuiltins(
|
|
13614
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13586
13615
|
const external = trimEmptyImports(dependencies);
|
|
13587
13616
|
const deps = external.map(dep => dep.globalName || 'null');
|
|
13588
13617
|
const args = external.map(m => m.name);
|
|
13589
13618
|
if (hasExports && !name) {
|
|
13590
|
-
|
|
13619
|
+
onwarn({
|
|
13591
13620
|
code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT',
|
|
13592
13621
|
message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`
|
|
13593
13622
|
});
|
|
@@ -13628,8 +13657,11 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13628
13657
|
if (namespaceMarkers) {
|
|
13629
13658
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13630
13659
|
}
|
|
13631
|
-
magicString
|
|
13632
|
-
|
|
13660
|
+
magicString
|
|
13661
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
13662
|
+
.indent(t)
|
|
13663
|
+
.prepend(wrapperIntro)
|
|
13664
|
+
.append(wrapperOutro);
|
|
13633
13665
|
}
|
|
13634
13666
|
|
|
13635
13667
|
function system(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, snippets, outro, usesTopLevelAwait }, { externalLiveBindings, freeze, name, namespaceToStringTag, strict, systemNullSetters }) {
|
|
@@ -13644,7 +13676,7 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
13644
13676
|
// factory function should be wrapped by parentheses to avoid lazy parsing,
|
|
13645
13677
|
// cf. https://v8.dev/blog/preparser#pife
|
|
13646
13678
|
let wrapperStart = `System.register(${registeredName}[` +
|
|
13647
|
-
dependencies.map(({
|
|
13679
|
+
dependencies.map(({ importPath }) => `'${importPath}'`).join(`,${_}`) +
|
|
13648
13680
|
`],${_}(${getNonArrowFunctionIntro(wrapperParams, { isAsync: false, name: null })}{${n}${t}${strict ? "'use strict';" : ''}` +
|
|
13649
13681
|
getStarExcludesBlock(starExcludes, t, snippets) +
|
|
13650
13682
|
getImportBindingsBlock(importBindings, t, snippets) +
|
|
@@ -13665,13 +13697,16 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
|
|
|
13665
13697
|
name: null
|
|
13666
13698
|
})}{${n}${n}`;
|
|
13667
13699
|
const wrapperEnd = `${t}${t}})${n}${t}}${s}${n}}));`;
|
|
13668
|
-
magicString
|
|
13700
|
+
magicString
|
|
13701
|
+
.prepend(intro +
|
|
13669
13702
|
getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, namespaceToStringTag) +
|
|
13670
|
-
getHoistedExportsBlock(exports, t, snippets))
|
|
13671
|
-
|
|
13703
|
+
getHoistedExportsBlock(exports, t, snippets))
|
|
13704
|
+
.append(`${outro}${n}${n}` +
|
|
13672
13705
|
getSyntheticExportsBlock(exports, t, snippets) +
|
|
13673
|
-
getMissingExportsBlock(exports, t, snippets))
|
|
13674
|
-
|
|
13706
|
+
getMissingExportsBlock(exports, t, snippets))
|
|
13707
|
+
.indent(`${t}${t}${t}`)
|
|
13708
|
+
.append(wrapperEnd)
|
|
13709
|
+
.prepend(wrapperStart);
|
|
13675
13710
|
}
|
|
13676
13711
|
function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, getPropertyAccess, n }) {
|
|
13677
13712
|
const importBindings = [];
|
|
@@ -13773,7 +13808,7 @@ function safeAccess(name, globalVar, { _, getPropertyAccess }) {
|
|
|
13773
13808
|
.map(part => (propertyPath += getPropertyAccess(part)))
|
|
13774
13809
|
.join(`${_}&&${_}`);
|
|
13775
13810
|
}
|
|
13776
|
-
function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets,
|
|
13811
|
+
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 }) {
|
|
13777
13812
|
const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
13778
13813
|
const factoryVar = compact ? 'f' : 'factory';
|
|
13779
13814
|
const globalVar = compact ? 'g' : 'global';
|
|
@@ -13783,9 +13818,9 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13783
13818
|
message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.'
|
|
13784
13819
|
});
|
|
13785
13820
|
}
|
|
13786
|
-
warnOnBuiltins(
|
|
13787
|
-
const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.
|
|
13788
|
-
const cjsDeps = dependencies.map(m => `require('${m.
|
|
13821
|
+
warnOnBuiltins(onwarn, dependencies);
|
|
13822
|
+
const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
|
|
13823
|
+
const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
|
|
13789
13824
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
13790
13825
|
const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar, getPropertyAccess));
|
|
13791
13826
|
const factoryParams = trimmedImports.map(m => m.name);
|
|
@@ -13862,169 +13897,328 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13862
13897
|
if (namespaceMarkers) {
|
|
13863
13898
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13864
13899
|
}
|
|
13865
|
-
magicString
|
|
13866
|
-
|
|
13900
|
+
magicString
|
|
13901
|
+
.append(`${exportBlock}${namespaceMarkers}${outro}`)
|
|
13902
|
+
.trim()
|
|
13903
|
+
.indent(t)
|
|
13904
|
+
.append(wrapperOutro)
|
|
13905
|
+
.prepend(wrapperIntro);
|
|
13867
13906
|
}
|
|
13868
13907
|
|
|
13869
13908
|
const finalisers = { amd, cjs, es, iife, system, umd };
|
|
13870
13909
|
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13910
|
+
const createHash = () => createHash$1('sha256');
|
|
13911
|
+
|
|
13912
|
+
// Four random characters from the private use area to minimize risk of conflicts
|
|
13913
|
+
const hashPlaceholderLeft = '\uf7f9\ue4d3';
|
|
13914
|
+
const hashPlaceholderRight = '\ue3cc\uf1fe';
|
|
13915
|
+
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
13916
|
+
// This is the size of a sha256
|
|
13917
|
+
const maxHashSize = 64;
|
|
13918
|
+
const defaultHashSize = 8;
|
|
13919
|
+
const getHashPlaceholderGenerator = () => {
|
|
13920
|
+
let nextIndex = 0;
|
|
13921
|
+
return (optionName, hashSize = defaultHashSize) => {
|
|
13922
|
+
if (hashSize > maxHashSize) {
|
|
13923
|
+
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
13924
|
+
}
|
|
13925
|
+
const placeholder = `${hashPlaceholderLeft}${String(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
13926
|
+
if (placeholder.length > hashSize) {
|
|
13927
|
+
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.`));
|
|
13928
|
+
}
|
|
13929
|
+
nextIndex++;
|
|
13930
|
+
return placeholder;
|
|
13931
|
+
};
|
|
13932
|
+
};
|
|
13933
|
+
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}\\d{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
13934
|
+
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
13935
|
+
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
13936
|
+
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
13937
|
+
const containedPlaceholders = new Set();
|
|
13938
|
+
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
13939
|
+
if (placeholders.has(placeholder)) {
|
|
13940
|
+
containedPlaceholders.add(placeholder);
|
|
13941
|
+
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
13942
|
+
}
|
|
13943
|
+
return placeholder;
|
|
13944
|
+
});
|
|
13945
|
+
return { containedPlaceholders, transformedCode };
|
|
13946
|
+
};
|
|
13947
|
+
|
|
13948
|
+
function renderNamePattern(pattern, patternName, replacements) {
|
|
13949
|
+
if (isPathFragment(pattern))
|
|
13950
|
+
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.`));
|
|
13951
|
+
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
13952
|
+
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
13953
|
+
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
13954
|
+
}
|
|
13955
|
+
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
13956
|
+
if (isPathFragment(replacement))
|
|
13957
|
+
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
13958
|
+
return replacement;
|
|
13959
|
+
});
|
|
13960
|
+
}
|
|
13961
|
+
function makeUnique(name, existingNames) {
|
|
13962
|
+
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
13963
|
+
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
13964
|
+
return name;
|
|
13965
|
+
const ext = extname(name);
|
|
13966
|
+
name = name.substring(0, name.length - ext.length);
|
|
13967
|
+
let uniqueName, uniqueIndex = 1;
|
|
13968
|
+
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
13969
|
+
;
|
|
13970
|
+
return uniqueName;
|
|
13971
|
+
}
|
|
13972
|
+
|
|
13973
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
13974
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
13975
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
13976
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
13977
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
13978
|
+
ext: () => extname(emittedName).substring(1),
|
|
13979
|
+
extname: () => extname(emittedName),
|
|
13980
|
+
hash: size => createHash()
|
|
13981
|
+
.update(source)
|
|
13982
|
+
.digest('hex')
|
|
13983
|
+
.substring(0, size || defaultHashSize),
|
|
13984
|
+
name: () => emittedName.substring(0, emittedName.length - extname(emittedName).length)
|
|
13985
|
+
}), bundle);
|
|
13986
|
+
}
|
|
13987
|
+
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
13988
|
+
if (fileName in bundle) {
|
|
13989
|
+
warn(errFileNameConflict(fileName));
|
|
13876
13990
|
}
|
|
13877
|
-
|
|
13878
|
-
|
|
13991
|
+
bundle[fileName] = FILE_PLACEHOLDER;
|
|
13992
|
+
}
|
|
13993
|
+
const FILE_PLACEHOLDER = {
|
|
13994
|
+
type: 'placeholder'
|
|
13995
|
+
};
|
|
13996
|
+
function hasValidType(emittedFile) {
|
|
13997
|
+
return Boolean(emittedFile &&
|
|
13998
|
+
(emittedFile.type === 'asset' ||
|
|
13999
|
+
emittedFile.type === 'chunk'));
|
|
14000
|
+
}
|
|
14001
|
+
function hasValidName(emittedFile) {
|
|
14002
|
+
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
14003
|
+
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
14004
|
+
}
|
|
14005
|
+
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
14006
|
+
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
14007
|
+
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
14008
|
+
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.`));
|
|
13879
14009
|
}
|
|
14010
|
+
return source;
|
|
13880
14011
|
}
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
this.names = map.names;
|
|
13885
|
-
this.mappings = map.mappings;
|
|
14012
|
+
function getAssetFileName(file, referenceId) {
|
|
14013
|
+
if (typeof file.fileName !== 'string') {
|
|
14014
|
+
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
13886
14015
|
}
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
const nameIndexMap = new Map();
|
|
13893
|
-
const mappings = [];
|
|
13894
|
-
for (const line of this.mappings) {
|
|
13895
|
-
const tracedLine = [];
|
|
13896
|
-
for (const segment of line) {
|
|
13897
|
-
if (segment.length === 1)
|
|
13898
|
-
continue;
|
|
13899
|
-
const source = this.sources[segment[1]];
|
|
13900
|
-
if (!source)
|
|
13901
|
-
continue;
|
|
13902
|
-
const traced = source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : '');
|
|
13903
|
-
if (traced) {
|
|
13904
|
-
const { column, line, name, source: { content, filename } } = traced;
|
|
13905
|
-
let sourceIndex = sourceIndexMap.get(filename);
|
|
13906
|
-
if (sourceIndex === undefined) {
|
|
13907
|
-
sourceIndex = sources.length;
|
|
13908
|
-
sources.push(filename);
|
|
13909
|
-
sourceIndexMap.set(filename, sourceIndex);
|
|
13910
|
-
sourcesContent[sourceIndex] = content;
|
|
13911
|
-
}
|
|
13912
|
-
else if (sourcesContent[sourceIndex] == null) {
|
|
13913
|
-
sourcesContent[sourceIndex] = content;
|
|
13914
|
-
}
|
|
13915
|
-
else if (content != null && sourcesContent[sourceIndex] !== content) {
|
|
13916
|
-
return error({
|
|
13917
|
-
message: `Multiple conflicting contents for sourcemap source ${filename}`
|
|
13918
|
-
});
|
|
13919
|
-
}
|
|
13920
|
-
const tracedSegment = [segment[0], sourceIndex, line, column];
|
|
13921
|
-
if (name) {
|
|
13922
|
-
let nameIndex = nameIndexMap.get(name);
|
|
13923
|
-
if (nameIndex === undefined) {
|
|
13924
|
-
nameIndex = names.length;
|
|
13925
|
-
names.push(name);
|
|
13926
|
-
nameIndexMap.set(name, nameIndex);
|
|
13927
|
-
}
|
|
13928
|
-
tracedSegment[4] = nameIndex;
|
|
13929
|
-
}
|
|
13930
|
-
tracedLine.push(tracedSegment);
|
|
13931
|
-
}
|
|
13932
|
-
}
|
|
13933
|
-
mappings.push(tracedLine);
|
|
13934
|
-
}
|
|
13935
|
-
return { mappings, names, sources, sourcesContent };
|
|
14016
|
+
return file.fileName;
|
|
14017
|
+
}
|
|
14018
|
+
function getChunkFileName(file, facadeChunkByModule) {
|
|
14019
|
+
if (file.fileName) {
|
|
14020
|
+
return file.fileName;
|
|
13936
14021
|
}
|
|
13937
|
-
|
|
13938
|
-
const
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
const source = this.sources[segment[1]];
|
|
13954
|
-
if (!source)
|
|
13955
|
-
return null;
|
|
13956
|
-
return source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : name);
|
|
14022
|
+
if (facadeChunkByModule) {
|
|
14023
|
+
const chunk = facadeChunkByModule.get(file.module);
|
|
14024
|
+
return chunk.id || chunk.getFileName();
|
|
14025
|
+
}
|
|
14026
|
+
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
14027
|
+
}
|
|
14028
|
+
class FileEmitter {
|
|
14029
|
+
constructor(graph, options, baseFileEmitter) {
|
|
14030
|
+
this.graph = graph;
|
|
14031
|
+
this.options = options;
|
|
14032
|
+
this.bundle = null;
|
|
14033
|
+
this.facadeChunkByModule = null;
|
|
14034
|
+
this.outputOptions = null;
|
|
14035
|
+
this.emitFile = (emittedFile) => {
|
|
14036
|
+
if (!hasValidType(emittedFile)) {
|
|
14037
|
+
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
13957
14038
|
}
|
|
13958
|
-
if (
|
|
13959
|
-
|
|
14039
|
+
if (!hasValidName(emittedFile)) {
|
|
14040
|
+
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}".`));
|
|
14041
|
+
}
|
|
14042
|
+
if (emittedFile.type === 'chunk') {
|
|
14043
|
+
return this.emitChunk(emittedFile);
|
|
14044
|
+
}
|
|
14045
|
+
return this.emitAsset(emittedFile);
|
|
14046
|
+
};
|
|
14047
|
+
this.finaliseAssets = () => {
|
|
14048
|
+
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
14049
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
14050
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
14051
|
+
}
|
|
14052
|
+
};
|
|
14053
|
+
this.getFileName = (fileReferenceId) => {
|
|
14054
|
+
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
14055
|
+
if (!emittedFile)
|
|
14056
|
+
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
14057
|
+
if (emittedFile.type === 'chunk') {
|
|
14058
|
+
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
14059
|
+
}
|
|
14060
|
+
return getAssetFileName(emittedFile, fileReferenceId);
|
|
14061
|
+
};
|
|
14062
|
+
this.setAssetSource = (referenceId, requestedSource) => {
|
|
14063
|
+
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
14064
|
+
if (!consumedFile)
|
|
14065
|
+
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
14066
|
+
if (consumedFile.type !== 'asset') {
|
|
14067
|
+
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
14068
|
+
}
|
|
14069
|
+
if (consumedFile.source !== undefined) {
|
|
14070
|
+
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
14071
|
+
}
|
|
14072
|
+
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
14073
|
+
if (this.bundle) {
|
|
14074
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
13960
14075
|
}
|
|
13961
14076
|
else {
|
|
13962
|
-
|
|
14077
|
+
consumedFile.source = source;
|
|
14078
|
+
}
|
|
14079
|
+
};
|
|
14080
|
+
this.setChunkInformation = (facadeChunkByModule) => {
|
|
14081
|
+
this.facadeChunkByModule = facadeChunkByModule;
|
|
14082
|
+
};
|
|
14083
|
+
this.setOutputBundle = (outputBundle, outputOptions) => {
|
|
14084
|
+
this.outputOptions = outputOptions;
|
|
14085
|
+
this.bundle = outputBundle;
|
|
14086
|
+
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
14087
|
+
if (emittedFile.fileName) {
|
|
14088
|
+
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
14089
|
+
}
|
|
14090
|
+
}
|
|
14091
|
+
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
14092
|
+
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
14093
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
14094
|
+
}
|
|
14095
|
+
}
|
|
14096
|
+
};
|
|
14097
|
+
this.filesByReferenceId = baseFileEmitter
|
|
14098
|
+
? new Map(baseFileEmitter.filesByReferenceId)
|
|
14099
|
+
: new Map();
|
|
14100
|
+
}
|
|
14101
|
+
assignReferenceId(file, idBase) {
|
|
14102
|
+
let referenceId;
|
|
14103
|
+
do {
|
|
14104
|
+
referenceId = createHash()
|
|
14105
|
+
.update(referenceId || idBase)
|
|
14106
|
+
.digest('hex')
|
|
14107
|
+
.substring(0, 8);
|
|
14108
|
+
} while (this.filesByReferenceId.has(referenceId));
|
|
14109
|
+
this.filesByReferenceId.set(referenceId, file);
|
|
14110
|
+
return referenceId;
|
|
14111
|
+
}
|
|
14112
|
+
emitAsset(emittedAsset) {
|
|
14113
|
+
const source = typeof emittedAsset.source !== 'undefined'
|
|
14114
|
+
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
14115
|
+
: undefined;
|
|
14116
|
+
const consumedAsset = {
|
|
14117
|
+
fileName: emittedAsset.fileName,
|
|
14118
|
+
name: emittedAsset.name,
|
|
14119
|
+
source,
|
|
14120
|
+
type: 'asset'
|
|
14121
|
+
};
|
|
14122
|
+
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
14123
|
+
if (this.bundle) {
|
|
14124
|
+
if (emittedAsset.fileName) {
|
|
14125
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
14126
|
+
}
|
|
14127
|
+
if (source !== undefined) {
|
|
14128
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
13963
14129
|
}
|
|
13964
14130
|
}
|
|
13965
|
-
return
|
|
14131
|
+
return referenceId;
|
|
13966
14132
|
}
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
if (map.mappings) {
|
|
13971
|
-
return new Link(map, [source]);
|
|
14133
|
+
emitChunk(emittedChunk) {
|
|
14134
|
+
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
14135
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
13972
14136
|
}
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
13978
|
-
|
|
13979
|
-
|
|
14137
|
+
if (typeof emittedChunk.id !== 'string') {
|
|
14138
|
+
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
14139
|
+
}
|
|
14140
|
+
const consumedChunk = {
|
|
14141
|
+
fileName: emittedChunk.fileName,
|
|
14142
|
+
module: null,
|
|
14143
|
+
name: emittedChunk.name || emittedChunk.id,
|
|
14144
|
+
type: 'chunk'
|
|
14145
|
+
};
|
|
14146
|
+
this.graph.moduleLoader
|
|
14147
|
+
.emitChunk(emittedChunk)
|
|
14148
|
+
.then(module => (consumedChunk.module = module))
|
|
14149
|
+
.catch(() => {
|
|
14150
|
+
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
14151
|
+
// once module loading has finished
|
|
13980
14152
|
});
|
|
13981
|
-
return
|
|
13982
|
-
mappings: [],
|
|
13983
|
-
names: []
|
|
13984
|
-
}, [source]);
|
|
13985
|
-
};
|
|
13986
|
-
}
|
|
13987
|
-
function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, linkMap) {
|
|
13988
|
-
let source;
|
|
13989
|
-
if (!originalSourcemap) {
|
|
13990
|
-
source = new Source(id, originalCode);
|
|
14153
|
+
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
13991
14154
|
}
|
|
13992
|
-
|
|
13993
|
-
const
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
|
|
13997
|
-
const
|
|
13998
|
-
|
|
14155
|
+
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
14156
|
+
const fileName = consumedFile.fileName ||
|
|
14157
|
+
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
14158
|
+
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
14159
|
+
// We must not modify the original assets to avoid interaction between outputs
|
|
14160
|
+
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
14161
|
+
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
14162
|
+
bundle[fileName] = {
|
|
14163
|
+
fileName,
|
|
14164
|
+
name: consumedFile.name,
|
|
14165
|
+
source,
|
|
14166
|
+
type: 'asset'
|
|
14167
|
+
};
|
|
13999
14168
|
}
|
|
14000
|
-
return sourcemapChain.reduce(linkMap, source);
|
|
14001
14169
|
}
|
|
14002
|
-
function
|
|
14003
|
-
const
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
.map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
|
|
14007
|
-
const link = new Link(map, moduleSources);
|
|
14008
|
-
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
14009
|
-
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
14010
|
-
if (file) {
|
|
14011
|
-
const directory = dirname(file);
|
|
14012
|
-
sources = sources.map((source) => relative$1(directory, source));
|
|
14013
|
-
file = basename(file);
|
|
14170
|
+
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
14171
|
+
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
14172
|
+
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
14173
|
+
return fileName;
|
|
14014
14174
|
}
|
|
14015
|
-
|
|
14016
|
-
return new SourceMap({ file, mappings, names, sources, sourcesContent });
|
|
14175
|
+
return null;
|
|
14017
14176
|
}
|
|
14018
|
-
function
|
|
14019
|
-
if (
|
|
14020
|
-
return
|
|
14177
|
+
function areSourcesEqual(sourceA, sourceB) {
|
|
14178
|
+
if (typeof sourceA === 'string') {
|
|
14179
|
+
return sourceA === sourceB;
|
|
14021
14180
|
}
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14181
|
+
if (typeof sourceB === 'string') {
|
|
14182
|
+
return false;
|
|
14183
|
+
}
|
|
14184
|
+
if ('equals' in sourceA) {
|
|
14185
|
+
return sourceA.equals(sourceB);
|
|
14186
|
+
}
|
|
14187
|
+
if (sourceA.length !== sourceB.length) {
|
|
14188
|
+
return false;
|
|
14189
|
+
}
|
|
14190
|
+
for (let index = 0; index < sourceA.length; index++) {
|
|
14191
|
+
if (sourceA[index] !== sourceB[index]) {
|
|
14192
|
+
return false;
|
|
14193
|
+
}
|
|
14194
|
+
}
|
|
14195
|
+
return true;
|
|
14196
|
+
}
|
|
14026
14197
|
|
|
14027
|
-
const
|
|
14198
|
+
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14199
|
+
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14200
|
+
async function createAddons(options, outputPluginDriver, chunk) {
|
|
14201
|
+
try {
|
|
14202
|
+
let [banner, footer, intro, outro] = await Promise.all([
|
|
14203
|
+
outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
|
|
14204
|
+
outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
|
|
14205
|
+
outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
|
|
14206
|
+
outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
|
|
14207
|
+
]);
|
|
14208
|
+
if (intro)
|
|
14209
|
+
intro += '\n\n';
|
|
14210
|
+
if (outro)
|
|
14211
|
+
outro = `\n\n${outro}`;
|
|
14212
|
+
if (banner)
|
|
14213
|
+
banner += '\n';
|
|
14214
|
+
if (footer)
|
|
14215
|
+
footer = '\n' + footer;
|
|
14216
|
+
return { banner, footer, intro, outro };
|
|
14217
|
+
}
|
|
14218
|
+
catch (err) {
|
|
14219
|
+
return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
|
|
14220
|
+
}
|
|
14221
|
+
}
|
|
14028
14222
|
|
|
14029
14223
|
const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
14030
14224
|
amd: deconflictImportsOther,
|
|
@@ -14034,21 +14228,21 @@ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
|
14034
14228
|
system: deconflictImportsEsmOrSystem,
|
|
14035
14229
|
umd: deconflictImportsOther
|
|
14036
14230
|
};
|
|
14037
|
-
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14231
|
+
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14038
14232
|
const reversedModules = modules.slice().reverse();
|
|
14039
14233
|
for (const module of reversedModules) {
|
|
14040
14234
|
module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14041
14235
|
}
|
|
14042
14236
|
deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
|
|
14043
|
-
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, syntheticExports);
|
|
14237
|
+
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
|
|
14044
14238
|
for (const module of reversedModules) {
|
|
14045
14239
|
module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14046
14240
|
}
|
|
14047
14241
|
}
|
|
14048
|
-
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, syntheticExports) {
|
|
14242
|
+
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
|
|
14049
14243
|
// This is needed for namespace reexports
|
|
14050
14244
|
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14051
|
-
if (preserveModules || dependency instanceof
|
|
14245
|
+
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14052
14246
|
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14053
14247
|
}
|
|
14054
14248
|
}
|
|
@@ -14056,7 +14250,9 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14056
14250
|
const module = variable.module;
|
|
14057
14251
|
const name = variable.name;
|
|
14058
14252
|
if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
|
|
14059
|
-
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14253
|
+
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14254
|
+
? externalChunkByModule.get(module)
|
|
14255
|
+
: chunkByModule.get(module)).variableName);
|
|
14060
14256
|
}
|
|
14061
14257
|
else if (module instanceof ExternalModule && name === 'default') {
|
|
14062
14258
|
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
@@ -14071,12 +14267,12 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14071
14267
|
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14072
14268
|
}
|
|
14073
14269
|
}
|
|
14074
|
-
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule) {
|
|
14075
|
-
for (const
|
|
14076
|
-
|
|
14270
|
+
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14271
|
+
for (const chunk of dependencies) {
|
|
14272
|
+
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14077
14273
|
}
|
|
14078
|
-
for (const
|
|
14079
|
-
|
|
14274
|
+
for (const chunk of deconflictedNamespace) {
|
|
14275
|
+
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14080
14276
|
}
|
|
14081
14277
|
for (const externalModule of deconflictedDefault) {
|
|
14082
14278
|
if (deconflictedNamespace.has(externalModule) &&
|
|
@@ -14090,12 +14286,13 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14090
14286
|
for (const variable of imports) {
|
|
14091
14287
|
const module = variable.module;
|
|
14092
14288
|
if (module instanceof ExternalModule) {
|
|
14289
|
+
const chunk = externalChunkByModule.get(module);
|
|
14093
14290
|
const name = variable.name;
|
|
14094
14291
|
if (name === 'default') {
|
|
14095
14292
|
const moduleInterop = String(interop(module.id));
|
|
14096
14293
|
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
14097
|
-
?
|
|
14098
|
-
:
|
|
14294
|
+
? chunk.defaultVariableName
|
|
14295
|
+
: chunk.variableName;
|
|
14099
14296
|
if (isDefaultAProperty(moduleInterop, externalLiveBindings)) {
|
|
14100
14297
|
variable.setRenderNames(variableName, 'default');
|
|
14101
14298
|
}
|
|
@@ -14105,12 +14302,12 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14105
14302
|
}
|
|
14106
14303
|
else if (name === '*') {
|
|
14107
14304
|
variable.setRenderNames(null, namespaceInteropHelpersByInteropType[String(interop(module.id))]
|
|
14108
|
-
?
|
|
14109
|
-
:
|
|
14305
|
+
? chunk.namespaceVariableName
|
|
14306
|
+
: chunk.variableName);
|
|
14110
14307
|
}
|
|
14111
14308
|
else {
|
|
14112
14309
|
// if the second parameter is `null`, it uses its "name" for the property name
|
|
14113
|
-
variable.setRenderNames(
|
|
14310
|
+
variable.setRenderNames(chunk.variableName, null);
|
|
14114
14311
|
}
|
|
14115
14312
|
}
|
|
14116
14313
|
else {
|
|
@@ -14144,15 +14341,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
|
|
|
14144
14341
|
}
|
|
14145
14342
|
}
|
|
14146
14343
|
|
|
14147
|
-
const needsEscapeRegEx = /[\\'\r\n\u2028\u2029]/;
|
|
14148
|
-
const quoteNewlineRegEx = /(['\r\n\u2028\u2029])/g;
|
|
14149
|
-
const backSlashRegEx = /\\/g;
|
|
14150
|
-
function escapeId(id) {
|
|
14151
|
-
if (!id.match(needsEscapeRegEx))
|
|
14152
|
-
return id;
|
|
14153
|
-
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
|
14154
|
-
}
|
|
14155
|
-
|
|
14156
14344
|
function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
|
|
14157
14345
|
let nameIndex = 0;
|
|
14158
14346
|
for (const variable of exports) {
|
|
@@ -14244,14 +14432,14 @@ function getIndentString(modules, options) {
|
|
|
14244
14432
|
return '\t';
|
|
14245
14433
|
}
|
|
14246
14434
|
|
|
14247
|
-
function getStaticDependencies(chunk, orderedModules, chunkByModule) {
|
|
14435
|
+
function getStaticDependencies(chunk, orderedModules, chunkByModule, externalChunkByModule) {
|
|
14248
14436
|
const staticDependencyBlocks = [];
|
|
14249
14437
|
const handledDependencies = new Set();
|
|
14250
14438
|
for (let modulePos = orderedModules.length - 1; modulePos >= 0; modulePos--) {
|
|
14251
14439
|
const module = orderedModules[modulePos];
|
|
14252
14440
|
if (!handledDependencies.has(module)) {
|
|
14253
14441
|
const staticDependencies = [];
|
|
14254
|
-
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule);
|
|
14442
|
+
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule, externalChunkByModule);
|
|
14255
14443
|
staticDependencyBlocks.unshift(staticDependencies);
|
|
14256
14444
|
}
|
|
14257
14445
|
}
|
|
@@ -14263,11 +14451,11 @@ function getStaticDependencies(chunk, orderedModules, chunkByModule) {
|
|
|
14263
14451
|
}
|
|
14264
14452
|
return dependencies;
|
|
14265
14453
|
}
|
|
14266
|
-
function addStaticDependencies(module, staticDependencies, handledModules, chunk, chunkByModule) {
|
|
14454
|
+
function addStaticDependencies(module, staticDependencies, handledModules, chunk, chunkByModule, externalChunkByModule) {
|
|
14267
14455
|
const dependencies = module.getDependenciesToBeIncluded();
|
|
14268
14456
|
for (const dependency of dependencies) {
|
|
14269
14457
|
if (dependency instanceof ExternalModule) {
|
|
14270
|
-
staticDependencies.push(dependency);
|
|
14458
|
+
staticDependencies.push(externalChunkByModule.get(dependency));
|
|
14271
14459
|
continue;
|
|
14272
14460
|
}
|
|
14273
14461
|
const dependencyChunk = chunkByModule.get(dependency);
|
|
@@ -14277,91 +14465,29 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
|
|
|
14277
14465
|
}
|
|
14278
14466
|
if (!handledModules.has(dependency)) {
|
|
14279
14467
|
handledModules.add(dependency);
|
|
14280
|
-
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule);
|
|
14468
|
+
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule, externalChunkByModule);
|
|
14281
14469
|
}
|
|
14282
14470
|
}
|
|
14283
14471
|
}
|
|
14284
14472
|
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
if (typeof map === 'string') {
|
|
14289
|
-
map = JSON.parse(map);
|
|
14290
|
-
}
|
|
14291
|
-
if (map.mappings === '') {
|
|
14292
|
-
return {
|
|
14293
|
-
mappings: [],
|
|
14294
|
-
names: [],
|
|
14295
|
-
sources: [],
|
|
14296
|
-
version: 3
|
|
14297
|
-
};
|
|
14298
|
-
}
|
|
14299
|
-
const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
|
|
14300
|
-
return { ...map, mappings };
|
|
14301
|
-
}
|
|
14302
|
-
|
|
14303
|
-
function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemapChain }) {
|
|
14304
|
-
const renderChunkReducer = (code, result, plugin) => {
|
|
14305
|
-
if (result == null)
|
|
14306
|
-
return code;
|
|
14307
|
-
if (typeof result === 'string')
|
|
14308
|
-
result = {
|
|
14309
|
-
code: result,
|
|
14310
|
-
map: undefined
|
|
14311
|
-
};
|
|
14312
|
-
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
|
|
14313
|
-
if (result.map !== null) {
|
|
14314
|
-
const map = decodedSourcemap(result.map);
|
|
14315
|
-
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
|
|
14316
|
-
}
|
|
14317
|
-
return result.code;
|
|
14318
|
-
};
|
|
14319
|
-
return outputPluginDriver.hookReduceArg0('renderChunk', [code, renderChunk, options], renderChunkReducer);
|
|
14320
|
-
}
|
|
14321
|
-
|
|
14322
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
14323
|
-
if (isPathFragment(pattern))
|
|
14324
|
-
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.`));
|
|
14325
|
-
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
14326
|
-
if (!replacements.hasOwnProperty(type)) {
|
|
14327
|
-
return error(errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`));
|
|
14328
|
-
}
|
|
14329
|
-
const replacement = replacements[type]();
|
|
14330
|
-
if (isPathFragment(replacement))
|
|
14331
|
-
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14332
|
-
return replacement;
|
|
14333
|
-
});
|
|
14334
|
-
}
|
|
14335
|
-
function makeUnique(name, existingNames) {
|
|
14336
|
-
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14337
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14338
|
-
return name;
|
|
14339
|
-
const ext = extname(name);
|
|
14340
|
-
name = name.substring(0, name.length - ext.length);
|
|
14341
|
-
let uniqueName, uniqueIndex = 1;
|
|
14342
|
-
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14343
|
-
;
|
|
14344
|
-
return uniqueName;
|
|
14345
|
-
}
|
|
14346
|
-
|
|
14347
|
-
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
|
|
14348
|
-
function getGlobalName(module, globals, hasExports, warn) {
|
|
14349
|
-
const globalName = typeof globals === 'function' ? globals(module.id) : globals[module.id];
|
|
14473
|
+
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
|
|
14474
|
+
function getGlobalName(chunk, globals, hasExports, warn) {
|
|
14475
|
+
const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
|
|
14350
14476
|
if (globalName) {
|
|
14351
14477
|
return globalName;
|
|
14352
14478
|
}
|
|
14353
14479
|
if (hasExports) {
|
|
14354
14480
|
warn({
|
|
14355
14481
|
code: 'MISSING_GLOBAL_NAME',
|
|
14356
|
-
guess:
|
|
14357
|
-
message: `No name was provided for external module '${
|
|
14358
|
-
source:
|
|
14482
|
+
guess: chunk.variableName,
|
|
14483
|
+
message: `No name was provided for external module '${chunk.id}' in output.globals – guessing '${chunk.variableName}'`,
|
|
14484
|
+
source: chunk.id
|
|
14359
14485
|
});
|
|
14360
|
-
return
|
|
14486
|
+
return chunk.variableName;
|
|
14361
14487
|
}
|
|
14362
14488
|
}
|
|
14363
14489
|
class Chunk {
|
|
14364
|
-
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, manualChunkAlias) {
|
|
14490
|
+
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, manualChunkAlias, getPlaceholder, bundle, inputBase, snippets) {
|
|
14365
14491
|
this.orderedModules = orderedModules;
|
|
14366
14492
|
this.inputOptions = inputOptions;
|
|
14367
14493
|
this.outputOptions = outputOptions;
|
|
@@ -14369,19 +14495,22 @@ class Chunk {
|
|
|
14369
14495
|
this.pluginDriver = pluginDriver;
|
|
14370
14496
|
this.modulesById = modulesById;
|
|
14371
14497
|
this.chunkByModule = chunkByModule;
|
|
14498
|
+
this.externalChunkByModule = externalChunkByModule;
|
|
14372
14499
|
this.facadeChunkByModule = facadeChunkByModule;
|
|
14373
14500
|
this.includedNamespaces = includedNamespaces;
|
|
14374
14501
|
this.manualChunkAlias = manualChunkAlias;
|
|
14502
|
+
this.getPlaceholder = getPlaceholder;
|
|
14503
|
+
this.bundle = bundle;
|
|
14504
|
+
this.inputBase = inputBase;
|
|
14505
|
+
this.snippets = snippets;
|
|
14375
14506
|
this.entryModules = [];
|
|
14376
14507
|
this.exportMode = 'named';
|
|
14377
14508
|
this.facadeModule = null;
|
|
14378
14509
|
this.id = null;
|
|
14379
14510
|
this.namespaceVariableName = '';
|
|
14380
|
-
this.needsExportsShim = false;
|
|
14381
14511
|
this.variableName = '';
|
|
14382
14512
|
this.accessedGlobalsByScope = new Map();
|
|
14383
14513
|
this.dependencies = new Set();
|
|
14384
|
-
this.dynamicDependencies = new Set();
|
|
14385
14514
|
this.dynamicEntryModules = [];
|
|
14386
14515
|
this.dynamicName = null;
|
|
14387
14516
|
this.exportNamesByVariable = new Map();
|
|
@@ -14391,23 +14520,23 @@ class Chunk {
|
|
|
14391
14520
|
this.implicitEntryModules = [];
|
|
14392
14521
|
this.implicitlyLoadedBefore = new Set();
|
|
14393
14522
|
this.imports = new Set();
|
|
14523
|
+
this.includedDynamicImports = null;
|
|
14394
14524
|
this.includedReexportsByModule = new Map();
|
|
14395
|
-
|
|
14396
|
-
// This may only be updated in the constructor
|
|
14525
|
+
// This may be updated in the constructor
|
|
14397
14526
|
this.isEmpty = true;
|
|
14398
14527
|
this.name = null;
|
|
14528
|
+
this.needsExportsShim = false;
|
|
14529
|
+
this.preRenderedChunkInfo = null;
|
|
14530
|
+
this.preliminaryFileName = null;
|
|
14531
|
+
this.renderedChunkInfo = null;
|
|
14399
14532
|
this.renderedDependencies = null;
|
|
14400
|
-
this.renderedExports = null;
|
|
14401
|
-
this.renderedHash = undefined;
|
|
14402
|
-
this.renderedModuleSources = new Map();
|
|
14403
14533
|
this.renderedModules = Object.create(null);
|
|
14404
|
-
this.renderedSource = null;
|
|
14405
14534
|
this.sortedExportNames = null;
|
|
14406
14535
|
this.strictFacade = false;
|
|
14407
|
-
this.usedModules = undefined;
|
|
14408
14536
|
this.execIndex = orderedModules.length > 0 ? orderedModules[0].execIndex : Infinity;
|
|
14409
14537
|
const chunkModules = new Set(orderedModules);
|
|
14410
14538
|
for (const module of orderedModules) {
|
|
14539
|
+
chunkByModule.set(module, this);
|
|
14411
14540
|
if (module.namespace.included) {
|
|
14412
14541
|
includedNamespaces.add(module);
|
|
14413
14542
|
}
|
|
@@ -14433,14 +14562,16 @@ class Chunk {
|
|
|
14433
14562
|
}
|
|
14434
14563
|
this.suggestedVariableName = makeLegal(this.generateVariableName());
|
|
14435
14564
|
}
|
|
14436
|
-
static generateFacade(inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, facadedModule, facadeName) {
|
|
14437
|
-
const chunk = new Chunk([], inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, includedNamespaces, null);
|
|
14565
|
+
static generateFacade(inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, facadedModule, facadeName, getPlaceholder, bundle, inputBase, snippets) {
|
|
14566
|
+
const chunk = new Chunk([], inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, externalChunkByModule, facadeChunkByModule, includedNamespaces, null, getPlaceholder, bundle, inputBase, snippets);
|
|
14438
14567
|
chunk.assignFacadeName(facadeName, facadedModule);
|
|
14439
14568
|
if (!facadeChunkByModule.has(facadedModule)) {
|
|
14440
14569
|
facadeChunkByModule.set(facadedModule, chunk);
|
|
14441
14570
|
}
|
|
14442
14571
|
for (const dependency of facadedModule.getDependenciesToBeIncluded()) {
|
|
14443
|
-
chunk.dependencies.add(dependency instanceof Module
|
|
14572
|
+
chunk.dependencies.add(dependency instanceof Module
|
|
14573
|
+
? chunkByModule.get(dependency)
|
|
14574
|
+
: externalChunkByModule.get(dependency));
|
|
14444
14575
|
}
|
|
14445
14576
|
if (!chunk.dependencies.has(chunkByModule.get(facadedModule)) &&
|
|
14446
14577
|
facadedModule.info.moduleSideEffects &&
|
|
@@ -14456,17 +14587,6 @@ class Chunk {
|
|
|
14456
14587
|
const moduleExportNamesByVariable = module.getExportNamesByVariable();
|
|
14457
14588
|
for (const exposedVariable of this.exports) {
|
|
14458
14589
|
if (!moduleExportNamesByVariable.has(exposedVariable)) {
|
|
14459
|
-
if (moduleExportNamesByVariable.size === 0 &&
|
|
14460
|
-
module.isUserDefinedEntryPoint &&
|
|
14461
|
-
module.preserveSignature === 'strict' &&
|
|
14462
|
-
this.unsetOptions.has('preserveEntrySignatures')) {
|
|
14463
|
-
this.inputOptions.onwarn({
|
|
14464
|
-
code: 'EMPTY_FACADE',
|
|
14465
|
-
id: module.id,
|
|
14466
|
-
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.`,
|
|
14467
|
-
url: 'https://rollupjs.org/guide/en/#preserveentrysignatures'
|
|
14468
|
-
});
|
|
14469
|
-
}
|
|
14470
14590
|
return false;
|
|
14471
14591
|
}
|
|
14472
14592
|
}
|
|
@@ -14537,11 +14657,11 @@ class Chunk {
|
|
|
14537
14657
|
if (module.preserveSignature) {
|
|
14538
14658
|
this.strictFacade = needsStrictFacade;
|
|
14539
14659
|
}
|
|
14540
|
-
this.assignFacadeName(requiredFacades.shift(), module);
|
|
14660
|
+
this.assignFacadeName(requiredFacades.shift(), module, this.outputOptions.preserveModules);
|
|
14541
14661
|
}
|
|
14542
14662
|
}
|
|
14543
14663
|
for (const facadeName of requiredFacades) {
|
|
14544
|
-
facades.push(Chunk.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
|
|
14664
|
+
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));
|
|
14545
14665
|
}
|
|
14546
14666
|
}
|
|
14547
14667
|
for (const module of this.dynamicEntryModules) {
|
|
@@ -14568,89 +14688,24 @@ class Chunk {
|
|
|
14568
14688
|
}
|
|
14569
14689
|
return facades;
|
|
14570
14690
|
}
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
}
|
|
14575
|
-
const [pattern, patternName] = this.facadeModule && this.facadeModule.isUserDefinedEntryPoint
|
|
14576
|
-
? [options.entryFileNames, 'output.entryFileNames']
|
|
14577
|
-
: [options.chunkFileNames, 'output.chunkFileNames'];
|
|
14578
|
-
return makeUnique(renderNamePattern(typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, patternName, {
|
|
14579
|
-
format: () => options.format,
|
|
14580
|
-
hash: () => includeHash
|
|
14581
|
-
? this.computeContentHashWithDependencies(addons, options, existingNames)
|
|
14582
|
-
: '[hash]',
|
|
14583
|
-
name: () => this.getChunkName()
|
|
14584
|
-
}), existingNames);
|
|
14585
|
-
}
|
|
14586
|
-
generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
|
|
14587
|
-
const [{ id }] = this.orderedModules;
|
|
14588
|
-
const sanitizedId = this.outputOptions.sanitizeFileName(id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
14589
|
-
let path;
|
|
14590
|
-
const patternOpt = unsetOptions.has('entryFileNames')
|
|
14591
|
-
? '[name][assetExtname].js'
|
|
14592
|
-
: options.entryFileNames;
|
|
14593
|
-
const pattern = typeof patternOpt === 'function' ? patternOpt(this.getChunkInfo()) : patternOpt;
|
|
14594
|
-
if (isAbsolute(sanitizedId)) {
|
|
14595
|
-
const currentDir = dirname(sanitizedId);
|
|
14596
|
-
const extension = extname(sanitizedId);
|
|
14597
|
-
const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
|
|
14598
|
-
assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
|
|
14599
|
-
ext: () => extension.substring(1),
|
|
14600
|
-
extname: () => extension,
|
|
14601
|
-
format: () => options.format,
|
|
14602
|
-
name: () => this.getChunkName()
|
|
14603
|
-
});
|
|
14604
|
-
const currentPath = `${currentDir}/${fileName}`;
|
|
14605
|
-
const { preserveModulesRoot } = options;
|
|
14606
|
-
if (preserveModulesRoot && currentPath.startsWith(preserveModulesRoot)) {
|
|
14607
|
-
path = currentPath.slice(preserveModulesRoot.length).replace(/^[\\/]/, '');
|
|
14608
|
-
}
|
|
14609
|
-
else {
|
|
14610
|
-
path = relative(preserveModulesRelativeDir, currentPath);
|
|
14611
|
-
}
|
|
14612
|
-
}
|
|
14613
|
-
else {
|
|
14614
|
-
const extension = extname(sanitizedId);
|
|
14615
|
-
const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
|
|
14616
|
-
assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
|
|
14617
|
-
ext: () => extension.substring(1),
|
|
14618
|
-
extname: () => extension,
|
|
14619
|
-
format: () => options.format,
|
|
14620
|
-
name: () => getAliasName(sanitizedId)
|
|
14621
|
-
});
|
|
14622
|
-
path = `_virtual/${fileName}`;
|
|
14623
|
-
}
|
|
14624
|
-
return makeUnique(normalize(path), existingNames);
|
|
14625
|
-
}
|
|
14626
|
-
getChunkInfo() {
|
|
14627
|
-
const facadeModule = this.facadeModule;
|
|
14628
|
-
const getChunkName = this.getChunkName.bind(this);
|
|
14691
|
+
generateOutputChunk(code, map, hashesByPlaceholder) {
|
|
14692
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
14693
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
14629
14694
|
return {
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14695
|
+
...renderedChunkInfo,
|
|
14696
|
+
code,
|
|
14697
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
14698
|
+
fileName: finalize(renderedChunkInfo.fileName),
|
|
14699
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
14700
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
14701
|
+
finalize(fileName),
|
|
14702
|
+
bindings
|
|
14703
|
+
])),
|
|
14704
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
14705
|
+
map,
|
|
14706
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
14640
14707
|
};
|
|
14641
14708
|
}
|
|
14642
|
-
getChunkInfoWithFileNames() {
|
|
14643
|
-
return Object.assign(this.getChunkInfo(), {
|
|
14644
|
-
code: undefined,
|
|
14645
|
-
dynamicImports: Array.from(this.dynamicDependencies, getId),
|
|
14646
|
-
fileName: this.id,
|
|
14647
|
-
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
|
|
14648
|
-
importedBindings: this.getImportedBindingsPerDependency(),
|
|
14649
|
-
imports: Array.from(this.dependencies, getId),
|
|
14650
|
-
map: undefined,
|
|
14651
|
-
referencedFiles: this.getReferencedFiles()
|
|
14652
|
-
});
|
|
14653
|
-
}
|
|
14654
14709
|
getChunkName() {
|
|
14655
14710
|
var _a;
|
|
14656
14711
|
return ((_a = this.name) !== null && _a !== void 0 ? _a : (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
@@ -14659,25 +14714,61 @@ class Chunk {
|
|
|
14659
14714
|
var _a;
|
|
14660
14715
|
return ((_a = this.sortedExportNames) !== null && _a !== void 0 ? _a : (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14661
14716
|
}
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14666
|
-
|
|
14667
|
-
|
|
14668
|
-
|
|
14717
|
+
getFileName() {
|
|
14718
|
+
var _a;
|
|
14719
|
+
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14720
|
+
}
|
|
14721
|
+
getImportPath(importer) {
|
|
14722
|
+
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd', true));
|
|
14723
|
+
}
|
|
14724
|
+
getPreliminaryFileName() {
|
|
14725
|
+
var _a;
|
|
14726
|
+
if (this.preliminaryFileName) {
|
|
14727
|
+
return this.preliminaryFileName;
|
|
14728
|
+
}
|
|
14729
|
+
let fileName;
|
|
14730
|
+
let hashPlaceholder = null;
|
|
14731
|
+
const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
|
|
14732
|
+
if (file) {
|
|
14733
|
+
fileName = basename(file);
|
|
14734
|
+
}
|
|
14735
|
+
else if (this.fileName !== null) {
|
|
14736
|
+
fileName = this.fileName;
|
|
14737
|
+
}
|
|
14738
|
+
else {
|
|
14739
|
+
const [pattern, patternName] = preserveModules || ((_a = this.facadeModule) === null || _a === void 0 ? void 0 : _a.isUserDefinedEntryPoint)
|
|
14740
|
+
? [entryFileNames, 'output.entryFileNames']
|
|
14741
|
+
: [chunkFileNames, 'output.chunkFileNames'];
|
|
14742
|
+
fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
14743
|
+
format: () => format,
|
|
14744
|
+
hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
|
|
14745
|
+
name: () => this.getChunkName()
|
|
14746
|
+
});
|
|
14747
|
+
if (!hashPlaceholder) {
|
|
14748
|
+
fileName = makeUnique(fileName, this.bundle);
|
|
14669
14749
|
}
|
|
14670
|
-
|
|
14750
|
+
}
|
|
14751
|
+
if (!hashPlaceholder) {
|
|
14752
|
+
this.bundle[fileName] = FILE_PLACEHOLDER;
|
|
14753
|
+
}
|
|
14754
|
+
// Caching is essential to not conflict with the file name reservation above
|
|
14755
|
+
return (this.preliminaryFileName = { fileName, hashPlaceholder });
|
|
14756
|
+
}
|
|
14757
|
+
getRenderedChunkInfo() {
|
|
14758
|
+
if (this.renderedChunkInfo) {
|
|
14759
|
+
return this.renderedChunkInfo;
|
|
14760
|
+
}
|
|
14761
|
+
const resolveFileName = (dependency) => dependency.getFileName();
|
|
14762
|
+
return (this.renderedChunkInfo = {
|
|
14763
|
+
...this.getPreRenderedChunkInfo(),
|
|
14764
|
+
dynamicImports: this.getDynamicDependencies().map(resolveFileName),
|
|
14765
|
+
fileName: this.getFileName(),
|
|
14766
|
+
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, resolveFileName),
|
|
14767
|
+
importedBindings: getImportedBindingsPerDependency(this.getRenderedDependencies(), resolveFileName),
|
|
14768
|
+
imports: Array.from(this.dependencies, resolveFileName),
|
|
14769
|
+
modules: this.renderedModules,
|
|
14770
|
+
referencedFiles: this.getReferencedFiles()
|
|
14671
14771
|
});
|
|
14672
|
-
hash.update(hashAugmentation);
|
|
14673
|
-
hash.update(this.renderedSource.toString());
|
|
14674
|
-
hash.update(this.getExportNames()
|
|
14675
|
-
.map(exportName => {
|
|
14676
|
-
const variable = this.exportsByName.get(exportName);
|
|
14677
|
-
return `${relativeId(variable.module.id).replace(/\\/g, '/')}:${variable.name}:${exportName}`;
|
|
14678
|
-
})
|
|
14679
|
-
.join(','));
|
|
14680
|
-
return (this.renderedHash = hash.digest('hex'));
|
|
14681
14772
|
}
|
|
14682
14773
|
getVariableExportName(variable) {
|
|
14683
14774
|
if (this.outputOptions.preserveModules && variable instanceof NamespaceVariable) {
|
|
@@ -14686,225 +14777,63 @@ class Chunk {
|
|
|
14686
14777
|
return this.exportNamesByVariable.get(variable)[0];
|
|
14687
14778
|
}
|
|
14688
14779
|
link() {
|
|
14689
|
-
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule);
|
|
14780
|
+
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule, this.externalChunkByModule);
|
|
14690
14781
|
for (const module of this.orderedModules) {
|
|
14691
|
-
this.
|
|
14692
|
-
this.addDependenciesToChunk(module.implicitlyLoadedBefore, this.implicitlyLoadedBefore);
|
|
14782
|
+
this.addImplicitlyLoadedBeforeFromModule(module);
|
|
14693
14783
|
this.setUpChunkImportsAndExportsForModule(module);
|
|
14694
14784
|
}
|
|
14695
14785
|
}
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
const {
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
|
|
14703
|
-
dynamicImportFunction: options.dynamicImportFunction,
|
|
14704
|
-
exportNamesByVariable: this.exportNamesByVariable,
|
|
14705
|
-
format: options.format,
|
|
14706
|
-
freeze: options.freeze,
|
|
14707
|
-
indent: this.indentString,
|
|
14708
|
-
namespaceToStringTag: options.namespaceToStringTag,
|
|
14709
|
-
outputPluginDriver: this.pluginDriver,
|
|
14710
|
-
snippets
|
|
14711
|
-
};
|
|
14712
|
-
// for static and dynamic entry points, inline the execution list to avoid loading latency
|
|
14713
|
-
if (options.hoistTransitiveImports &&
|
|
14714
|
-
!this.outputOptions.preserveModules &&
|
|
14715
|
-
this.facadeModule !== null) {
|
|
14716
|
-
for (const dep of this.dependencies) {
|
|
14786
|
+
async render() {
|
|
14787
|
+
const { dependencies, exportMode, facadeModule, inputOptions: { onwarn }, outputOptions, pluginDriver, snippets } = this;
|
|
14788
|
+
const { format, hoistTransitiveImports, preserveModules } = outputOptions;
|
|
14789
|
+
// for static and dynamic entry points, add transitive dependencies to this
|
|
14790
|
+
// chunk's dependencies to avoid loading latency
|
|
14791
|
+
if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
|
|
14792
|
+
for (const dep of dependencies) {
|
|
14717
14793
|
if (dep instanceof Chunk)
|
|
14718
14794
|
this.inlineChunkDependencies(dep);
|
|
14719
14795
|
}
|
|
14720
14796
|
}
|
|
14721
|
-
this.
|
|
14722
|
-
this.
|
|
14723
|
-
|
|
14724
|
-
const
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
renderedLength = source.length();
|
|
14730
|
-
if (renderedLength) {
|
|
14731
|
-
if (options.compact && source.lastLine().includes('//'))
|
|
14732
|
-
source.append('\n');
|
|
14733
|
-
this.renderedModuleSources.set(module, source);
|
|
14734
|
-
magicString.addSource(source);
|
|
14735
|
-
this.usedModules.push(module);
|
|
14736
|
-
}
|
|
14737
|
-
const namespace = module.namespace;
|
|
14738
|
-
if (this.includedNamespaces.has(module) && !this.outputOptions.preserveModules) {
|
|
14739
|
-
const rendered = namespace.renderBlock(renderOptions);
|
|
14740
|
-
if (namespace.renderFirst())
|
|
14741
|
-
hoistedSource += n + rendered;
|
|
14742
|
-
else
|
|
14743
|
-
magicString.addSource(new MagicString(rendered));
|
|
14744
|
-
}
|
|
14745
|
-
}
|
|
14746
|
-
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
14747
|
-
const { renderedModuleSources } = this;
|
|
14748
|
-
renderedModules[module.id] = {
|
|
14749
|
-
get code() {
|
|
14750
|
-
var _a, _b;
|
|
14751
|
-
return (_b = (_a = renderedModuleSources.get(module)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null;
|
|
14752
|
-
},
|
|
14753
|
-
originalLength: module.originalCode.length,
|
|
14754
|
-
removedExports,
|
|
14755
|
-
renderedExports,
|
|
14756
|
-
renderedLength
|
|
14757
|
-
};
|
|
14758
|
-
}
|
|
14759
|
-
if (hoistedSource)
|
|
14760
|
-
magicString.prepend(hoistedSource + n + n);
|
|
14761
|
-
if (this.needsExportsShim) {
|
|
14762
|
-
magicString.prepend(`${n}${snippets.cnst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}`);
|
|
14763
|
-
}
|
|
14764
|
-
if (options.compact) {
|
|
14765
|
-
this.renderedSource = magicString;
|
|
14766
|
-
}
|
|
14767
|
-
else {
|
|
14768
|
-
this.renderedSource = magicString.trim();
|
|
14769
|
-
}
|
|
14770
|
-
this.renderedHash = undefined;
|
|
14771
|
-
if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) {
|
|
14772
|
-
const chunkName = this.getChunkName();
|
|
14773
|
-
this.inputOptions.onwarn({
|
|
14774
|
-
chunkName,
|
|
14775
|
-
code: 'EMPTY_BUNDLE',
|
|
14776
|
-
message: `Generated an empty chunk: "${chunkName}"`
|
|
14777
|
-
});
|
|
14778
|
-
}
|
|
14779
|
-
this.setExternalRenderPaths(options, inputBase);
|
|
14780
|
-
this.renderedDependencies = this.getChunkDependencyDeclarations(options, getPropertyAccess);
|
|
14781
|
-
this.renderedExports =
|
|
14782
|
-
this.exportMode === 'none'
|
|
14783
|
-
? []
|
|
14784
|
-
: this.getChunkExportDeclarations(options.format, getPropertyAccess);
|
|
14785
|
-
}
|
|
14786
|
-
async render(options, addons, outputChunk, snippets) {
|
|
14787
|
-
timeStart('render format', 2);
|
|
14788
|
-
const format = options.format;
|
|
14789
|
-
const finalise = finalisers[format];
|
|
14790
|
-
if (options.dynamicImportFunction && format !== 'es') {
|
|
14791
|
-
this.inputOptions.onwarn(errInvalidOption('output.dynamicImportFunction', 'outputdynamicImportFunction', 'this option is ignored for formats other than "es"'));
|
|
14792
|
-
}
|
|
14793
|
-
// populate ids in the rendered declarations only here
|
|
14794
|
-
// as chunk ids known only after prerender
|
|
14795
|
-
for (const dependency of this.dependencies) {
|
|
14796
|
-
const renderedDependency = this.renderedDependencies.get(dependency);
|
|
14797
|
-
if (dependency instanceof ExternalModule) {
|
|
14798
|
-
const originalId = dependency.renderPath;
|
|
14799
|
-
renderedDependency.id = escapeId(dependency.renormalizeRenderPath
|
|
14800
|
-
? getImportPath(this.id, originalId, false, false)
|
|
14801
|
-
: originalId);
|
|
14802
|
-
}
|
|
14803
|
-
else {
|
|
14804
|
-
renderedDependency.namedExportsMode = dependency.exportMode !== 'default';
|
|
14805
|
-
renderedDependency.id = escapeId(getImportPath(this.id, dependency.id, false, true));
|
|
14806
|
-
}
|
|
14807
|
-
}
|
|
14808
|
-
this.finaliseDynamicImports(options, snippets);
|
|
14809
|
-
this.finaliseImportMetas(format, snippets);
|
|
14810
|
-
const hasExports = this.renderedExports.length !== 0 ||
|
|
14811
|
-
[...this.renderedDependencies.values()].some(dep => (dep.reexports && dep.reexports.length !== 0));
|
|
14812
|
-
let topLevelAwaitModule = null;
|
|
14813
|
-
const accessedGlobals = new Set();
|
|
14814
|
-
for (const module of this.orderedModules) {
|
|
14815
|
-
if (module.usesTopLevelAwait) {
|
|
14816
|
-
topLevelAwaitModule = module.id;
|
|
14817
|
-
}
|
|
14818
|
-
const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
|
|
14819
|
-
if (accessedGlobalVariables) {
|
|
14820
|
-
for (const name of accessedGlobalVariables) {
|
|
14821
|
-
accessedGlobals.add(name);
|
|
14822
|
-
}
|
|
14823
|
-
}
|
|
14824
|
-
}
|
|
14825
|
-
if (topLevelAwaitModule !== null && format !== 'es' && format !== 'system') {
|
|
14826
|
-
return error({
|
|
14827
|
-
code: 'INVALID_TLA_FORMAT',
|
|
14828
|
-
id: topLevelAwaitModule,
|
|
14829
|
-
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
14830
|
-
});
|
|
14831
|
-
}
|
|
14832
|
-
/* istanbul ignore next */
|
|
14833
|
-
if (!this.id) {
|
|
14834
|
-
throw new Error('Internal Error: expecting chunk id');
|
|
14835
|
-
}
|
|
14836
|
-
const magicString = finalise(this.renderedSource, {
|
|
14797
|
+
const preliminaryFileName = this.getPreliminaryFileName();
|
|
14798
|
+
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
14799
|
+
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
14800
|
+
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
14801
|
+
const hasExports = renderedExports.length !== 0 ||
|
|
14802
|
+
renderedDependencies.some(dep => (dep.reexports && dep.reexports.length !== 0));
|
|
14803
|
+
const { intro, outro, banner, footer } = await createAddons(outputOptions, pluginDriver, this.getRenderedChunkInfo());
|
|
14804
|
+
finalisers[format](renderedSource, {
|
|
14837
14805
|
accessedGlobals,
|
|
14838
|
-
dependencies:
|
|
14839
|
-
exports:
|
|
14806
|
+
dependencies: renderedDependencies,
|
|
14807
|
+
exports: renderedExports,
|
|
14840
14808
|
hasExports,
|
|
14841
|
-
id:
|
|
14842
|
-
indent
|
|
14843
|
-
intro
|
|
14844
|
-
isEntryFacade:
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
outro
|
|
14809
|
+
id: preliminaryFileName.fileName,
|
|
14810
|
+
indent,
|
|
14811
|
+
intro,
|
|
14812
|
+
isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry),
|
|
14813
|
+
isModuleFacade: facadeModule !== null,
|
|
14814
|
+
namedExportsMode: exportMode !== 'default',
|
|
14815
|
+
onwarn,
|
|
14816
|
+
outro,
|
|
14849
14817
|
snippets,
|
|
14850
|
-
usesTopLevelAwait
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
code: prevCode,
|
|
14863
|
-
options,
|
|
14864
|
-
outputPluginDriver: this.pluginDriver,
|
|
14865
|
-
renderChunk: outputChunk,
|
|
14866
|
-
sourcemapChain: chunkSourcemapChain
|
|
14867
|
-
});
|
|
14868
|
-
if (options.sourcemap) {
|
|
14869
|
-
timeStart('sourcemap', 2);
|
|
14870
|
-
let file;
|
|
14871
|
-
if (options.file)
|
|
14872
|
-
file = resolve(options.sourcemapFile || options.file);
|
|
14873
|
-
else if (options.dir)
|
|
14874
|
-
file = resolve(options.dir, this.id);
|
|
14875
|
-
else
|
|
14876
|
-
file = resolve(this.id);
|
|
14877
|
-
const decodedMap = magicString.generateDecodedMap({});
|
|
14878
|
-
map = collapseSourcemaps(file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources, this.inputOptions.onwarn);
|
|
14879
|
-
map.sources = map.sources
|
|
14880
|
-
.map(sourcePath => {
|
|
14881
|
-
const { sourcemapPathTransform } = options;
|
|
14882
|
-
if (sourcemapPathTransform) {
|
|
14883
|
-
const newSourcePath = sourcemapPathTransform(sourcePath, `${file}.map`);
|
|
14884
|
-
if (typeof newSourcePath !== 'string') {
|
|
14885
|
-
error(errFailedValidation(`sourcemapPathTransform function must return a string.`));
|
|
14886
|
-
}
|
|
14887
|
-
return newSourcePath;
|
|
14888
|
-
}
|
|
14889
|
-
return sourcePath;
|
|
14890
|
-
})
|
|
14891
|
-
.map(normalize);
|
|
14892
|
-
timeEnd('sourcemap', 2);
|
|
14893
|
-
}
|
|
14894
|
-
if (!options.compact && code[code.length - 1] !== '\n')
|
|
14895
|
-
code += '\n';
|
|
14896
|
-
return { code, map };
|
|
14818
|
+
usesTopLevelAwait
|
|
14819
|
+
}, outputOptions);
|
|
14820
|
+
if (banner)
|
|
14821
|
+
magicString.prepend(banner);
|
|
14822
|
+
if (footer)
|
|
14823
|
+
magicString.append(footer);
|
|
14824
|
+
return {
|
|
14825
|
+
chunk: this,
|
|
14826
|
+
magicString,
|
|
14827
|
+
preliminaryFileName,
|
|
14828
|
+
usedModules
|
|
14829
|
+
};
|
|
14897
14830
|
}
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
}
|
|
14905
|
-
}
|
|
14906
|
-
else {
|
|
14907
|
-
chunkDependencies.add(module);
|
|
14831
|
+
addImplicitlyLoadedBeforeFromModule(baseModule) {
|
|
14832
|
+
const { implicitlyLoadedBefore } = this;
|
|
14833
|
+
for (const module of baseModule.implicitlyLoadedBefore) {
|
|
14834
|
+
const chunk = this.chunkByModule.get(module);
|
|
14835
|
+
if (chunk && chunk !== this) {
|
|
14836
|
+
implicitlyLoadedBefore.add(chunk);
|
|
14908
14837
|
}
|
|
14909
14838
|
}
|
|
14910
14839
|
}
|
|
@@ -14917,12 +14846,15 @@ class Chunk {
|
|
|
14917
14846
|
}
|
|
14918
14847
|
}
|
|
14919
14848
|
}
|
|
14920
|
-
assignFacadeName({ fileName, name }, facadedModule) {
|
|
14849
|
+
assignFacadeName({ fileName, name }, facadedModule, preservePath) {
|
|
14921
14850
|
if (fileName) {
|
|
14922
14851
|
this.fileName = fileName;
|
|
14923
14852
|
}
|
|
14924
14853
|
else {
|
|
14925
|
-
this.name = this.outputOptions.sanitizeFileName(name ||
|
|
14854
|
+
this.name = this.outputOptions.sanitizeFileName(name ||
|
|
14855
|
+
(preservePath
|
|
14856
|
+
? this.getPreserveModulesChunkNameFromModule(facadedModule)
|
|
14857
|
+
: getChunkNameFromModule(facadedModule)));
|
|
14926
14858
|
}
|
|
14927
14859
|
}
|
|
14928
14860
|
checkCircularDependencyImport(variable, importingModule) {
|
|
@@ -14942,27 +14874,6 @@ class Chunk {
|
|
|
14942
14874
|
} while (alternativeReexportModule);
|
|
14943
14875
|
}
|
|
14944
14876
|
}
|
|
14945
|
-
computeContentHashWithDependencies(addons, options, existingNames) {
|
|
14946
|
-
const hash = createHash();
|
|
14947
|
-
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].join(':'));
|
|
14948
|
-
hash.update(options.format);
|
|
14949
|
-
const dependenciesForHashing = new Set([this]);
|
|
14950
|
-
for (const current of dependenciesForHashing) {
|
|
14951
|
-
if (current instanceof ExternalModule) {
|
|
14952
|
-
hash.update(`:${current.renderPath}`);
|
|
14953
|
-
}
|
|
14954
|
-
else {
|
|
14955
|
-
hash.update(current.getRenderedHash());
|
|
14956
|
-
hash.update(current.generateId(addons, options, existingNames, false));
|
|
14957
|
-
}
|
|
14958
|
-
if (current instanceof ExternalModule)
|
|
14959
|
-
continue;
|
|
14960
|
-
for (const dependency of [...current.dependencies, ...current.dynamicDependencies]) {
|
|
14961
|
-
dependenciesForHashing.add(dependency);
|
|
14962
|
-
}
|
|
14963
|
-
}
|
|
14964
|
-
return hash.digest('hex').substr(0, 8);
|
|
14965
|
-
}
|
|
14966
14877
|
ensureReexportsAreAvailableForModule(module) {
|
|
14967
14878
|
const includedReexports = [];
|
|
14968
14879
|
const map = module.getExportNamesByVariable();
|
|
@@ -14990,35 +14901,6 @@ class Chunk {
|
|
|
14990
14901
|
this.includedReexportsByModule.set(module, includedReexports);
|
|
14991
14902
|
}
|
|
14992
14903
|
}
|
|
14993
|
-
finaliseDynamicImports(options, snippets) {
|
|
14994
|
-
const stripKnownJsExtensions = options.format === 'amd';
|
|
14995
|
-
for (const [module, code] of this.renderedModuleSources) {
|
|
14996
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
14997
|
-
const chunk = this.chunkByModule.get(resolution);
|
|
14998
|
-
const facadeChunk = this.facadeChunkByModule.get(resolution);
|
|
14999
|
-
if (!resolution || !node.included || chunk === this) {
|
|
15000
|
-
continue;
|
|
15001
|
-
}
|
|
15002
|
-
const renderedResolution = resolution instanceof Module
|
|
15003
|
-
? `'${escapeId(getImportPath(this.id, (facadeChunk || chunk).id, stripKnownJsExtensions, true))}'`
|
|
15004
|
-
: resolution instanceof ExternalModule
|
|
15005
|
-
? `'${escapeId(resolution.renormalizeRenderPath
|
|
15006
|
-
? getImportPath(this.id, resolution.renderPath, stripKnownJsExtensions, false)
|
|
15007
|
-
: resolution.renderPath)}'`
|
|
15008
|
-
: resolution;
|
|
15009
|
-
node.renderFinalResolution(code, renderedResolution, resolution instanceof Module &&
|
|
15010
|
-
!(facadeChunk === null || facadeChunk === void 0 ? void 0 : facadeChunk.strictFacade) &&
|
|
15011
|
-
chunk.exportNamesByVariable.get(resolution.namespace)[0], snippets);
|
|
15012
|
-
}
|
|
15013
|
-
}
|
|
15014
|
-
}
|
|
15015
|
-
finaliseImportMetas(format, snippets) {
|
|
15016
|
-
for (const [module, code] of this.renderedModuleSources) {
|
|
15017
|
-
for (const importMeta of module.importMetas) {
|
|
15018
|
-
importMeta.renderFinalMechanism(code, this.id, format, snippets, this.pluginDriver);
|
|
15019
|
-
}
|
|
15020
|
-
}
|
|
15021
|
-
}
|
|
15022
14904
|
generateVariableName() {
|
|
15023
14905
|
if (this.manualChunkAlias) {
|
|
15024
14906
|
return this.manualChunkAlias;
|
|
@@ -15032,31 +14914,7 @@ class Chunk {
|
|
|
15032
14914
|
}
|
|
15033
14915
|
return 'chunk';
|
|
15034
14916
|
}
|
|
15035
|
-
|
|
15036
|
-
const importSpecifiers = this.getImportSpecifiers(getPropertyAccess);
|
|
15037
|
-
const reexportSpecifiers = this.getReexportSpecifiers();
|
|
15038
|
-
const dependencyDeclaration = new Map();
|
|
15039
|
-
for (const dep of this.dependencies) {
|
|
15040
|
-
const imports = importSpecifiers.get(dep) || null;
|
|
15041
|
-
const reexports = reexportSpecifiers.get(dep) || null;
|
|
15042
|
-
const namedExportsMode = dep instanceof ExternalModule || dep.exportMode !== 'default';
|
|
15043
|
-
dependencyDeclaration.set(dep, {
|
|
15044
|
-
defaultVariableName: dep.defaultVariableName,
|
|
15045
|
-
globalName: (dep instanceof ExternalModule &&
|
|
15046
|
-
(options.format === 'umd' || options.format === 'iife') &&
|
|
15047
|
-
getGlobalName(dep, options.globals, (imports || reexports) !== null, this.inputOptions.onwarn)),
|
|
15048
|
-
id: undefined,
|
|
15049
|
-
imports,
|
|
15050
|
-
isChunk: dep instanceof Chunk,
|
|
15051
|
-
name: dep.variableName,
|
|
15052
|
-
namedExportsMode,
|
|
15053
|
-
namespaceVariableName: dep.namespaceVariableName,
|
|
15054
|
-
reexports
|
|
15055
|
-
});
|
|
15056
|
-
}
|
|
15057
|
-
return dependencyDeclaration;
|
|
15058
|
-
}
|
|
15059
|
-
getChunkExportDeclarations(format, getPropertyAccess) {
|
|
14917
|
+
getChunkExportDeclarations(format) {
|
|
15060
14918
|
const exports = [];
|
|
15061
14919
|
for (const exportName of this.getExportNames()) {
|
|
15062
14920
|
if (exportName[0] === '*')
|
|
@@ -15069,7 +14927,7 @@ class Chunk {
|
|
|
15069
14927
|
}
|
|
15070
14928
|
let expression = null;
|
|
15071
14929
|
let hoisted = false;
|
|
15072
|
-
let local = variable.getName(getPropertyAccess);
|
|
14930
|
+
let local = variable.getName(this.snippets.getPropertyAccess);
|
|
15073
14931
|
if (variable instanceof LocalVariable) {
|
|
15074
14932
|
for (const declaration of variable.declarations) {
|
|
15075
14933
|
if (declaration.parent instanceof FunctionDeclaration ||
|
|
@@ -15103,16 +14961,17 @@ class Chunk {
|
|
|
15103
14961
|
if (addNonNamespacesAndInteropHelpers || variable.isNamespace) {
|
|
15104
14962
|
const module = variable.module;
|
|
15105
14963
|
if (module instanceof ExternalModule) {
|
|
15106
|
-
|
|
14964
|
+
const chunk = this.externalChunkByModule.get(module);
|
|
14965
|
+
dependencies.add(chunk);
|
|
15107
14966
|
if (addNonNamespacesAndInteropHelpers) {
|
|
15108
14967
|
if (variable.name === 'default') {
|
|
15109
14968
|
if (defaultInteropHelpersByInteropType[String(interop(module.id))]) {
|
|
15110
|
-
deconflictedDefault.add(
|
|
14969
|
+
deconflictedDefault.add(chunk);
|
|
15111
14970
|
}
|
|
15112
14971
|
}
|
|
15113
14972
|
else if (variable.name === '*') {
|
|
15114
14973
|
if (namespaceInteropHelpersByInteropType[String(interop(module.id))]) {
|
|
15115
|
-
deconflictedNamespace.add(
|
|
14974
|
+
deconflictedNamespace.add(chunk);
|
|
15116
14975
|
}
|
|
15117
14976
|
}
|
|
15118
14977
|
}
|
|
@@ -15137,6 +14996,15 @@ class Chunk {
|
|
|
15137
14996
|
}
|
|
15138
14997
|
return { deconflictedDefault, deconflictedNamespace, dependencies };
|
|
15139
14998
|
}
|
|
14999
|
+
getDynamicDependencies() {
|
|
15000
|
+
return this.getIncludedDynamicImports()
|
|
15001
|
+
.map(resolvedDynamicImport => resolvedDynamicImport.facadeChunk ||
|
|
15002
|
+
resolvedDynamicImport.chunk ||
|
|
15003
|
+
resolvedDynamicImport.externalChunk ||
|
|
15004
|
+
resolvedDynamicImport.resolution)
|
|
15005
|
+
.filter((resolution) => resolution !== this &&
|
|
15006
|
+
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
15007
|
+
}
|
|
15140
15008
|
getFallbackChunkName() {
|
|
15141
15009
|
if (this.manualChunkAlias) {
|
|
15142
15010
|
return this.manualChunkAlias;
|
|
@@ -15149,7 +15017,7 @@ class Chunk {
|
|
|
15149
15017
|
}
|
|
15150
15018
|
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
|
|
15151
15019
|
}
|
|
15152
|
-
getImportSpecifiers(
|
|
15020
|
+
getImportSpecifiers() {
|
|
15153
15021
|
const { interop } = this.outputOptions;
|
|
15154
15022
|
const importsByDependency = new Map();
|
|
15155
15023
|
for (const variable of this.imports) {
|
|
@@ -15157,7 +15025,7 @@ class Chunk {
|
|
|
15157
15025
|
let dependency;
|
|
15158
15026
|
let imported;
|
|
15159
15027
|
if (module instanceof ExternalModule) {
|
|
15160
|
-
dependency = module;
|
|
15028
|
+
dependency = this.externalChunkByModule.get(module);
|
|
15161
15029
|
imported = variable.name;
|
|
15162
15030
|
if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
|
|
15163
15031
|
return error(errUnexpectedNamedImport(module.id, imported, false));
|
|
@@ -15169,30 +15037,78 @@ class Chunk {
|
|
|
15169
15037
|
}
|
|
15170
15038
|
getOrCreate(importsByDependency, dependency, () => []).push({
|
|
15171
15039
|
imported,
|
|
15172
|
-
local: variable.getName(getPropertyAccess)
|
|
15040
|
+
local: variable.getName(this.snippets.getPropertyAccess)
|
|
15173
15041
|
});
|
|
15174
15042
|
}
|
|
15175
15043
|
return importsByDependency;
|
|
15176
15044
|
}
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
if (declaration.reexports) {
|
|
15187
|
-
for (const { imported } of declaration.reexports) {
|
|
15188
|
-
specifiers.add(imported);
|
|
15045
|
+
getIncludedDynamicImports() {
|
|
15046
|
+
if (this.includedDynamicImports) {
|
|
15047
|
+
return this.includedDynamicImports;
|
|
15048
|
+
}
|
|
15049
|
+
const includedDynamicImports = [];
|
|
15050
|
+
for (const module of this.orderedModules) {
|
|
15051
|
+
for (const { node, resolution } of module.dynamicImports) {
|
|
15052
|
+
if (!node.included) {
|
|
15053
|
+
continue;
|
|
15189
15054
|
}
|
|
15055
|
+
includedDynamicImports.push(resolution instanceof Module
|
|
15056
|
+
? {
|
|
15057
|
+
chunk: this.chunkByModule.get(resolution),
|
|
15058
|
+
externalChunk: null,
|
|
15059
|
+
facadeChunk: this.facadeChunkByModule.get(resolution),
|
|
15060
|
+
node,
|
|
15061
|
+
resolution
|
|
15062
|
+
}
|
|
15063
|
+
: resolution instanceof ExternalModule
|
|
15064
|
+
? {
|
|
15065
|
+
chunk: null,
|
|
15066
|
+
externalChunk: this.externalChunkByModule.get(resolution),
|
|
15067
|
+
facadeChunk: null,
|
|
15068
|
+
node,
|
|
15069
|
+
resolution
|
|
15070
|
+
}
|
|
15071
|
+
: { chunk: null, externalChunk: null, facadeChunk: null, node, resolution });
|
|
15190
15072
|
}
|
|
15191
|
-
importSpecifiers[dependency.id] = [...specifiers];
|
|
15192
15073
|
}
|
|
15193
|
-
return
|
|
15074
|
+
return (this.includedDynamicImports = includedDynamicImports);
|
|
15194
15075
|
}
|
|
15195
|
-
|
|
15076
|
+
getPreRenderedChunkInfo() {
|
|
15077
|
+
if (this.preRenderedChunkInfo) {
|
|
15078
|
+
return this.preRenderedChunkInfo;
|
|
15079
|
+
}
|
|
15080
|
+
const { facadeModule } = this;
|
|
15081
|
+
return (this.preRenderedChunkInfo = {
|
|
15082
|
+
exports: this.getExportNames(),
|
|
15083
|
+
facadeModuleId: facadeModule && facadeModule.id,
|
|
15084
|
+
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
15085
|
+
isEntry: !!(facadeModule === null || facadeModule === void 0 ? void 0 : facadeModule.info.isEntry),
|
|
15086
|
+
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
15087
|
+
moduleIds: this.orderedModules.map(({ id }) => id),
|
|
15088
|
+
name: this.getChunkName(),
|
|
15089
|
+
type: 'chunk'
|
|
15090
|
+
});
|
|
15091
|
+
}
|
|
15092
|
+
getPreserveModulesChunkNameFromModule(module) {
|
|
15093
|
+
const predefinedChunkName = getPredefinedChunkNameFromModule(module);
|
|
15094
|
+
if (predefinedChunkName)
|
|
15095
|
+
return predefinedChunkName;
|
|
15096
|
+
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
15097
|
+
const sanitizedId = sanitizeFileName(module.id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
15098
|
+
const extName = extname(sanitizedId);
|
|
15099
|
+
const idWithoutExtension = NON_ASSET_EXTENSIONS.includes(extName)
|
|
15100
|
+
? sanitizedId.slice(0, -extName.length)
|
|
15101
|
+
: sanitizedId;
|
|
15102
|
+
if (isAbsolute(idWithoutExtension)) {
|
|
15103
|
+
return preserveModulesRoot && idWithoutExtension.startsWith(preserveModulesRoot)
|
|
15104
|
+
? idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[\\/]/, '')
|
|
15105
|
+
: relative(this.inputBase, idWithoutExtension);
|
|
15106
|
+
}
|
|
15107
|
+
else {
|
|
15108
|
+
return `_virtual/${basename(idWithoutExtension)}`;
|
|
15109
|
+
}
|
|
15110
|
+
}
|
|
15111
|
+
getReexportSpecifiers() {
|
|
15196
15112
|
const { externalLiveBindings, interop } = this.outputOptions;
|
|
15197
15113
|
const reexportSpecifiers = new Map();
|
|
15198
15114
|
for (let exportName of this.getExportNames()) {
|
|
@@ -15205,7 +15121,7 @@ class Chunk {
|
|
|
15205
15121
|
this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id));
|
|
15206
15122
|
}
|
|
15207
15123
|
needsLiveBinding = externalLiveBindings;
|
|
15208
|
-
dependency = this.modulesById.get(id);
|
|
15124
|
+
dependency = this.externalChunkByModule.get(this.modulesById.get(id));
|
|
15209
15125
|
imported = exportName = '*';
|
|
15210
15126
|
}
|
|
15211
15127
|
else {
|
|
@@ -15221,7 +15137,7 @@ class Chunk {
|
|
|
15221
15137
|
needsLiveBinding = variable.isReassigned;
|
|
15222
15138
|
}
|
|
15223
15139
|
else {
|
|
15224
|
-
dependency = module;
|
|
15140
|
+
dependency = this.externalChunkByModule.get(module);
|
|
15225
15141
|
imported = variable.name;
|
|
15226
15142
|
if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
|
|
15227
15143
|
return error(errUnexpectedNamedImport(module.id, imported, true));
|
|
@@ -15240,16 +15156,45 @@ class Chunk {
|
|
|
15240
15156
|
return reexportSpecifiers;
|
|
15241
15157
|
}
|
|
15242
15158
|
getReferencedFiles() {
|
|
15243
|
-
const referencedFiles =
|
|
15159
|
+
const referencedFiles = new Set();
|
|
15244
15160
|
for (const module of this.orderedModules) {
|
|
15245
15161
|
for (const meta of module.importMetas) {
|
|
15246
15162
|
const fileName = meta.getReferencedFileName(this.pluginDriver);
|
|
15247
15163
|
if (fileName) {
|
|
15248
|
-
referencedFiles.
|
|
15164
|
+
referencedFiles.add(fileName);
|
|
15249
15165
|
}
|
|
15250
15166
|
}
|
|
15251
15167
|
}
|
|
15252
|
-
return referencedFiles;
|
|
15168
|
+
return [...referencedFiles];
|
|
15169
|
+
}
|
|
15170
|
+
getRenderedDependencies() {
|
|
15171
|
+
if (this.renderedDependencies) {
|
|
15172
|
+
return this.renderedDependencies;
|
|
15173
|
+
}
|
|
15174
|
+
const importSpecifiers = this.getImportSpecifiers();
|
|
15175
|
+
const reexportSpecifiers = this.getReexportSpecifiers();
|
|
15176
|
+
const renderedDependencies = new Map();
|
|
15177
|
+
const fileName = this.getFileName();
|
|
15178
|
+
for (const dep of this.dependencies) {
|
|
15179
|
+
const imports = importSpecifiers.get(dep) || null;
|
|
15180
|
+
const reexports = reexportSpecifiers.get(dep) || null;
|
|
15181
|
+
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
15182
|
+
const importPath = dep.getImportPath(fileName);
|
|
15183
|
+
renderedDependencies.set(dep, {
|
|
15184
|
+
defaultVariableName: dep.defaultVariableName,
|
|
15185
|
+
globalName: dep instanceof ExternalChunk &&
|
|
15186
|
+
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
15187
|
+
getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onwarn),
|
|
15188
|
+
importPath,
|
|
15189
|
+
imports,
|
|
15190
|
+
isChunk: dep instanceof Chunk,
|
|
15191
|
+
name: dep.variableName,
|
|
15192
|
+
namedExportsMode,
|
|
15193
|
+
namespaceVariableName: dep.namespaceVariableName,
|
|
15194
|
+
reexports
|
|
15195
|
+
});
|
|
15196
|
+
}
|
|
15197
|
+
return (this.renderedDependencies = renderedDependencies);
|
|
15253
15198
|
}
|
|
15254
15199
|
inlineChunkDependencies(chunk) {
|
|
15255
15200
|
for (const dep of chunk.dependencies) {
|
|
@@ -15261,42 +15206,111 @@ class Chunk {
|
|
|
15261
15206
|
}
|
|
15262
15207
|
}
|
|
15263
15208
|
}
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
const
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15209
|
+
// This method changes properties on the AST before rendering and must not be async
|
|
15210
|
+
renderModules(fileName) {
|
|
15211
|
+
const { dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onwarn }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
|
|
15212
|
+
const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag, preserveModules } = outputOptions;
|
|
15213
|
+
const { _, n } = snippets;
|
|
15214
|
+
this.setDynamicImportResolutions(fileName);
|
|
15215
|
+
this.setImportMetaResolutions(fileName);
|
|
15216
|
+
this.setIdentifierRenderResolutions();
|
|
15217
|
+
const magicString = new Bundle$1({ separator: `${n}${n}` });
|
|
15218
|
+
const indent = getIndentString(orderedModules, outputOptions);
|
|
15219
|
+
const usedModules = [];
|
|
15220
|
+
let hoistedSource = '';
|
|
15221
|
+
const accessedGlobals = new Set();
|
|
15222
|
+
const renderedModuleSources = new Map();
|
|
15223
|
+
const renderOptions = {
|
|
15224
|
+
dynamicImportFunction,
|
|
15225
|
+
exportNamesByVariable,
|
|
15226
|
+
format,
|
|
15227
|
+
freeze,
|
|
15228
|
+
indent,
|
|
15229
|
+
namespaceToStringTag,
|
|
15230
|
+
pluginDriver,
|
|
15231
|
+
snippets
|
|
15232
|
+
};
|
|
15233
|
+
let usesTopLevelAwait = false;
|
|
15234
|
+
for (const module of orderedModules) {
|
|
15235
|
+
let renderedLength = 0;
|
|
15236
|
+
let source;
|
|
15237
|
+
if (module.isIncluded() || includedNamespaces.has(module)) {
|
|
15238
|
+
const rendered = module.render(renderOptions);
|
|
15239
|
+
({ source } = rendered);
|
|
15240
|
+
usesTopLevelAwait || (usesTopLevelAwait = rendered.usesTopLevelAwait);
|
|
15241
|
+
renderedLength = source.length();
|
|
15242
|
+
if (renderedLength) {
|
|
15243
|
+
if (compact && source.lastLine().includes('//'))
|
|
15244
|
+
source.append('\n');
|
|
15245
|
+
renderedModuleSources.set(module, source);
|
|
15246
|
+
magicString.addSource(source);
|
|
15247
|
+
usedModules.push(module);
|
|
15248
|
+
}
|
|
15249
|
+
const namespace = module.namespace;
|
|
15250
|
+
if (includedNamespaces.has(module) && !preserveModules) {
|
|
15251
|
+
const rendered = namespace.renderBlock(renderOptions);
|
|
15252
|
+
if (namespace.renderFirst())
|
|
15253
|
+
hoistedSource += n + rendered;
|
|
15254
|
+
else
|
|
15255
|
+
magicString.addSource(new MagicString(rendered));
|
|
15256
|
+
}
|
|
15257
|
+
const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
|
|
15258
|
+
if (accessedGlobalVariables) {
|
|
15259
|
+
for (const name of accessedGlobalVariables) {
|
|
15260
|
+
accessedGlobals.add(name);
|
|
15281
15261
|
}
|
|
15282
15262
|
}
|
|
15283
15263
|
}
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15264
|
+
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
15265
|
+
renderedModules[module.id] = {
|
|
15266
|
+
get code() {
|
|
15267
|
+
var _a;
|
|
15268
|
+
return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
|
|
15269
|
+
},
|
|
15270
|
+
originalLength: module.originalCode.length,
|
|
15271
|
+
removedExports,
|
|
15272
|
+
renderedExports,
|
|
15273
|
+
renderedLength
|
|
15274
|
+
};
|
|
15275
|
+
}
|
|
15276
|
+
if (hoistedSource)
|
|
15277
|
+
magicString.prepend(hoistedSource + n + n);
|
|
15278
|
+
if (this.needsExportsShim) {
|
|
15279
|
+
magicString.prepend(`${n}${snippets.cnst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}`);
|
|
15280
|
+
}
|
|
15281
|
+
const renderedSource = compact ? magicString : magicString.trim();
|
|
15282
|
+
if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
|
|
15283
|
+
const chunkName = this.getChunkName();
|
|
15284
|
+
onwarn({
|
|
15285
|
+
chunkName,
|
|
15286
|
+
code: 'EMPTY_BUNDLE',
|
|
15287
|
+
message: `Generated an empty chunk: "${chunkName}"`
|
|
15288
|
+
});
|
|
15290
15289
|
}
|
|
15290
|
+
return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
|
|
15291
15291
|
}
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15292
|
+
setDynamicImportResolutions(fileName) {
|
|
15293
|
+
const { accessedGlobalsByScope, outputOptions, pluginDriver, snippets } = this;
|
|
15294
|
+
for (const resolvedDynamicImport of this.getIncludedDynamicImports()) {
|
|
15295
|
+
if (resolvedDynamicImport.chunk) {
|
|
15296
|
+
const { chunk, facadeChunk, node, resolution } = resolvedDynamicImport;
|
|
15297
|
+
if (chunk === this) {
|
|
15298
|
+
node.setInternalResolution(resolution.namespace);
|
|
15299
|
+
}
|
|
15300
|
+
else {
|
|
15301
|
+
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]);
|
|
15302
|
+
}
|
|
15303
|
+
}
|
|
15304
|
+
else {
|
|
15305
|
+
const { resolution } = resolvedDynamicImport;
|
|
15306
|
+
resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolution instanceof ExternalModule
|
|
15307
|
+
? `'${this.externalChunkByModule.get(resolution).getImportPath(fileName)}'`
|
|
15308
|
+
: resolution || '', false);
|
|
15296
15309
|
}
|
|
15297
15310
|
}
|
|
15298
15311
|
}
|
|
15299
|
-
setIdentifierRenderResolutions(
|
|
15312
|
+
setIdentifierRenderResolutions() {
|
|
15313
|
+
const { format, interop, namespaceToStringTag } = this.outputOptions;
|
|
15300
15314
|
const syntheticExports = new Set();
|
|
15301
15315
|
for (const exportName of this.getExportNames()) {
|
|
15302
15316
|
const exportVariable = this.exportsByName.get(exportName);
|
|
@@ -15341,7 +15355,18 @@ class Chunk {
|
|
|
15341
15355
|
usedNames.add(helper);
|
|
15342
15356
|
}
|
|
15343
15357
|
}
|
|
15344
|
-
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);
|
|
15358
|
+
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);
|
|
15359
|
+
}
|
|
15360
|
+
setImportMetaResolutions(fileName) {
|
|
15361
|
+
const { accessedGlobalsByScope, includedNamespaces, outputOptions: { format, preserveModules } } = this;
|
|
15362
|
+
for (const module of this.orderedModules) {
|
|
15363
|
+
for (const importMeta of module.importMetas) {
|
|
15364
|
+
importMeta.setResolution(format, accessedGlobalsByScope, fileName);
|
|
15365
|
+
}
|
|
15366
|
+
if (includedNamespaces.has(module) && !preserveModules) {
|
|
15367
|
+
module.namespace.prepare(accessedGlobalsByScope);
|
|
15368
|
+
}
|
|
15369
|
+
}
|
|
15345
15370
|
}
|
|
15346
15371
|
setUpChunkImportsAndExportsForModule(module) {
|
|
15347
15372
|
const moduleImports = new Set(module.includedImports);
|
|
@@ -15389,549 +15414,657 @@ class Chunk {
|
|
|
15389
15414
|
}
|
|
15390
15415
|
}
|
|
15391
15416
|
function getChunkNameFromModule(module) {
|
|
15392
|
-
var _a
|
|
15393
|
-
return (
|
|
15417
|
+
var _a;
|
|
15418
|
+
return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
|
|
15394
15419
|
}
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
15399
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
15400
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
15401
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
15402
|
-
ext: () => extname(emittedName).substring(1),
|
|
15403
|
-
extname: () => extname(emittedName),
|
|
15404
|
-
hash() {
|
|
15405
|
-
return createHash()
|
|
15406
|
-
.update(emittedName)
|
|
15407
|
-
.update(':')
|
|
15408
|
-
.update(source)
|
|
15409
|
-
.digest('hex')
|
|
15410
|
-
.substring(0, 8);
|
|
15411
|
-
},
|
|
15412
|
-
name: () => emittedName.substring(0, emittedName.length - extname(emittedName).length)
|
|
15413
|
-
}), bundle);
|
|
15420
|
+
function getPredefinedChunkNameFromModule(module) {
|
|
15421
|
+
var _a, _b, _c;
|
|
15422
|
+
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);
|
|
15414
15423
|
}
|
|
15415
|
-
function
|
|
15416
|
-
|
|
15417
|
-
|
|
15424
|
+
function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
|
|
15425
|
+
const importedBindingsPerDependency = {};
|
|
15426
|
+
for (const [dependency, declaration] of renderedDependencies) {
|
|
15427
|
+
const specifiers = new Set();
|
|
15428
|
+
if (declaration.imports) {
|
|
15429
|
+
for (const { imported } of declaration.imports) {
|
|
15430
|
+
specifiers.add(imported);
|
|
15431
|
+
}
|
|
15432
|
+
}
|
|
15433
|
+
if (declaration.reexports) {
|
|
15434
|
+
for (const { imported } of declaration.reexports) {
|
|
15435
|
+
specifiers.add(imported);
|
|
15436
|
+
}
|
|
15437
|
+
}
|
|
15438
|
+
importedBindingsPerDependency[resolveFileName(dependency)] = [...specifiers];
|
|
15418
15439
|
}
|
|
15419
|
-
|
|
15420
|
-
}
|
|
15421
|
-
const FILE_PLACEHOLDER = {
|
|
15422
|
-
type: 'placeholder'
|
|
15423
|
-
};
|
|
15424
|
-
function hasValidType(emittedFile) {
|
|
15425
|
-
return Boolean(emittedFile &&
|
|
15426
|
-
(emittedFile.type === 'asset' ||
|
|
15427
|
-
emittedFile.type === 'chunk'));
|
|
15428
|
-
}
|
|
15429
|
-
function hasValidName(emittedFile) {
|
|
15430
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
15431
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
15440
|
+
return importedBindingsPerDependency;
|
|
15432
15441
|
}
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15442
|
+
const QUERY_HASH_REGEX = /[?#]/;
|
|
15443
|
+
|
|
15444
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
15445
|
+
const chunkDefinitions = [];
|
|
15446
|
+
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
15447
|
+
const manualChunkModulesByAlias = Object.create(null);
|
|
15448
|
+
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
15449
|
+
const chunkModules = (manualChunkModulesByAlias[alias] =
|
|
15450
|
+
manualChunkModulesByAlias[alias] || []);
|
|
15451
|
+
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15437
15452
|
}
|
|
15438
|
-
|
|
15439
|
-
}
|
|
15440
|
-
function getAssetFileName(file, referenceId) {
|
|
15441
|
-
if (typeof file.fileName !== 'string') {
|
|
15442
|
-
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
15453
|
+
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15454
|
+
chunkDefinitions.push({ alias, modules });
|
|
15443
15455
|
}
|
|
15444
|
-
|
|
15445
|
-
}
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
this.graph = graph;
|
|
15456
|
-
this.options = options;
|
|
15457
|
-
this.bundle = null;
|
|
15458
|
-
this.facadeChunkByModule = null;
|
|
15459
|
-
this.outputOptions = null;
|
|
15460
|
-
this.assertAssetsFinalized = () => {
|
|
15461
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
15462
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
15463
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
15464
|
-
}
|
|
15465
|
-
};
|
|
15466
|
-
this.emitFile = (emittedFile) => {
|
|
15467
|
-
if (!hasValidType(emittedFile)) {
|
|
15468
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
15469
|
-
}
|
|
15470
|
-
if (!hasValidName(emittedFile)) {
|
|
15471
|
-
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}".`));
|
|
15472
|
-
}
|
|
15473
|
-
if (emittedFile.type === 'chunk') {
|
|
15474
|
-
return this.emitChunk(emittedFile);
|
|
15475
|
-
}
|
|
15476
|
-
return this.emitAsset(emittedFile);
|
|
15477
|
-
};
|
|
15478
|
-
this.getFileName = (fileReferenceId) => {
|
|
15479
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
15480
|
-
if (!emittedFile)
|
|
15481
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
15482
|
-
if (emittedFile.type === 'chunk') {
|
|
15483
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
15484
|
-
}
|
|
15485
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
15486
|
-
};
|
|
15487
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
15488
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
15489
|
-
if (!consumedFile)
|
|
15490
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
15491
|
-
if (consumedFile.type !== 'asset') {
|
|
15492
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
15493
|
-
}
|
|
15494
|
-
if (consumedFile.source !== undefined) {
|
|
15495
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
15496
|
-
}
|
|
15497
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
15498
|
-
if (this.bundle) {
|
|
15499
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
15456
|
+
const assignedEntryPointsByModule = new Map();
|
|
15457
|
+
const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
|
|
15458
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
|
|
15459
|
+
const staticEntries = new Set(entryModules);
|
|
15460
|
+
function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
|
|
15461
|
+
const modulesToHandle = new Set([entry]);
|
|
15462
|
+
for (const module of modulesToHandle) {
|
|
15463
|
+
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
15464
|
+
if (dynamicDependentEntryPoints &&
|
|
15465
|
+
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
15466
|
+
continue;
|
|
15500
15467
|
}
|
|
15501
15468
|
else {
|
|
15502
|
-
|
|
15469
|
+
assignedEntryPoints.add(entry);
|
|
15503
15470
|
}
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
this.bundle = outputBundle;
|
|
15508
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
15509
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
15510
|
-
if (emittedFile.fileName) {
|
|
15511
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
15471
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15472
|
+
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15473
|
+
modulesToHandle.add(dependency);
|
|
15512
15474
|
}
|
|
15513
15475
|
}
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15476
|
+
}
|
|
15477
|
+
}
|
|
15478
|
+
function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
|
|
15479
|
+
const entriesToCheck = new Set(entryPoints);
|
|
15480
|
+
for (const entry of entriesToCheck) {
|
|
15481
|
+
if (!containedIn.has(entry)) {
|
|
15482
|
+
if (staticEntries.has(entry))
|
|
15483
|
+
return false;
|
|
15484
|
+
const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
|
|
15485
|
+
for (const dependentEntry of dynamicallyDependentEntryPoints) {
|
|
15486
|
+
entriesToCheck.add(dependentEntry);
|
|
15517
15487
|
}
|
|
15518
15488
|
}
|
|
15519
|
-
}
|
|
15520
|
-
|
|
15521
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
15522
|
-
: new Map();
|
|
15523
|
-
}
|
|
15524
|
-
assignReferenceId(file, idBase) {
|
|
15525
|
-
let referenceId;
|
|
15526
|
-
do {
|
|
15527
|
-
referenceId = createHash()
|
|
15528
|
-
.update(referenceId || idBase)
|
|
15529
|
-
.digest('hex')
|
|
15530
|
-
.substring(0, 8);
|
|
15531
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
15532
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
15533
|
-
return referenceId;
|
|
15489
|
+
}
|
|
15490
|
+
return true;
|
|
15534
15491
|
}
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
: undefined;
|
|
15539
|
-
const consumedAsset = {
|
|
15540
|
-
fileName: emittedAsset.fileName,
|
|
15541
|
-
name: emittedAsset.name,
|
|
15542
|
-
source,
|
|
15543
|
-
type: 'asset'
|
|
15544
|
-
};
|
|
15545
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
15546
|
-
if (this.bundle) {
|
|
15547
|
-
if (emittedAsset.fileName) {
|
|
15548
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
15549
|
-
}
|
|
15550
|
-
if (source !== undefined) {
|
|
15551
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
15552
|
-
}
|
|
15492
|
+
for (const entry of entryModules) {
|
|
15493
|
+
if (!modulesInManualChunks.has(entry)) {
|
|
15494
|
+
assignEntryToStaticDependencies(entry, null);
|
|
15553
15495
|
}
|
|
15554
|
-
return referenceId;
|
|
15555
15496
|
}
|
|
15556
|
-
|
|
15557
|
-
if (
|
|
15558
|
-
|
|
15559
|
-
}
|
|
15560
|
-
if (typeof emittedChunk.id !== 'string') {
|
|
15561
|
-
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
15497
|
+
for (const entry of dynamicEntryModules) {
|
|
15498
|
+
if (!modulesInManualChunks.has(entry)) {
|
|
15499
|
+
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15562
15500
|
}
|
|
15563
|
-
const consumedChunk = {
|
|
15564
|
-
fileName: emittedChunk.fileName,
|
|
15565
|
-
module: null,
|
|
15566
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
15567
|
-
type: 'chunk'
|
|
15568
|
-
};
|
|
15569
|
-
this.graph.moduleLoader
|
|
15570
|
-
.emitChunk(emittedChunk)
|
|
15571
|
-
.then(module => (consumedChunk.module = module))
|
|
15572
|
-
.catch(() => {
|
|
15573
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
15574
|
-
// once module loading has finished
|
|
15575
|
-
});
|
|
15576
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
15577
|
-
}
|
|
15578
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
15579
|
-
const fileName = consumedFile.fileName ||
|
|
15580
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
15581
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
15582
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
15583
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
15584
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
15585
|
-
const { options } = this;
|
|
15586
|
-
bundle[fileName] = {
|
|
15587
|
-
fileName,
|
|
15588
|
-
get isAsset() {
|
|
15589
|
-
warnDeprecation('Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', true, options);
|
|
15590
|
-
return true;
|
|
15591
|
-
},
|
|
15592
|
-
name: consumedFile.name,
|
|
15593
|
-
source,
|
|
15594
|
-
type: 'asset'
|
|
15595
|
-
};
|
|
15596
15501
|
}
|
|
15502
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
15503
|
+
return chunkDefinitions;
|
|
15597
15504
|
}
|
|
15598
|
-
function
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15505
|
+
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
15506
|
+
const modulesToHandle = new Set([entry]);
|
|
15507
|
+
for (const module of modulesToHandle) {
|
|
15508
|
+
modulesInManualChunks.add(module);
|
|
15509
|
+
manualChunkModules.push(module);
|
|
15510
|
+
for (const dependency of module.dependencies) {
|
|
15511
|
+
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15512
|
+
modulesToHandle.add(dependency);
|
|
15513
|
+
}
|
|
15514
|
+
}
|
|
15602
15515
|
}
|
|
15603
|
-
return null;
|
|
15604
15516
|
}
|
|
15605
|
-
function
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15517
|
+
function analyzeModuleGraph(entryModules) {
|
|
15518
|
+
const dynamicEntryModules = new Set();
|
|
15519
|
+
const dependentEntryPointsByModule = new Map();
|
|
15520
|
+
const entriesToHandle = new Set(entryModules);
|
|
15521
|
+
for (const currentEntry of entriesToHandle) {
|
|
15522
|
+
const modulesToHandle = new Set([currentEntry]);
|
|
15523
|
+
for (const module of modulesToHandle) {
|
|
15524
|
+
getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
|
|
15525
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15526
|
+
if (!(dependency instanceof ExternalModule)) {
|
|
15527
|
+
modulesToHandle.add(dependency);
|
|
15528
|
+
}
|
|
15529
|
+
}
|
|
15530
|
+
for (const { resolution } of module.dynamicImports) {
|
|
15531
|
+
if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
|
|
15532
|
+
dynamicEntryModules.add(resolution);
|
|
15533
|
+
entriesToHandle.add(resolution);
|
|
15534
|
+
}
|
|
15535
|
+
}
|
|
15536
|
+
for (const dependency of module.implicitlyLoadedBefore) {
|
|
15537
|
+
dynamicEntryModules.add(dependency);
|
|
15538
|
+
entriesToHandle.add(dependency);
|
|
15539
|
+
}
|
|
15540
|
+
}
|
|
15614
15541
|
}
|
|
15615
|
-
|
|
15616
|
-
|
|
15542
|
+
return { dependentEntryPointsByModule, dynamicEntryModules };
|
|
15543
|
+
}
|
|
15544
|
+
function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
|
|
15545
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
|
|
15546
|
+
for (const dynamicEntry of dynamicEntryModules) {
|
|
15547
|
+
const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
|
|
15548
|
+
for (const importer of [
|
|
15549
|
+
...dynamicEntry.includedDynamicImporters,
|
|
15550
|
+
...dynamicEntry.implicitlyLoadedAfter
|
|
15551
|
+
]) {
|
|
15552
|
+
for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
|
|
15553
|
+
dynamicDependentEntryPoints.add(entryPoint);
|
|
15554
|
+
}
|
|
15555
|
+
}
|
|
15617
15556
|
}
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15557
|
+
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
15558
|
+
}
|
|
15559
|
+
function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
15560
|
+
const chunkModules = Object.create(null);
|
|
15561
|
+
for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
|
|
15562
|
+
let chunkSignature = '';
|
|
15563
|
+
for (const entry of allEntryPoints) {
|
|
15564
|
+
chunkSignature += assignedEntryPoints.has(entry) ? 'X' : '_';
|
|
15565
|
+
}
|
|
15566
|
+
const chunk = chunkModules[chunkSignature];
|
|
15567
|
+
if (chunk) {
|
|
15568
|
+
chunk.push(module);
|
|
15569
|
+
}
|
|
15570
|
+
else {
|
|
15571
|
+
chunkModules[chunkSignature] = [module];
|
|
15621
15572
|
}
|
|
15622
15573
|
}
|
|
15623
|
-
return
|
|
15574
|
+
return Object.values(chunkModules).map(modules => ({
|
|
15575
|
+
alias: null,
|
|
15576
|
+
modules
|
|
15577
|
+
}));
|
|
15624
15578
|
}
|
|
15625
15579
|
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
]
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15580
|
+
// ported from https://github.com/substack/node-commondir
|
|
15581
|
+
function commondir(files) {
|
|
15582
|
+
if (files.length === 0)
|
|
15583
|
+
return '/';
|
|
15584
|
+
if (files.length === 1)
|
|
15585
|
+
return dirname(files[0]);
|
|
15586
|
+
const commonSegments = files.slice(1).reduce((commonSegments, file) => {
|
|
15587
|
+
const pathSegements = file.split(/\/+|\\+/);
|
|
15588
|
+
let i;
|
|
15589
|
+
for (i = 0; commonSegments[i] === pathSegements[i] &&
|
|
15590
|
+
i < Math.min(commonSegments.length, pathSegements.length); i++)
|
|
15591
|
+
;
|
|
15592
|
+
return commonSegments.slice(0, i);
|
|
15593
|
+
}, files[0].split(/\/+|\\+/));
|
|
15594
|
+
// Windows correctly handles paths with forward-slashes
|
|
15595
|
+
return commonSegments.length > 1 ? commonSegments.join('/') : '/';
|
|
15596
|
+
}
|
|
15597
|
+
|
|
15598
|
+
const compareExecIndex = (unitA, unitB) => unitA.execIndex > unitB.execIndex ? 1 : -1;
|
|
15599
|
+
function sortByExecutionOrder(units) {
|
|
15600
|
+
units.sort(compareExecIndex);
|
|
15601
|
+
}
|
|
15602
|
+
function analyseModuleExecution(entryModules) {
|
|
15603
|
+
let nextExecIndex = 0;
|
|
15604
|
+
const cyclePaths = [];
|
|
15605
|
+
const analysedModules = new Set();
|
|
15606
|
+
const dynamicImports = new Set();
|
|
15607
|
+
const parents = new Map();
|
|
15608
|
+
const orderedModules = [];
|
|
15609
|
+
const analyseModule = (module) => {
|
|
15610
|
+
if (module instanceof Module) {
|
|
15611
|
+
for (const dependency of module.dependencies) {
|
|
15612
|
+
if (parents.has(dependency)) {
|
|
15613
|
+
if (!analysedModules.has(dependency)) {
|
|
15614
|
+
cyclePaths.push(getCyclePath(dependency, module, parents));
|
|
15615
|
+
}
|
|
15616
|
+
continue;
|
|
15617
|
+
}
|
|
15618
|
+
parents.set(dependency, module);
|
|
15619
|
+
analyseModule(dependency);
|
|
15620
|
+
}
|
|
15621
|
+
for (const dependency of module.implicitlyLoadedBefore) {
|
|
15622
|
+
dynamicImports.add(dependency);
|
|
15623
|
+
}
|
|
15624
|
+
for (const { resolution } of module.dynamicImports) {
|
|
15625
|
+
if (resolution instanceof Module) {
|
|
15626
|
+
dynamicImports.add(resolution);
|
|
15627
|
+
}
|
|
15628
|
+
}
|
|
15629
|
+
orderedModules.push(module);
|
|
15630
|
+
}
|
|
15631
|
+
module.execIndex = nextExecIndex++;
|
|
15632
|
+
analysedModules.add(module);
|
|
15633
|
+
};
|
|
15634
|
+
for (const curEntry of entryModules) {
|
|
15635
|
+
if (!parents.has(curEntry)) {
|
|
15636
|
+
parents.set(curEntry, null);
|
|
15637
|
+
analyseModule(curEntry);
|
|
15638
|
+
}
|
|
15645
15639
|
}
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15640
|
+
for (const curEntry of dynamicImports) {
|
|
15641
|
+
if (!parents.has(curEntry)) {
|
|
15642
|
+
parents.set(curEntry, null);
|
|
15643
|
+
analyseModule(curEntry);
|
|
15644
|
+
}
|
|
15645
|
+
}
|
|
15646
|
+
return { cyclePaths, orderedModules };
|
|
15647
|
+
}
|
|
15648
|
+
function getCyclePath(module, parent, parents) {
|
|
15649
|
+
const cycleSymbol = Symbol(module.id);
|
|
15650
|
+
const path = [relativeId(module.id)];
|
|
15651
|
+
let nextModule = parent;
|
|
15652
|
+
module.cycles.add(cycleSymbol);
|
|
15653
|
+
while (nextModule !== module) {
|
|
15654
|
+
nextModule.cycles.add(cycleSymbol);
|
|
15655
|
+
path.push(relativeId(nextModule.id));
|
|
15656
|
+
nextModule = parents.get(nextModule);
|
|
15652
15657
|
}
|
|
15658
|
+
path.push(path[0]);
|
|
15659
|
+
path.reverse();
|
|
15660
|
+
return path;
|
|
15661
|
+
}
|
|
15662
|
+
|
|
15663
|
+
function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, constBindings, objectShorthand, reservedNamesAsProps } }) {
|
|
15664
|
+
const { _, n, s } = compact ? { _: '', n: '', s: '' } : { _: ' ', n: '\n', s: ';' };
|
|
15665
|
+
const cnst = constBindings ? 'const' : 'var';
|
|
15666
|
+
const getNonArrowFunctionIntro = (params, { isAsync, name }) => `${isAsync ? `async ` : ''}function${name ? ` ${name}` : ''}${_}(${params.join(`,${_}`)})${_}`;
|
|
15667
|
+
const getFunctionIntro = arrowFunctions
|
|
15668
|
+
? (params, { isAsync, name }) => {
|
|
15669
|
+
const singleParam = params.length === 1;
|
|
15670
|
+
const asyncString = isAsync ? `async${singleParam ? ' ' : _}` : '';
|
|
15671
|
+
return `${name ? `${cnst} ${name}${_}=${_}` : ''}${asyncString}${singleParam ? params[0] : `(${params.join(`,${_}`)})`}${_}=>${_}`;
|
|
15672
|
+
}
|
|
15673
|
+
: getNonArrowFunctionIntro;
|
|
15674
|
+
const getDirectReturnFunction = (params, { functionReturn, lineBreakIndent, name }) => [
|
|
15675
|
+
`${getFunctionIntro(params, {
|
|
15676
|
+
isAsync: false,
|
|
15677
|
+
name
|
|
15678
|
+
})}${arrowFunctions
|
|
15679
|
+
? lineBreakIndent
|
|
15680
|
+
? `${n}${lineBreakIndent.base}${lineBreakIndent.t}`
|
|
15681
|
+
: ''
|
|
15682
|
+
: `{${lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _}${functionReturn ? 'return ' : ''}`}`,
|
|
15683
|
+
arrowFunctions
|
|
15684
|
+
? `${name ? ';' : ''}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : ''}`
|
|
15685
|
+
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
15686
|
+
];
|
|
15687
|
+
const isValidPropName = reservedNamesAsProps
|
|
15688
|
+
? (name) => validPropName.test(name)
|
|
15689
|
+
: (name) => !RESERVED_NAMES$1.has(name) && validPropName.test(name);
|
|
15690
|
+
return {
|
|
15691
|
+
_,
|
|
15692
|
+
cnst,
|
|
15693
|
+
getDirectReturnFunction,
|
|
15694
|
+
getDirectReturnIifeLeft: (params, returned, { needsArrowReturnParens, needsWrappedFunction }) => {
|
|
15695
|
+
const [left, right] = getDirectReturnFunction(params, {
|
|
15696
|
+
functionReturn: true,
|
|
15697
|
+
lineBreakIndent: null,
|
|
15698
|
+
name: null
|
|
15699
|
+
});
|
|
15700
|
+
return `${wrapIfNeeded(`${left}${wrapIfNeeded(returned, arrowFunctions && needsArrowReturnParens)}${right}`, arrowFunctions || needsWrappedFunction)}(`;
|
|
15701
|
+
},
|
|
15702
|
+
getFunctionIntro,
|
|
15703
|
+
getNonArrowFunctionIntro,
|
|
15704
|
+
getObject(fields, { lineBreakIndent }) {
|
|
15705
|
+
const prefix = lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _;
|
|
15706
|
+
return `{${fields
|
|
15707
|
+
.map(([key, value]) => {
|
|
15708
|
+
if (key === null)
|
|
15709
|
+
return `${prefix}${value}`;
|
|
15710
|
+
const needsQuotes = !isValidPropName(key);
|
|
15711
|
+
return key === value && objectShorthand && !needsQuotes
|
|
15712
|
+
? prefix + key
|
|
15713
|
+
: `${prefix}${needsQuotes ? `'${key}'` : key}:${_}${value}`;
|
|
15714
|
+
})
|
|
15715
|
+
.join(`,`)}${fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`;
|
|
15716
|
+
},
|
|
15717
|
+
getPropertyAccess: (name) => isValidPropName(name) ? `.${name}` : `[${JSON.stringify(name)}]`,
|
|
15718
|
+
n,
|
|
15719
|
+
s
|
|
15720
|
+
};
|
|
15653
15721
|
}
|
|
15722
|
+
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
15723
|
+
const validPropName = /^(?!\d)[\w$]+$/;
|
|
15654
15724
|
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
const chunkModules = (manualChunkModulesByAlias[alias] =
|
|
15661
|
-
manualChunkModulesByAlias[alias] || []);
|
|
15662
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15725
|
+
class Source {
|
|
15726
|
+
constructor(filename, content) {
|
|
15727
|
+
this.isOriginal = true;
|
|
15728
|
+
this.filename = filename;
|
|
15729
|
+
this.content = content;
|
|
15663
15730
|
}
|
|
15664
|
-
|
|
15665
|
-
|
|
15731
|
+
traceSegment(line, column, name) {
|
|
15732
|
+
return { column, line, name, source: this };
|
|
15666
15733
|
}
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
for (const module of modulesToHandle) {
|
|
15674
|
-
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
15675
|
-
if (dynamicDependentEntryPoints &&
|
|
15676
|
-
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
15677
|
-
continue;
|
|
15678
|
-
}
|
|
15679
|
-
else {
|
|
15680
|
-
assignedEntryPoints.add(entry);
|
|
15681
|
-
}
|
|
15682
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15683
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15684
|
-
modulesToHandle.add(dependency);
|
|
15685
|
-
}
|
|
15686
|
-
}
|
|
15687
|
-
}
|
|
15734
|
+
}
|
|
15735
|
+
class Link {
|
|
15736
|
+
constructor(map, sources) {
|
|
15737
|
+
this.sources = sources;
|
|
15738
|
+
this.names = map.names;
|
|
15739
|
+
this.mappings = map.mappings;
|
|
15688
15740
|
}
|
|
15689
|
-
|
|
15690
|
-
const
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15741
|
+
traceMappings() {
|
|
15742
|
+
const sources = [];
|
|
15743
|
+
const sourceIndexMap = new Map();
|
|
15744
|
+
const sourcesContent = [];
|
|
15745
|
+
const names = [];
|
|
15746
|
+
const nameIndexMap = new Map();
|
|
15747
|
+
const mappings = [];
|
|
15748
|
+
for (const line of this.mappings) {
|
|
15749
|
+
const tracedLine = [];
|
|
15750
|
+
for (const segment of line) {
|
|
15751
|
+
if (segment.length === 1)
|
|
15752
|
+
continue;
|
|
15753
|
+
const source = this.sources[segment[1]];
|
|
15754
|
+
if (!source)
|
|
15755
|
+
continue;
|
|
15756
|
+
const traced = source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : '');
|
|
15757
|
+
if (traced) {
|
|
15758
|
+
const { column, line, name, source: { content, filename } } = traced;
|
|
15759
|
+
let sourceIndex = sourceIndexMap.get(filename);
|
|
15760
|
+
if (sourceIndex === undefined) {
|
|
15761
|
+
sourceIndex = sources.length;
|
|
15762
|
+
sources.push(filename);
|
|
15763
|
+
sourceIndexMap.set(filename, sourceIndex);
|
|
15764
|
+
sourcesContent[sourceIndex] = content;
|
|
15765
|
+
}
|
|
15766
|
+
else if (sourcesContent[sourceIndex] == null) {
|
|
15767
|
+
sourcesContent[sourceIndex] = content;
|
|
15768
|
+
}
|
|
15769
|
+
else if (content != null && sourcesContent[sourceIndex] !== content) {
|
|
15770
|
+
return error({
|
|
15771
|
+
message: `Multiple conflicting contents for sourcemap source ${filename}`
|
|
15772
|
+
});
|
|
15773
|
+
}
|
|
15774
|
+
const tracedSegment = [segment[0], sourceIndex, line, column];
|
|
15775
|
+
if (name) {
|
|
15776
|
+
let nameIndex = nameIndexMap.get(name);
|
|
15777
|
+
if (nameIndex === undefined) {
|
|
15778
|
+
nameIndex = names.length;
|
|
15779
|
+
names.push(name);
|
|
15780
|
+
nameIndexMap.set(name, nameIndex);
|
|
15781
|
+
}
|
|
15782
|
+
tracedSegment[4] = nameIndex;
|
|
15783
|
+
}
|
|
15784
|
+
tracedLine.push(tracedSegment);
|
|
15698
15785
|
}
|
|
15699
15786
|
}
|
|
15787
|
+
mappings.push(tracedLine);
|
|
15700
15788
|
}
|
|
15701
|
-
return
|
|
15702
|
-
}
|
|
15703
|
-
for (const entry of entryModules) {
|
|
15704
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
15705
|
-
assignEntryToStaticDependencies(entry, null);
|
|
15706
|
-
}
|
|
15707
|
-
}
|
|
15708
|
-
for (const entry of dynamicEntryModules) {
|
|
15709
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
15710
|
-
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15711
|
-
}
|
|
15712
|
-
}
|
|
15713
|
-
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
15714
|
-
return chunkDefinitions;
|
|
15715
|
-
}
|
|
15716
|
-
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
15717
|
-
const modulesToHandle = new Set([entry]);
|
|
15718
|
-
for (const module of modulesToHandle) {
|
|
15719
|
-
modulesInManualChunks.add(module);
|
|
15720
|
-
manualChunkModules.push(module);
|
|
15721
|
-
for (const dependency of module.dependencies) {
|
|
15722
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
15723
|
-
modulesToHandle.add(dependency);
|
|
15724
|
-
}
|
|
15725
|
-
}
|
|
15789
|
+
return { mappings, names, sources, sourcesContent };
|
|
15726
15790
|
}
|
|
15727
|
-
|
|
15728
|
-
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15791
|
+
traceSegment(line, column, name) {
|
|
15792
|
+
const segments = this.mappings[line];
|
|
15793
|
+
if (!segments)
|
|
15794
|
+
return null;
|
|
15795
|
+
// binary search through segments for the given column
|
|
15796
|
+
let searchStart = 0;
|
|
15797
|
+
let searchEnd = segments.length - 1;
|
|
15798
|
+
while (searchStart <= searchEnd) {
|
|
15799
|
+
const m = (searchStart + searchEnd) >> 1;
|
|
15800
|
+
const segment = segments[m];
|
|
15801
|
+
// If a sourcemap does not have sufficient resolution to contain a
|
|
15802
|
+
// necessary mapping, e.g. because it only contains line information, we
|
|
15803
|
+
// use the best approximation we could find
|
|
15804
|
+
if (segment[0] === column || searchStart === searchEnd) {
|
|
15805
|
+
if (segment.length == 1)
|
|
15806
|
+
return null;
|
|
15807
|
+
const source = this.sources[segment[1]];
|
|
15808
|
+
if (!source)
|
|
15809
|
+
return null;
|
|
15810
|
+
return source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : name);
|
|
15740
15811
|
}
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
dynamicEntryModules.add(resolution);
|
|
15744
|
-
entriesToHandle.add(resolution);
|
|
15745
|
-
}
|
|
15812
|
+
if (segment[0] > column) {
|
|
15813
|
+
searchEnd = m - 1;
|
|
15746
15814
|
}
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
entriesToHandle.add(dependency);
|
|
15815
|
+
else {
|
|
15816
|
+
searchStart = m + 1;
|
|
15750
15817
|
}
|
|
15751
15818
|
}
|
|
15819
|
+
return null;
|
|
15752
15820
|
}
|
|
15753
|
-
return { dependentEntryPointsByModule, dynamicEntryModules };
|
|
15754
15821
|
}
|
|
15755
|
-
function
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
for (const importer of [
|
|
15760
|
-
...dynamicEntry.includedDynamicImporters,
|
|
15761
|
-
...dynamicEntry.implicitlyLoadedAfter
|
|
15762
|
-
]) {
|
|
15763
|
-
for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
|
|
15764
|
-
dynamicDependentEntryPoints.add(entryPoint);
|
|
15765
|
-
}
|
|
15822
|
+
function getLinkMap(warn) {
|
|
15823
|
+
return function linkMap(source, map) {
|
|
15824
|
+
if (map.mappings) {
|
|
15825
|
+
return new Link(map, [source]);
|
|
15766
15826
|
}
|
|
15827
|
+
warn({
|
|
15828
|
+
code: 'SOURCEMAP_BROKEN',
|
|
15829
|
+
message: `Sourcemap is likely to be incorrect: a plugin (${map.plugin}) was used to transform ` +
|
|
15830
|
+
"files, but didn't generate a sourcemap for the transformation. Consult the plugin " +
|
|
15831
|
+
'documentation for help',
|
|
15832
|
+
plugin: map.plugin,
|
|
15833
|
+
url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect`
|
|
15834
|
+
});
|
|
15835
|
+
return new Link({
|
|
15836
|
+
mappings: [],
|
|
15837
|
+
names: []
|
|
15838
|
+
}, [source]);
|
|
15839
|
+
};
|
|
15840
|
+
}
|
|
15841
|
+
function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, linkMap) {
|
|
15842
|
+
let source;
|
|
15843
|
+
if (!originalSourcemap) {
|
|
15844
|
+
source = new Source(id, originalCode);
|
|
15767
15845
|
}
|
|
15768
|
-
|
|
15846
|
+
else {
|
|
15847
|
+
const sources = originalSourcemap.sources;
|
|
15848
|
+
const sourcesContent = originalSourcemap.sourcesContent || [];
|
|
15849
|
+
const directory = dirname(id) || '.';
|
|
15850
|
+
const sourceRoot = originalSourcemap.sourceRoot || '.';
|
|
15851
|
+
const baseSources = sources.map((source, i) => new Source(resolve(directory, sourceRoot, source), sourcesContent[i]));
|
|
15852
|
+
source = new Link(originalSourcemap, baseSources);
|
|
15853
|
+
}
|
|
15854
|
+
return sourcemapChain.reduce(linkMap, source);
|
|
15769
15855
|
}
|
|
15770
|
-
function
|
|
15771
|
-
const
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
chunkModules[chunkSignature] = [module];
|
|
15783
|
-
}
|
|
15856
|
+
function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, warn) {
|
|
15857
|
+
const linkMap = getLinkMap(warn);
|
|
15858
|
+
const moduleSources = modules
|
|
15859
|
+
.filter(module => !module.excludeFromSourcemap)
|
|
15860
|
+
.map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
|
|
15861
|
+
const link = new Link(map, moduleSources);
|
|
15862
|
+
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
15863
|
+
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
15864
|
+
if (file) {
|
|
15865
|
+
const directory = dirname(file);
|
|
15866
|
+
sources = sources.map((source) => relative$1(directory, source));
|
|
15867
|
+
file = basename(file);
|
|
15784
15868
|
}
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
|
|
15788
|
-
|
|
15869
|
+
sourcesContent = (excludeContent ? null : sourcesContent);
|
|
15870
|
+
return new SourceMap({ file, mappings, names, sources, sourcesContent });
|
|
15871
|
+
}
|
|
15872
|
+
function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn) {
|
|
15873
|
+
if (!sourcemapChain.length) {
|
|
15874
|
+
return originalSourcemap;
|
|
15875
|
+
}
|
|
15876
|
+
const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(warn));
|
|
15877
|
+
const map = source.traceMappings();
|
|
15878
|
+
return { version: 3, ...map };
|
|
15789
15879
|
}
|
|
15790
15880
|
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
}
|
|
15805
|
-
|
|
15806
|
-
return
|
|
15881
|
+
function decodedSourcemap(map) {
|
|
15882
|
+
if (!map)
|
|
15883
|
+
return null;
|
|
15884
|
+
if (typeof map === 'string') {
|
|
15885
|
+
map = JSON.parse(map);
|
|
15886
|
+
}
|
|
15887
|
+
if (map.mappings === '') {
|
|
15888
|
+
return {
|
|
15889
|
+
mappings: [],
|
|
15890
|
+
names: [],
|
|
15891
|
+
sources: [],
|
|
15892
|
+
version: 3
|
|
15893
|
+
};
|
|
15894
|
+
}
|
|
15895
|
+
const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
|
|
15896
|
+
return { ...map, mappings };
|
|
15807
15897
|
}
|
|
15808
15898
|
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15899
|
+
async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, onwarn) {
|
|
15900
|
+
timeStart('render chunks', 2);
|
|
15901
|
+
reserveEntryChunksInBundle(chunks);
|
|
15902
|
+
const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
|
|
15903
|
+
timeEnd('render chunks', 2);
|
|
15904
|
+
timeStart('transform chunks', 2);
|
|
15905
|
+
const chunkGraph = getChunkGraph(chunks);
|
|
15906
|
+
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
15907
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle);
|
|
15908
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders);
|
|
15909
|
+
timeEnd('transform chunks', 2);
|
|
15812
15910
|
}
|
|
15813
|
-
function
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15911
|
+
function reserveEntryChunksInBundle(chunks) {
|
|
15912
|
+
for (const chunk of chunks) {
|
|
15913
|
+
if (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint) {
|
|
15914
|
+
// reserves name in bundle as side effect if it does not contain a hash
|
|
15915
|
+
chunk.getPreliminaryFileName();
|
|
15916
|
+
}
|
|
15917
|
+
}
|
|
15918
|
+
}
|
|
15919
|
+
function getChunkGraph(chunks) {
|
|
15920
|
+
return Object.fromEntries(chunks.map(chunk => {
|
|
15921
|
+
const renderedChunkInfo = chunk.getRenderedChunkInfo();
|
|
15922
|
+
return [renderedChunkInfo.fileName, renderedChunkInfo];
|
|
15923
|
+
}));
|
|
15924
|
+
}
|
|
15925
|
+
async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, onwarn) {
|
|
15926
|
+
let map = null;
|
|
15927
|
+
const sourcemapChain = [];
|
|
15928
|
+
let code = await outputPluginDriver.hookReduceArg0('renderChunk', [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], (code, result, plugin) => {
|
|
15929
|
+
if (result == null)
|
|
15930
|
+
return code;
|
|
15931
|
+
if (typeof result === 'string')
|
|
15932
|
+
result = {
|
|
15933
|
+
code: result,
|
|
15934
|
+
map: undefined
|
|
15935
|
+
};
|
|
15936
|
+
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
|
|
15937
|
+
if (result.map !== null) {
|
|
15938
|
+
const map = decodedSourcemap(result.map);
|
|
15939
|
+
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
|
|
15940
|
+
}
|
|
15941
|
+
return result.code;
|
|
15942
|
+
});
|
|
15943
|
+
const { compact, sourcemap, sourcemapPathTransform } = options;
|
|
15944
|
+
if (!compact && code[code.length - 1] !== '\n')
|
|
15945
|
+
code += '\n';
|
|
15946
|
+
if (sourcemap) {
|
|
15947
|
+
timeStart('sourcemaps', 3);
|
|
15948
|
+
let file;
|
|
15949
|
+
if (options.file)
|
|
15950
|
+
file = resolve(options.sourcemapFile || options.file);
|
|
15951
|
+
else if (options.dir)
|
|
15952
|
+
file = resolve(options.dir, fileName);
|
|
15953
|
+
else
|
|
15954
|
+
file = resolve(fileName);
|
|
15955
|
+
const decodedMap = magicString.generateDecodedMap({});
|
|
15956
|
+
map = collapseSourcemaps(file, decodedMap, usedModules, sourcemapChain, options.sourcemapExcludeSources, onwarn);
|
|
15957
|
+
map.sources = map.sources
|
|
15958
|
+
.map(sourcePath => {
|
|
15959
|
+
if (sourcemapPathTransform) {
|
|
15960
|
+
const newSourcePath = sourcemapPathTransform(sourcePath, `${file}.map`);
|
|
15961
|
+
if (typeof newSourcePath !== 'string') {
|
|
15962
|
+
error(errFailedValidation(`sourcemapPathTransform function must return a string.`));
|
|
15828
15963
|
}
|
|
15829
|
-
|
|
15830
|
-
analyseModule(dependency);
|
|
15964
|
+
return newSourcePath;
|
|
15831
15965
|
}
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15966
|
+
return sourcePath;
|
|
15967
|
+
})
|
|
15968
|
+
.map(normalize);
|
|
15969
|
+
timeEnd('sourcemaps', 3);
|
|
15970
|
+
}
|
|
15971
|
+
return {
|
|
15972
|
+
code,
|
|
15973
|
+
map
|
|
15974
|
+
};
|
|
15975
|
+
}
|
|
15976
|
+
async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn) {
|
|
15977
|
+
const nonHashedChunksWithPlaceholders = [];
|
|
15978
|
+
const renderedChunksByPlaceholder = new Map();
|
|
15979
|
+
const hashDependenciesByPlaceholder = new Map();
|
|
15980
|
+
const placeholders = new Set();
|
|
15981
|
+
for (const { preliminaryFileName: { hashPlaceholder } } of renderedChunks) {
|
|
15982
|
+
if (hashPlaceholder)
|
|
15983
|
+
placeholders.add(hashPlaceholder);
|
|
15984
|
+
}
|
|
15985
|
+
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, magicString, usedModules }) => {
|
|
15986
|
+
const transformedChunk = {
|
|
15987
|
+
chunk,
|
|
15988
|
+
fileName,
|
|
15989
|
+
...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, onwarn))
|
|
15990
|
+
};
|
|
15991
|
+
const { code } = transformedChunk;
|
|
15992
|
+
if (hashPlaceholder) {
|
|
15993
|
+
const hash = createHash();
|
|
15994
|
+
// To create a reproducible content-only hash, all placeholders are
|
|
15995
|
+
// replaced with the same value before hashing
|
|
15996
|
+
const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
|
|
15997
|
+
hash.update(transformedCode);
|
|
15998
|
+
const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
|
|
15999
|
+
if (pluginHash) {
|
|
16000
|
+
augmentation += pluginHash;
|
|
15838
16001
|
}
|
|
16002
|
+
return augmentation;
|
|
16003
|
+
});
|
|
16004
|
+
if (hashAugmentation) {
|
|
16005
|
+
hash.update(hashAugmentation);
|
|
15839
16006
|
}
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
for (const curEntry of entryModules) {
|
|
15846
|
-
if (!parents.has(curEntry)) {
|
|
15847
|
-
parents.set(curEntry, null);
|
|
15848
|
-
analyseModule(curEntry);
|
|
16007
|
+
renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
|
|
16008
|
+
hashDependenciesByPlaceholder.set(hashPlaceholder, {
|
|
16009
|
+
containedPlaceholders,
|
|
16010
|
+
contentHash: hash.digest('hex')
|
|
16011
|
+
});
|
|
15849
16012
|
}
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
if (!parents.has(curEntry)) {
|
|
15853
|
-
parents.set(curEntry, null);
|
|
15854
|
-
analyseModule(curEntry);
|
|
16013
|
+
else {
|
|
16014
|
+
nonHashedChunksWithPlaceholders.push(transformedChunk);
|
|
15855
16015
|
}
|
|
15856
|
-
}
|
|
15857
|
-
return {
|
|
16016
|
+
}));
|
|
16017
|
+
return {
|
|
16018
|
+
hashDependenciesByPlaceholder,
|
|
16019
|
+
nonHashedChunksWithPlaceholders,
|
|
16020
|
+
renderedChunksByPlaceholder
|
|
16021
|
+
};
|
|
15858
16022
|
}
|
|
15859
|
-
function
|
|
15860
|
-
const
|
|
15861
|
-
const
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
16023
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle) {
|
|
16024
|
+
const hashesByPlaceholder = new Map();
|
|
16025
|
+
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
16026
|
+
let hash = createHash();
|
|
16027
|
+
const hashDependencyPlaceholders = new Set([placeholder]);
|
|
16028
|
+
for (const dependencyPlaceholder of hashDependencyPlaceholders) {
|
|
16029
|
+
const { containedPlaceholders, contentHash } = hashDependenciesByPlaceholder.get(dependencyPlaceholder);
|
|
16030
|
+
hash.update(contentHash);
|
|
16031
|
+
for (const containedPlaceholder of containedPlaceholders) {
|
|
16032
|
+
// When looping over a map, setting an entry only causes a new iteration if the key is new
|
|
16033
|
+
hashDependencyPlaceholders.add(containedPlaceholder);
|
|
16034
|
+
}
|
|
16035
|
+
}
|
|
16036
|
+
let finalFileName;
|
|
16037
|
+
let finalHash;
|
|
16038
|
+
do {
|
|
16039
|
+
// In case of a hash collision, create a hash of the hash
|
|
16040
|
+
if (finalHash) {
|
|
16041
|
+
hash = createHash();
|
|
16042
|
+
hash.update(finalHash);
|
|
16043
|
+
}
|
|
16044
|
+
finalHash = hash.digest('hex').slice(0, placeholder.length);
|
|
16045
|
+
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
16046
|
+
} while (outputBundle[finalFileName]);
|
|
16047
|
+
outputBundle[finalFileName] = FILE_PLACEHOLDER;
|
|
16048
|
+
hashesByPlaceholder.set(placeholder, finalHash.slice(0, placeholder.length));
|
|
15868
16049
|
}
|
|
15869
|
-
|
|
15870
|
-
path.reverse();
|
|
15871
|
-
return path;
|
|
16050
|
+
return hashesByPlaceholder;
|
|
15872
16051
|
}
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
? (params, { isAsync, name }) => {
|
|
15880
|
-
const singleParam = params.length === 1;
|
|
15881
|
-
const asyncString = isAsync ? `async${singleParam ? ' ' : _}` : '';
|
|
15882
|
-
return `${name ? `${cnst} ${name}${_}=${_}` : ''}${asyncString}${singleParam ? params[0] : `(${params.join(`,${_}`)})`}${_}=>${_}`;
|
|
16052
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders) {
|
|
16053
|
+
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16054
|
+
const updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16055
|
+
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
16056
|
+
if (map) {
|
|
16057
|
+
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
15883
16058
|
}
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
: ''
|
|
15893
|
-
: `{${lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _}${functionReturn ? 'return ' : ''}`}`,
|
|
15894
|
-
arrowFunctions
|
|
15895
|
-
? `${name ? ';' : ''}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : ''}`
|
|
15896
|
-
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
15897
|
-
];
|
|
15898
|
-
const isValidPropName = reservedNamesAsProps
|
|
15899
|
-
? (name) => validPropName.test(name)
|
|
15900
|
-
: (name) => !RESERVED_NAMES$1.has(name) && validPropName.test(name);
|
|
15901
|
-
return {
|
|
15902
|
-
_,
|
|
15903
|
-
cnst,
|
|
15904
|
-
getDirectReturnFunction,
|
|
15905
|
-
getDirectReturnIifeLeft: (params, returned, { needsArrowReturnParens, needsWrappedFunction }) => {
|
|
15906
|
-
const [left, right] = getDirectReturnFunction(params, {
|
|
15907
|
-
functionReturn: true,
|
|
15908
|
-
lineBreakIndent: null,
|
|
15909
|
-
name: null
|
|
15910
|
-
});
|
|
15911
|
-
return `${wrapIfNeeded(`${left}${wrapIfNeeded(returned, arrowFunctions && needsArrowReturnParens)}${right}`, arrowFunctions || needsWrappedFunction)}(`;
|
|
15912
|
-
},
|
|
15913
|
-
getFunctionIntro,
|
|
15914
|
-
getNonArrowFunctionIntro,
|
|
15915
|
-
getObject(fields, { lineBreakIndent }) {
|
|
15916
|
-
const prefix = lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _;
|
|
15917
|
-
return `{${fields
|
|
15918
|
-
.map(([key, value]) => {
|
|
15919
|
-
if (key === null)
|
|
15920
|
-
return `${prefix}${value}`;
|
|
15921
|
-
const needsQuotes = !isValidPropName(key);
|
|
15922
|
-
return key === value && objectShorthand && !needsQuotes
|
|
15923
|
-
? prefix + key
|
|
15924
|
-
: `${prefix}${needsQuotes ? `'${key}'` : key}:${_}${value}`;
|
|
15925
|
-
})
|
|
15926
|
-
.join(`,`)}${fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`;
|
|
15927
|
-
},
|
|
15928
|
-
getPropertyAccess: (name) => isValidPropName(name) ? `.${name}` : `[${JSON.stringify(name)}]`,
|
|
15929
|
-
n,
|
|
15930
|
-
s
|
|
15931
|
-
};
|
|
16059
|
+
outputBundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16060
|
+
}
|
|
16061
|
+
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16062
|
+
const updatedCode = hashesByPlaceholder.size
|
|
16063
|
+
? replacePlaceholders(code, hashesByPlaceholder)
|
|
16064
|
+
: code;
|
|
16065
|
+
outputBundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16066
|
+
}
|
|
15932
16067
|
}
|
|
15933
|
-
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
15934
|
-
const validPropName = /^(?!\d)[\w$]+$/;
|
|
15935
16068
|
|
|
15936
16069
|
class Bundle {
|
|
15937
16070
|
constructor(outputOptions, unsetOptions, inputOptions, pluginDriver, graph) {
|
|
@@ -15946,48 +16079,39 @@ class Bundle {
|
|
|
15946
16079
|
async generate(isWrite) {
|
|
15947
16080
|
timeStart('GENERATE', 1);
|
|
15948
16081
|
const outputBundle = Object.create(null);
|
|
15949
|
-
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions
|
|
16082
|
+
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
|
|
15950
16083
|
try {
|
|
16084
|
+
timeStart('initialize render', 2);
|
|
15951
16085
|
await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
|
|
16086
|
+
timeEnd('initialize render', 2);
|
|
15952
16087
|
timeStart('generate chunks', 2);
|
|
15953
|
-
const
|
|
16088
|
+
const getHashPlaceholder = getHashPlaceholderGenerator();
|
|
16089
|
+
const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
|
|
15954
16090
|
if (chunks.length > 1) {
|
|
15955
16091
|
validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
|
|
15956
16092
|
}
|
|
15957
|
-
|
|
16093
|
+
this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
|
|
16094
|
+
for (const chunk of chunks) {
|
|
16095
|
+
chunk.generateExports();
|
|
16096
|
+
}
|
|
15958
16097
|
timeEnd('generate chunks', 2);
|
|
15959
|
-
|
|
15960
|
-
// We need to create addons before prerender because at the moment, there
|
|
15961
|
-
// can be no async code between prerender and render due to internal state
|
|
15962
|
-
const addons = await createAddons(this.outputOptions, this.pluginDriver);
|
|
15963
|
-
const snippets = getGenerateCodeSnippets(this.outputOptions);
|
|
15964
|
-
this.prerenderChunks(chunks, inputBase, snippets);
|
|
15965
|
-
timeEnd('render modules', 2);
|
|
15966
|
-
await this.addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle, snippets);
|
|
16098
|
+
await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
|
|
15967
16099
|
}
|
|
15968
16100
|
catch (err) {
|
|
15969
16101
|
await this.pluginDriver.hookParallel('renderError', [err]);
|
|
15970
16102
|
throw err;
|
|
15971
16103
|
}
|
|
16104
|
+
timeStart('generate bundle', 2);
|
|
15972
16105
|
await this.pluginDriver.hookSeq('generateBundle', [
|
|
15973
16106
|
this.outputOptions,
|
|
15974
16107
|
outputBundle,
|
|
15975
16108
|
isWrite
|
|
15976
16109
|
]);
|
|
15977
16110
|
this.finaliseAssets(outputBundle);
|
|
16111
|
+
timeEnd('generate bundle', 2);
|
|
15978
16112
|
timeEnd('GENERATE', 1);
|
|
15979
16113
|
return outputBundle;
|
|
15980
16114
|
}
|
|
15981
|
-
async addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle, snippets) {
|
|
15982
|
-
this.assignChunkIds(chunks, inputBase, addons, outputBundle);
|
|
15983
|
-
for (const chunk of chunks) {
|
|
15984
|
-
outputBundle[chunk.id] = chunk.getChunkInfoWithFileNames();
|
|
15985
|
-
}
|
|
15986
|
-
await Promise.all(chunks.map(async (chunk) => {
|
|
15987
|
-
const outputChunk = outputBundle[chunk.id];
|
|
15988
|
-
Object.assign(outputChunk, await chunk.render(this.outputOptions, addons, outputChunk, snippets));
|
|
15989
|
-
}));
|
|
15990
|
-
}
|
|
15991
16115
|
async addManualChunks(manualChunks) {
|
|
15992
16116
|
const manualChunkAliasByEntry = new Map();
|
|
15993
16117
|
const chunkEntries = await Promise.all(Object.entries(manualChunks).map(async ([alias, files]) => ({
|
|
@@ -16001,29 +16125,6 @@ class Bundle {
|
|
|
16001
16125
|
}
|
|
16002
16126
|
return manualChunkAliasByEntry;
|
|
16003
16127
|
}
|
|
16004
|
-
assignChunkIds(chunks, inputBase, addons, bundle) {
|
|
16005
|
-
const entryChunks = [];
|
|
16006
|
-
const otherChunks = [];
|
|
16007
|
-
for (const chunk of chunks) {
|
|
16008
|
-
(chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint
|
|
16009
|
-
? entryChunks
|
|
16010
|
-
: otherChunks).push(chunk);
|
|
16011
|
-
}
|
|
16012
|
-
// make sure entry chunk names take precedence with regard to deconflicting
|
|
16013
|
-
const chunksForNaming = entryChunks.concat(otherChunks);
|
|
16014
|
-
for (const chunk of chunksForNaming) {
|
|
16015
|
-
if (this.outputOptions.file) {
|
|
16016
|
-
chunk.id = basename(this.outputOptions.file);
|
|
16017
|
-
}
|
|
16018
|
-
else if (this.outputOptions.preserveModules) {
|
|
16019
|
-
chunk.id = chunk.generateIdPreserveModules(inputBase, this.outputOptions, bundle, this.unsetOptions);
|
|
16020
|
-
}
|
|
16021
|
-
else {
|
|
16022
|
-
chunk.id = chunk.generateId(addons, this.outputOptions, bundle, true);
|
|
16023
|
-
}
|
|
16024
|
-
bundle[chunk.id] = FILE_PLACEHOLDER;
|
|
16025
|
-
}
|
|
16026
|
-
}
|
|
16027
16128
|
assignManualChunks(getManualChunk) {
|
|
16028
16129
|
const manualChunkAliasesWithEntry = [];
|
|
16029
16130
|
const manualChunksApi = {
|
|
@@ -16047,10 +16148,6 @@ class Bundle {
|
|
|
16047
16148
|
}
|
|
16048
16149
|
finaliseAssets(outputBundle) {
|
|
16049
16150
|
for (const file of Object.values(outputBundle)) {
|
|
16050
|
-
if (!file.type) {
|
|
16051
|
-
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);
|
|
16052
|
-
file.type = 'asset';
|
|
16053
|
-
}
|
|
16054
16151
|
if (this.outputOptions.validate && 'code' in file) {
|
|
16055
16152
|
try {
|
|
16056
16153
|
this.graph.contextParse(file.code, {
|
|
@@ -16065,27 +16162,25 @@ class Bundle {
|
|
|
16065
16162
|
}
|
|
16066
16163
|
this.pluginDriver.finaliseAssets();
|
|
16067
16164
|
}
|
|
16068
|
-
async generateChunks() {
|
|
16069
|
-
const { manualChunks } = this.outputOptions;
|
|
16165
|
+
async generateChunks(bundle, getHashPlaceholder) {
|
|
16166
|
+
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16070
16167
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16071
16168
|
? await this.addManualChunks(manualChunks)
|
|
16072
16169
|
: this.assignManualChunks(manualChunks);
|
|
16170
|
+
const snippets = getGenerateCodeSnippets(this.outputOptions);
|
|
16171
|
+
const includedModules = getIncludedModules(this.graph.modulesById);
|
|
16172
|
+
const inputBase = commondir(getAbsoluteEntryModulePaths(includedModules, preserveModules));
|
|
16173
|
+
const externalChunkByModule = getExternalChunkByModule(this.graph.modulesById, this.outputOptions, inputBase);
|
|
16073
16174
|
const chunks = [];
|
|
16074
16175
|
const chunkByModule = new Map();
|
|
16075
|
-
for (const { alias, modules } of
|
|
16076
|
-
? [{ alias: null, modules:
|
|
16077
|
-
:
|
|
16078
|
-
?
|
|
16079
|
-
alias: null,
|
|
16080
|
-
modules: [module]
|
|
16081
|
-
}))
|
|
16176
|
+
for (const { alias, modules } of inlineDynamicImports
|
|
16177
|
+
? [{ alias: null, modules: includedModules }]
|
|
16178
|
+
: preserveModules
|
|
16179
|
+
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16082
16180
|
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
16083
16181
|
sortByExecutionOrder(modules);
|
|
16084
|
-
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias);
|
|
16182
|
+
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);
|
|
16085
16183
|
chunks.push(chunk);
|
|
16086
|
-
for (const module of modules) {
|
|
16087
|
-
chunkByModule.set(module, chunk);
|
|
16088
|
-
}
|
|
16089
16184
|
}
|
|
16090
16185
|
for (const chunk of chunks) {
|
|
16091
16186
|
chunk.link();
|
|
@@ -16096,25 +16191,6 @@ class Bundle {
|
|
|
16096
16191
|
}
|
|
16097
16192
|
return [...chunks, ...facades];
|
|
16098
16193
|
}
|
|
16099
|
-
prerenderChunks(chunks, inputBase, snippets) {
|
|
16100
|
-
for (const chunk of chunks) {
|
|
16101
|
-
chunk.generateExports();
|
|
16102
|
-
}
|
|
16103
|
-
for (const chunk of chunks) {
|
|
16104
|
-
chunk.preRender(this.outputOptions, inputBase, snippets);
|
|
16105
|
-
}
|
|
16106
|
-
}
|
|
16107
|
-
}
|
|
16108
|
-
function getAbsoluteEntryModulePaths(chunks) {
|
|
16109
|
-
const absoluteEntryModulePaths = [];
|
|
16110
|
-
for (const chunk of chunks) {
|
|
16111
|
-
for (const entryModule of chunk.entryModules) {
|
|
16112
|
-
if (isAbsolute(entryModule.id)) {
|
|
16113
|
-
absoluteEntryModulePaths.push(entryModule.id);
|
|
16114
|
-
}
|
|
16115
|
-
}
|
|
16116
|
-
}
|
|
16117
|
-
return absoluteEntryModulePaths;
|
|
16118
16194
|
}
|
|
16119
16195
|
function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
|
|
16120
16196
|
if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
|
|
@@ -16127,8 +16203,32 @@ function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
|
|
|
16127
16203
|
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'));
|
|
16128
16204
|
}
|
|
16129
16205
|
function getIncludedModules(modulesById) {
|
|
16130
|
-
|
|
16131
|
-
|
|
16206
|
+
const includedModules = [];
|
|
16207
|
+
for (const module of modulesById.values()) {
|
|
16208
|
+
if (module instanceof Module &&
|
|
16209
|
+
(module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0)) {
|
|
16210
|
+
includedModules.push(module);
|
|
16211
|
+
}
|
|
16212
|
+
}
|
|
16213
|
+
return includedModules;
|
|
16214
|
+
}
|
|
16215
|
+
function getAbsoluteEntryModulePaths(includedModules, preserveModules) {
|
|
16216
|
+
const absoluteEntryModulePaths = [];
|
|
16217
|
+
for (const module of includedModules) {
|
|
16218
|
+
if ((module.info.isEntry || preserveModules) && isAbsolute(module.id)) {
|
|
16219
|
+
absoluteEntryModulePaths.push(module.id);
|
|
16220
|
+
}
|
|
16221
|
+
}
|
|
16222
|
+
return absoluteEntryModulePaths;
|
|
16223
|
+
}
|
|
16224
|
+
function getExternalChunkByModule(modulesById, outputOptions, inputBase) {
|
|
16225
|
+
const externalChunkByModule = new Map();
|
|
16226
|
+
for (const module of modulesById.values()) {
|
|
16227
|
+
if (module instanceof ExternalModule) {
|
|
16228
|
+
externalChunkByModule.set(module, new ExternalChunk(module, outputOptions, inputBase));
|
|
16229
|
+
}
|
|
16230
|
+
}
|
|
16231
|
+
return externalChunkByModule;
|
|
16132
16232
|
}
|
|
16133
16233
|
function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
16134
16234
|
const existingAlias = manualChunkAliasByEntry.get(module);
|
|
@@ -21739,7 +21839,7 @@ async function findFile(file, preserveSymlinks) {
|
|
|
21739
21839
|
return file;
|
|
21740
21840
|
}
|
|
21741
21841
|
}
|
|
21742
|
-
catch
|
|
21842
|
+
catch {
|
|
21743
21843
|
// suppress
|
|
21744
21844
|
}
|
|
21745
21845
|
}
|
|
@@ -21762,21 +21862,6 @@ function throwPluginError(err, plugin, { hook, id } = {}) {
|
|
|
21762
21862
|
}
|
|
21763
21863
|
return error(err);
|
|
21764
21864
|
}
|
|
21765
|
-
const deprecatedHooks = [
|
|
21766
|
-
{ active: true, deprecated: 'resolveAssetUrl', replacement: 'resolveFileUrl' }
|
|
21767
|
-
];
|
|
21768
|
-
function warnDeprecatedHooks(plugins, options) {
|
|
21769
|
-
for (const { active, deprecated, replacement } of deprecatedHooks) {
|
|
21770
|
-
for (const plugin of plugins) {
|
|
21771
|
-
if (deprecated in plugin) {
|
|
21772
|
-
warnDeprecation({
|
|
21773
|
-
message: `The "${deprecated}" hook used by plugin ${plugin.name} is deprecated. The "${replacement}" hook should be used instead.`,
|
|
21774
|
-
plugin: plugin.name
|
|
21775
|
-
}, active, options);
|
|
21776
|
-
}
|
|
21777
|
-
}
|
|
21778
|
-
}
|
|
21779
|
-
}
|
|
21780
21865
|
|
|
21781
21866
|
function createPluginCache(cache) {
|
|
21782
21867
|
return {
|
|
@@ -21918,14 +22003,6 @@ async function transform(source, module, pluginDriver, warn) {
|
|
|
21918
22003
|
cache: customTransformCache
|
|
21919
22004
|
? pluginContext.cache
|
|
21920
22005
|
: getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
|
|
21921
|
-
emitAsset(name, source) {
|
|
21922
|
-
emittedFiles.push({ name, source, type: 'asset' });
|
|
21923
|
-
return pluginContext.emitAsset(name, source);
|
|
21924
|
-
},
|
|
21925
|
-
emitChunk(id, options) {
|
|
21926
|
-
emittedFiles.push({ id, name: options && options.name, type: 'chunk' });
|
|
21927
|
-
return pluginContext.emitChunk(id, options);
|
|
21928
|
-
},
|
|
21929
22006
|
emitFile(emittedFile) {
|
|
21930
22007
|
emittedFiles.push(emittedFile);
|
|
21931
22008
|
return pluginDriver.emitFile(emittedFile);
|
|
@@ -22089,13 +22166,11 @@ class ModuleLoader {
|
|
|
22089
22166
|
}));
|
|
22090
22167
|
}
|
|
22091
22168
|
async addModuleSource(id, importer, module) {
|
|
22092
|
-
timeStart('load modules', 3);
|
|
22093
22169
|
let source;
|
|
22094
22170
|
try {
|
|
22095
22171
|
source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await promises.readFile(id, 'utf8')); });
|
|
22096
22172
|
}
|
|
22097
22173
|
catch (err) {
|
|
22098
|
-
timeEnd('load modules', 3);
|
|
22099
22174
|
let msg = `Could not load ${id}`;
|
|
22100
22175
|
if (importer)
|
|
22101
22176
|
msg += ` (imported by ${relativeId(importer)})`;
|
|
@@ -22103,7 +22178,6 @@ class ModuleLoader {
|
|
|
22103
22178
|
err.message = msg;
|
|
22104
22179
|
throw err;
|
|
22105
22180
|
}
|
|
22106
|
-
timeEnd('load modules', 3);
|
|
22107
22181
|
const sourceDescription = typeof source === 'string'
|
|
22108
22182
|
? { code: source }
|
|
22109
22183
|
: source != null && typeof source === 'object' && typeof source.code === 'string'
|
|
@@ -22434,19 +22508,6 @@ class GlobalScope extends Scope$1 {
|
|
|
22434
22508
|
}
|
|
22435
22509
|
}
|
|
22436
22510
|
|
|
22437
|
-
function getDeprecatedContextHandler(handler, handlerName, newHandlerName, pluginName, activeDeprecation, options) {
|
|
22438
|
-
let deprecationWarningShown = false;
|
|
22439
|
-
return ((...args) => {
|
|
22440
|
-
if (!deprecationWarningShown) {
|
|
22441
|
-
deprecationWarningShown = true;
|
|
22442
|
-
warnDeprecation({
|
|
22443
|
-
message: `The "this.${handlerName}" plugin context function used by plugin ${pluginName} is deprecated. The "this.${newHandlerName}" plugin context function should be used instead.`,
|
|
22444
|
-
plugin: pluginName
|
|
22445
|
-
}, activeDeprecation, options);
|
|
22446
|
-
}
|
|
22447
|
-
return handler(...args);
|
|
22448
|
-
});
|
|
22449
|
-
}
|
|
22450
22511
|
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
22451
22512
|
let cacheable = true;
|
|
22452
22513
|
if (typeof plugin.cacheKey !== 'string') {
|
|
@@ -22478,19 +22539,14 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22478
22539
|
graph.watchFiles[id] = true;
|
|
22479
22540
|
},
|
|
22480
22541
|
cache: cacheInstance,
|
|
22481
|
-
emitAsset: getDeprecatedContextHandler((name, source) => fileEmitter.emitFile({ name, source, type: 'asset' }), 'emitAsset', 'emitFile', plugin.name, true, options),
|
|
22482
|
-
emitChunk: getDeprecatedContextHandler((id, options) => fileEmitter.emitFile({ id, name: options && options.name, type: 'chunk' }), 'emitChunk', 'emitFile', plugin.name, true, options),
|
|
22483
22542
|
emitFile: fileEmitter.emitFile.bind(fileEmitter),
|
|
22484
22543
|
error(err) {
|
|
22485
22544
|
return throwPluginError(err, plugin.name);
|
|
22486
22545
|
},
|
|
22487
|
-
getAssetFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getAssetFileName', 'getFileName', plugin.name, true, options),
|
|
22488
|
-
getChunkFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getChunkFileName', 'getFileName', plugin.name, true, options),
|
|
22489
22546
|
getFileName: fileEmitter.getFileName,
|
|
22490
22547
|
getModuleIds: () => graph.modulesById.keys(),
|
|
22491
22548
|
getModuleInfo: graph.getModuleInfo,
|
|
22492
22549
|
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
22493
|
-
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
22494
22550
|
load(resolvedId) {
|
|
22495
22551
|
return graph.moduleLoader.preloadModule(resolvedId);
|
|
22496
22552
|
},
|
|
@@ -22504,7 +22560,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22504
22560
|
warnDeprecation({
|
|
22505
22561
|
message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
|
|
22506
22562
|
plugin: plugin.name
|
|
22507
|
-
},
|
|
22563
|
+
}, true, options);
|
|
22508
22564
|
yield* moduleIds;
|
|
22509
22565
|
}
|
|
22510
22566
|
const moduleIds = graph.modulesById.keys();
|
|
@@ -22514,9 +22570,6 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22514
22570
|
resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
|
|
22515
22571
|
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22516
22572
|
},
|
|
22517
|
-
resolveId: getDeprecatedContextHandler((source, importer) => graph.moduleLoader
|
|
22518
|
-
.resolveId(source, importer, BLANK, undefined)
|
|
22519
|
-
.then(resolveId => resolveId && resolveId.id), 'resolveId', 'resolve', plugin.name, true, options),
|
|
22520
22573
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22521
22574
|
warn(warning) {
|
|
22522
22575
|
if (typeof warning === 'string')
|
|
@@ -22557,14 +22610,14 @@ class PluginDriver {
|
|
|
22557
22610
|
this.graph = graph;
|
|
22558
22611
|
this.options = options;
|
|
22559
22612
|
this.unfulfilledActions = new Set();
|
|
22560
|
-
warnDeprecatedHooks(userPlugins, options);
|
|
22561
22613
|
this.pluginCache = pluginCache;
|
|
22562
22614
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
22563
22615
|
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
22564
22616
|
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
22565
|
-
this.finaliseAssets = this.fileEmitter.
|
|
22617
|
+
this.finaliseAssets = this.fileEmitter.finaliseAssets.bind(this.fileEmitter);
|
|
22618
|
+
this.setChunkInformation = this.fileEmitter.setChunkInformation.bind(this.fileEmitter);
|
|
22566
22619
|
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
|
|
22567
|
-
this.plugins =
|
|
22620
|
+
this.plugins = (basePluginDriver ? basePluginDriver.plugins : []).concat(userPlugins);
|
|
22568
22621
|
const existingPluginNames = new Set();
|
|
22569
22622
|
this.pluginContexts = new Map(this.plugins.map(plugin => [
|
|
22570
22623
|
plugin,
|
|
@@ -22849,10 +22902,10 @@ class Graph {
|
|
|
22849
22902
|
timeStart('generate module graph', 2);
|
|
22850
22903
|
await this.generateModuleGraph();
|
|
22851
22904
|
timeEnd('generate module graph', 2);
|
|
22852
|
-
timeStart('sort modules', 2);
|
|
22905
|
+
timeStart('sort and bind modules', 2);
|
|
22853
22906
|
this.phase = BuildPhase.ANALYSE;
|
|
22854
22907
|
this.sortModules();
|
|
22855
|
-
timeEnd('sort modules', 2);
|
|
22908
|
+
timeEnd('sort and bind modules', 2);
|
|
22856
22909
|
timeStart('mark included statements', 2);
|
|
22857
22910
|
this.includeStatements();
|
|
22858
22911
|
timeEnd('mark included statements', 2);
|
|
@@ -23126,7 +23179,7 @@ const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
|
23126
23179
|
const getHashFromObjectOption = (optionName) => optionName.split('.').join('').toLowerCase();
|
|
23127
23180
|
|
|
23128
23181
|
function normalizeInputOptions(config) {
|
|
23129
|
-
var _a, _b, _c;
|
|
23182
|
+
var _a, _b, _c, _d;
|
|
23130
23183
|
// These are options that may trigger special warnings or behaviour later
|
|
23131
23184
|
// if the user did not select an explicit value
|
|
23132
23185
|
const unsetOptions = new Set();
|
|
@@ -23143,7 +23196,7 @@ function normalizeInputOptions(config) {
|
|
|
23143
23196
|
external: getIdMatcher(config.external),
|
|
23144
23197
|
inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
|
|
23145
23198
|
input: getInput(config),
|
|
23146
|
-
makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c :
|
|
23199
|
+
makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : 'ifRelativeSource',
|
|
23147
23200
|
manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
|
|
23148
23201
|
maxParallelFileOps,
|
|
23149
23202
|
maxParallelFileReads: maxParallelFileOps,
|
|
@@ -23151,12 +23204,12 @@ function normalizeInputOptions(config) {
|
|
|
23151
23204
|
onwarn,
|
|
23152
23205
|
perf: config.perf || false,
|
|
23153
23206
|
plugins: ensureArray(config.plugins),
|
|
23154
|
-
preserveEntrySignatures:
|
|
23207
|
+
preserveEntrySignatures: (_d = config.preserveEntrySignatures) !== null && _d !== void 0 ? _d : 'exports-only',
|
|
23155
23208
|
preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
|
|
23156
23209
|
preserveSymlinks: config.preserveSymlinks || false,
|
|
23157
23210
|
shimMissingExports: config.shimMissingExports || false,
|
|
23158
23211
|
strictDeprecations,
|
|
23159
|
-
treeshake: getTreeshake(config
|
|
23212
|
+
treeshake: getTreeshake(config)
|
|
23160
23213
|
};
|
|
23161
23214
|
warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', options.onwarn, /^(output)$/);
|
|
23162
23215
|
return { options, unsetOptions };
|
|
@@ -23212,7 +23265,7 @@ const getIdMatcher = (option) => {
|
|
|
23212
23265
|
const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
|
|
23213
23266
|
const configInlineDynamicImports = config.inlineDynamicImports;
|
|
23214
23267
|
if (configInlineDynamicImports) {
|
|
23215
|
-
warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.',
|
|
23268
|
+
warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', true, warn, strictDeprecations);
|
|
23216
23269
|
}
|
|
23217
23270
|
return configInlineDynamicImports;
|
|
23218
23271
|
};
|
|
@@ -23223,7 +23276,7 @@ const getInput = (config) => {
|
|
|
23223
23276
|
const getManualChunks$1 = (config, warn, strictDeprecations) => {
|
|
23224
23277
|
const configManualChunks = config.manualChunks;
|
|
23225
23278
|
if (configManualChunks) {
|
|
23226
|
-
warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.',
|
|
23279
|
+
warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', true, warn, strictDeprecations);
|
|
23227
23280
|
}
|
|
23228
23281
|
return configManualChunks;
|
|
23229
23282
|
};
|
|
@@ -23231,7 +23284,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
|
23231
23284
|
var _a;
|
|
23232
23285
|
const maxParallelFileReads = config.maxParallelFileReads;
|
|
23233
23286
|
if (typeof maxParallelFileReads === 'number') {
|
|
23234
|
-
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.',
|
|
23287
|
+
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
|
|
23235
23288
|
}
|
|
23236
23289
|
const maxParallelFileOps = (_a = config.maxParallelFileOps) !== null && _a !== void 0 ? _a : maxParallelFileReads;
|
|
23237
23290
|
if (typeof maxParallelFileOps === 'number') {
|
|
@@ -23255,35 +23308,23 @@ const getModuleContext = (config, context) => {
|
|
|
23255
23308
|
}
|
|
23256
23309
|
return () => context;
|
|
23257
23310
|
};
|
|
23258
|
-
const getPreserveEntrySignatures = (config, unsetOptions) => {
|
|
23259
|
-
const configPreserveEntrySignatures = config.preserveEntrySignatures;
|
|
23260
|
-
if (configPreserveEntrySignatures == null) {
|
|
23261
|
-
unsetOptions.add('preserveEntrySignatures');
|
|
23262
|
-
}
|
|
23263
|
-
return configPreserveEntrySignatures !== null && configPreserveEntrySignatures !== void 0 ? configPreserveEntrySignatures : 'strict';
|
|
23264
|
-
};
|
|
23265
23311
|
const getPreserveModules$1 = (config, warn, strictDeprecations) => {
|
|
23266
23312
|
const configPreserveModules = config.preserveModules;
|
|
23267
23313
|
if (configPreserveModules) {
|
|
23268
|
-
warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.',
|
|
23314
|
+
warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', true, warn, strictDeprecations);
|
|
23269
23315
|
}
|
|
23270
23316
|
return configPreserveModules;
|
|
23271
23317
|
};
|
|
23272
|
-
const getTreeshake = (config
|
|
23318
|
+
const getTreeshake = (config) => {
|
|
23273
23319
|
const configTreeshake = config.treeshake;
|
|
23274
23320
|
if (configTreeshake === false) {
|
|
23275
23321
|
return false;
|
|
23276
23322
|
}
|
|
23277
23323
|
const configWithPreset = getOptionWithPreset(config.treeshake, treeshakePresets, 'treeshake', 'false, true, ');
|
|
23278
|
-
if (typeof configWithPreset.pureExternalModules !== 'undefined') {
|
|
23279
|
-
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);
|
|
23280
|
-
}
|
|
23281
23324
|
return {
|
|
23282
23325
|
annotations: configWithPreset.annotations !== false,
|
|
23283
23326
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
23284
|
-
moduleSideEffects:
|
|
23285
|
-
? getHasModuleSideEffects(configTreeshake.moduleSideEffects, configTreeshake.pureExternalModules)
|
|
23286
|
-
: getHasModuleSideEffects(configWithPreset.moduleSideEffects, undefined),
|
|
23327
|
+
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
23287
23328
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
23288
23329
|
? 'always'
|
|
23289
23330
|
: configWithPreset.propertyReadSideEffects !== false,
|
|
@@ -23291,7 +23332,7 @@ const getTreeshake = (config, warn, strictDeprecations) => {
|
|
|
23291
23332
|
unknownGlobalSideEffects: configWithPreset.unknownGlobalSideEffects !== false
|
|
23292
23333
|
};
|
|
23293
23334
|
};
|
|
23294
|
-
const getHasModuleSideEffects = (moduleSideEffectsOption
|
|
23335
|
+
const getHasModuleSideEffects = (moduleSideEffectsOption) => {
|
|
23295
23336
|
if (typeof moduleSideEffectsOption === 'boolean') {
|
|
23296
23337
|
return () => moduleSideEffectsOption;
|
|
23297
23338
|
}
|
|
@@ -23308,8 +23349,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules) =
|
|
|
23308
23349
|
if (moduleSideEffectsOption) {
|
|
23309
23350
|
error(errInvalidOption('treeshake.moduleSideEffects', 'treeshake', 'please use one of false, "no-external", a function or an array'));
|
|
23310
23351
|
}
|
|
23311
|
-
|
|
23312
|
-
return (id, external) => !(external && isPureExternalModule(id));
|
|
23352
|
+
return () => true;
|
|
23313
23353
|
};
|
|
23314
23354
|
|
|
23315
23355
|
// https://datatracker.ietf.org/doc/html/rfc2396
|
|
@@ -23353,7 +23393,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23353
23393
|
chunkFileNames: (_b = config.chunkFileNames) !== null && _b !== void 0 ? _b : '[name]-[hash].js',
|
|
23354
23394
|
compact,
|
|
23355
23395
|
dir: getDir(config, file),
|
|
23356
|
-
dynamicImportFunction: getDynamicImportFunction(config, inputOptions),
|
|
23396
|
+
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
23357
23397
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23358
23398
|
esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : true,
|
|
23359
23399
|
exports: getExports(config, unsetOptions),
|
|
@@ -23459,7 +23499,7 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
|
|
|
23459
23499
|
const getPreferConst = (config, inputOptions) => {
|
|
23460
23500
|
const configPreferConst = config.preferConst;
|
|
23461
23501
|
if (configPreferConst != null) {
|
|
23462
|
-
warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`,
|
|
23502
|
+
warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`, true, inputOptions);
|
|
23463
23503
|
}
|
|
23464
23504
|
return !!configPreferConst;
|
|
23465
23505
|
};
|
|
@@ -23514,10 +23554,13 @@ const getDir = (config, file) => {
|
|
|
23514
23554
|
}
|
|
23515
23555
|
return dir;
|
|
23516
23556
|
};
|
|
23517
|
-
const getDynamicImportFunction = (config, inputOptions) => {
|
|
23557
|
+
const getDynamicImportFunction = (config, inputOptions, format) => {
|
|
23518
23558
|
const configDynamicImportFunction = config.dynamicImportFunction;
|
|
23519
23559
|
if (configDynamicImportFunction) {
|
|
23520
|
-
warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`,
|
|
23560
|
+
warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, true, inputOptions);
|
|
23561
|
+
if (format !== 'es') {
|
|
23562
|
+
inputOptions.onwarn(errInvalidOption('output.dynamicImportFunction', 'outputdynamicImportFunction', 'this option is ignored for formats other than "es"'));
|
|
23563
|
+
}
|
|
23521
23564
|
}
|
|
23522
23565
|
return configDynamicImportFunction;
|
|
23523
23566
|
};
|
|
@@ -23544,7 +23587,7 @@ const getGeneratedCode = (config, preferConst) => {
|
|
|
23544
23587
|
arrowFunctions: configWithPreset.arrowFunctions === true,
|
|
23545
23588
|
constBindings: configWithPreset.constBindings === true || preferConst,
|
|
23546
23589
|
objectShorthand: configWithPreset.objectShorthand === true,
|
|
23547
|
-
reservedNamesAsProps: configWithPreset.reservedNamesAsProps
|
|
23590
|
+
reservedNamesAsProps: configWithPreset.reservedNamesAsProps !== false,
|
|
23548
23591
|
symbols: configWithPreset.symbols === true
|
|
23549
23592
|
};
|
|
23550
23593
|
};
|
|
@@ -23576,7 +23619,7 @@ const getInterop = (config, inputOptions) => {
|
|
|
23576
23619
|
warnDeprecation({
|
|
23577
23620
|
message: `The boolean value "${interop}" for the "output.interop" option is deprecated. Use ${interop ? '"auto"' : '"esModule", "default" or "defaultOnly"'} instead.`,
|
|
23578
23621
|
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
23579
|
-
},
|
|
23622
|
+
}, true, inputOptions);
|
|
23580
23623
|
}
|
|
23581
23624
|
}
|
|
23582
23625
|
return interop;
|
|
@@ -23608,7 +23651,7 @@ const getMinifyInternalExports = (config, format, compact) => { var _a; return (
|
|
|
23608
23651
|
const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
23609
23652
|
const configNamespaceToStringTag = config.namespaceToStringTag;
|
|
23610
23653
|
if (configNamespaceToStringTag != null) {
|
|
23611
|
-
warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`,
|
|
23654
|
+
warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, true, inputOptions);
|
|
23612
23655
|
return configNamespaceToStringTag;
|
|
23613
23656
|
}
|
|
23614
23657
|
return generatedCode.symbols || false;
|
|
@@ -23637,7 +23680,9 @@ async function rollupInternal(rawInputOptions, watcher) {
|
|
|
23637
23680
|
timeStart('BUILD', 1);
|
|
23638
23681
|
await catchUnfinishedHookActions(graph.pluginDriver, async () => {
|
|
23639
23682
|
try {
|
|
23683
|
+
timeStart('initialize', 2);
|
|
23640
23684
|
await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
|
|
23685
|
+
timeEnd('initialize', 2);
|
|
23641
23686
|
await graph.build();
|
|
23642
23687
|
}
|
|
23643
23688
|
catch (err) {
|
|
@@ -23707,6 +23752,7 @@ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutput
|
|
|
23707
23752
|
const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
|
|
23708
23753
|
const generated = await bundle.generate(isWrite);
|
|
23709
23754
|
if (isWrite) {
|
|
23755
|
+
timeStart('WRITE', 1);
|
|
23710
23756
|
if (!outputOptions.dir && !outputOptions.file) {
|
|
23711
23757
|
return error({
|
|
23712
23758
|
code: 'MISSING_OPTION',
|
|
@@ -23715,6 +23761,7 @@ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutput
|
|
|
23715
23761
|
}
|
|
23716
23762
|
await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
|
|
23717
23763
|
await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
|
|
23764
|
+
timeEnd('WRITE', 1);
|
|
23718
23765
|
}
|
|
23719
23766
|
return createOutput(generated);
|
|
23720
23767
|
});
|