rollup 2.45.0 → 2.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/bin/rollup +3 -3
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +197 -132
- package/dist/es/shared/watch.js +3 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.d.ts +2 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +8 -18
- package/dist/shared/mergeOptions.js +3 -2
- package/dist/shared/rollup.js +187 -121
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +2 -3
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.47.0
|
|
4
|
+
Tue, 04 May 2021 05:02:40 GMT - commit 6cc9d6b5137dd80fef9618e97471f89f8fbc54ad
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -14,7 +14,7 @@ import * as fs from 'fs';
|
|
|
14
14
|
import { lstatSync, realpathSync, readdirSync } from 'fs';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
|
|
17
|
-
var version$1 = "2.
|
|
17
|
+
var version$1 = "2.47.0";
|
|
18
18
|
|
|
19
19
|
var charToInteger = {};
|
|
20
20
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -4351,14 +4351,17 @@ class NamespaceVariable extends Variable {
|
|
|
4351
4351
|
this.references.push(identifier);
|
|
4352
4352
|
this.name = identifier.name;
|
|
4353
4353
|
}
|
|
4354
|
-
|
|
4355
|
-
// build fails due to an illegal namespace reassignment or MemberExpression already forwards
|
|
4356
|
-
// the reassignment to the right variable. This means we lost track of this variable and thus
|
|
4357
|
-
// need to reassign all exports.
|
|
4358
|
-
deoptimizePath() {
|
|
4354
|
+
deoptimizePath(path) {
|
|
4359
4355
|
const memberVariables = this.getMemberVariables();
|
|
4360
|
-
|
|
4361
|
-
|
|
4356
|
+
const memberPath = path.length <= 1 ? UNKNOWN_PATH : path.slice(1);
|
|
4357
|
+
const key = path[0];
|
|
4358
|
+
if (typeof key !== 'string') {
|
|
4359
|
+
for (const key of Object.keys(memberVariables)) {
|
|
4360
|
+
memberVariables[key].deoptimizePath(memberPath);
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
else {
|
|
4364
|
+
memberVariables[key].deoptimizePath(memberPath);
|
|
4362
4365
|
}
|
|
4363
4366
|
}
|
|
4364
4367
|
getMemberVariables() {
|
|
@@ -4368,7 +4371,10 @@ class NamespaceVariable extends Variable {
|
|
|
4368
4371
|
const memberVariables = Object.create(null);
|
|
4369
4372
|
for (const name of this.context.getExports().concat(this.context.getReexports())) {
|
|
4370
4373
|
if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
|
|
4371
|
-
|
|
4374
|
+
const exportedVariable = this.context.traceExport(name);
|
|
4375
|
+
if (exportedVariable) {
|
|
4376
|
+
memberVariables[name] = exportedVariable;
|
|
4377
|
+
}
|
|
4372
4378
|
}
|
|
4373
4379
|
}
|
|
4374
4380
|
return (this.memberVariables = memberVariables);
|
|
@@ -4541,6 +4547,32 @@ function normalize(path) {
|
|
|
4541
4547
|
return path.replace(/\\/g, '/');
|
|
4542
4548
|
}
|
|
4543
4549
|
|
|
4550
|
+
function printQuotedStringList(list, verbs) {
|
|
4551
|
+
const isSingleItem = list.length <= 1;
|
|
4552
|
+
const quotedList = list.map(item => `"${item}"`);
|
|
4553
|
+
let output = isSingleItem
|
|
4554
|
+
? quotedList[0]
|
|
4555
|
+
: `${quotedList.slice(0, -1).join(', ')} and ${quotedList.slice(-1)[0]}`;
|
|
4556
|
+
if (verbs) {
|
|
4557
|
+
output += ` ${isSingleItem ? verbs[0] : verbs[1]}`;
|
|
4558
|
+
}
|
|
4559
|
+
return output;
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4562
|
+
function getAliasName(id) {
|
|
4563
|
+
const base = basename(id);
|
|
4564
|
+
return base.substr(0, base.length - extname(id).length);
|
|
4565
|
+
}
|
|
4566
|
+
function relativeId(id) {
|
|
4567
|
+
if (!isAbsolute(id))
|
|
4568
|
+
return id;
|
|
4569
|
+
return relative$1(resolve(), id);
|
|
4570
|
+
}
|
|
4571
|
+
function isPathFragment(name) {
|
|
4572
|
+
// starting with "/", "./", "../", "C:/"
|
|
4573
|
+
return name[0] === '/' || name[0] === '.' && (name[1] === '/' || name[1] === '.') || isAbsolute(name);
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4544
4576
|
class ExternalModule {
|
|
4545
4577
|
constructor(options, id, hasModuleSideEffects, meta, renormalizeRenderPath) {
|
|
4546
4578
|
this.options = options;
|
|
@@ -4618,17 +4650,20 @@ class ExternalModule {
|
|
|
4618
4650
|
});
|
|
4619
4651
|
if (unused.length === 0)
|
|
4620
4652
|
return;
|
|
4621
|
-
const
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
.
|
|
4626
|
-
|
|
4653
|
+
const importersSet = new Set();
|
|
4654
|
+
for (const name of unused) {
|
|
4655
|
+
const { importers } = this.declarations[name].module;
|
|
4656
|
+
for (const importer of importers) {
|
|
4657
|
+
importersSet.add(importer);
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
const importersArray = [...importersSet];
|
|
4627
4661
|
this.options.onwarn({
|
|
4628
4662
|
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
4629
|
-
message: `${
|
|
4663
|
+
message: `${printQuotedStringList(unused, ['is', 'are'])} imported from external module "${this.id}" but never used in ${printQuotedStringList(importersArray.map(importer => relativeId(importer)))}.`,
|
|
4630
4664
|
names: unused,
|
|
4631
|
-
source: this.id
|
|
4665
|
+
source: this.id,
|
|
4666
|
+
sources: importersArray
|
|
4632
4667
|
});
|
|
4633
4668
|
}
|
|
4634
4669
|
}
|
|
@@ -4949,15 +4984,9 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
4949
4984
|
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins);
|
|
4950
4985
|
if (!externalBuiltins.length)
|
|
4951
4986
|
return;
|
|
4952
|
-
const detail = externalBuiltins.length === 1
|
|
4953
|
-
? `module ('${externalBuiltins[0]}')`
|
|
4954
|
-
: `modules (${externalBuiltins
|
|
4955
|
-
.slice(0, -1)
|
|
4956
|
-
.map(name => `'${name}'`)
|
|
4957
|
-
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
4958
4987
|
warn({
|
|
4959
4988
|
code: 'MISSING_NODE_BUILTINS',
|
|
4960
|
-
message: `Creating a browser bundle that depends on Node.js built-in ${
|
|
4989
|
+
message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills`,
|
|
4961
4990
|
modules: externalBuiltins
|
|
4962
4991
|
});
|
|
4963
4992
|
}
|
|
@@ -5192,31 +5221,6 @@ function getCodeFrame(source, line, column) {
|
|
|
5192
5221
|
.join('\n');
|
|
5193
5222
|
}
|
|
5194
5223
|
|
|
5195
|
-
function sanitizeFileName(name) {
|
|
5196
|
-
const match = /^[a-z]:/i.exec(name);
|
|
5197
|
-
const driveLetter = match ? match[0] : "";
|
|
5198
|
-
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
|
|
5199
|
-
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
|
|
5200
|
-
return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_');
|
|
5201
|
-
}
|
|
5202
|
-
|
|
5203
|
-
function getAliasName(id) {
|
|
5204
|
-
const base = basename(id);
|
|
5205
|
-
return base.substr(0, base.length - extname(id).length);
|
|
5206
|
-
}
|
|
5207
|
-
function relativeId(id) {
|
|
5208
|
-
if (!isAbsolute(id))
|
|
5209
|
-
return id;
|
|
5210
|
-
return relative$1(resolve(), id);
|
|
5211
|
-
}
|
|
5212
|
-
function isPlainPathFragment(name) {
|
|
5213
|
-
// not starting with "/", "./", "../"
|
|
5214
|
-
return (name[0] !== '/' &&
|
|
5215
|
-
!(name[0] === '.' && (name[1] === '/' || name[1] === '.')) &&
|
|
5216
|
-
sanitizeFileName(name) === name &&
|
|
5217
|
-
!isAbsolute(name));
|
|
5218
|
-
}
|
|
5219
|
-
|
|
5220
5224
|
function error(base) {
|
|
5221
5225
|
if (!(base instanceof Error))
|
|
5222
5226
|
base = Object.assign(new Error(base.message), base);
|
|
@@ -5265,6 +5269,7 @@ var Errors;
|
|
|
5265
5269
|
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
5266
5270
|
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
5267
5271
|
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
5272
|
+
Errors["AMBIGUOUS_EXTERNAL_NAMESPACES"] = "AMBIGUOUS_EXTERNAL_NAMESPACES";
|
|
5268
5273
|
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
5269
5274
|
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
5270
5275
|
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
@@ -5430,9 +5435,7 @@ function errImplicitDependantIsNotIncluded(module) {
|
|
|
5430
5435
|
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
5431
5436
|
return {
|
|
5432
5437
|
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5433
|
-
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before
|
|
5434
|
-
? implicitDependencies[0]
|
|
5435
|
-
: `${implicitDependencies.slice(0, -1).join('", "')}" and "${implicitDependencies.slice(-1)[0]}`}" is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.`
|
|
5438
|
+
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before ${printQuotedStringList(implicitDependencies)} is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.`
|
|
5436
5439
|
};
|
|
5437
5440
|
}
|
|
5438
5441
|
function errMixedExport(facadeModuleId, name) {
|
|
@@ -5446,12 +5449,21 @@ function errMixedExport(facadeModuleId, name) {
|
|
|
5446
5449
|
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
5447
5450
|
return {
|
|
5448
5451
|
code: Errors.NAMESPACE_CONFLICT,
|
|
5449
|
-
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports
|
|
5452
|
+
message: `Conflicting namespaces: "${relativeId(reexportingModule.id)}" re-exports "${name}" from both "${relativeId(reexportingModule.exportsAll[name])}" and "${relativeId(additionalExportAllModule.exportsAll[name])}" (will be ignored)`,
|
|
5450
5453
|
name,
|
|
5451
5454
|
reexporter: reexportingModule.id,
|
|
5452
5455
|
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
5453
5456
|
};
|
|
5454
5457
|
}
|
|
5458
|
+
function errAmbiguousExternalNamespaces(name, reexportingModule, usedExternalModule, externalModules) {
|
|
5459
|
+
return {
|
|
5460
|
+
code: Errors.AMBIGUOUS_EXTERNAL_NAMESPACES,
|
|
5461
|
+
message: `Ambiguous external namespace resolution: "${relativeId(reexportingModule)}" re-exports "${name}" from one of the external modules ${printQuotedStringList(externalModules.map(module => relativeId(module)))}, guessing "${relativeId(usedExternalModule)}".`,
|
|
5462
|
+
name,
|
|
5463
|
+
reexporter: reexportingModule,
|
|
5464
|
+
sources: externalModules
|
|
5465
|
+
};
|
|
5466
|
+
}
|
|
5455
5467
|
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
5456
5468
|
return {
|
|
5457
5469
|
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
@@ -6517,15 +6529,9 @@ class MemberExpression extends NodeBase {
|
|
|
6517
6529
|
if (this.variable) {
|
|
6518
6530
|
this.variable.deoptimizePath(path);
|
|
6519
6531
|
}
|
|
6520
|
-
else {
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
this.object.deoptimizePath(UNKNOWN_PATH);
|
|
6524
|
-
}
|
|
6525
|
-
else {
|
|
6526
|
-
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6527
|
-
this.object.deoptimizePath([propertyKey, ...path]);
|
|
6528
|
-
}
|
|
6532
|
+
else if (!this.replacement) {
|
|
6533
|
+
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6534
|
+
this.object.deoptimizePath([this.getPropertyKey(), ...path]);
|
|
6529
6535
|
}
|
|
6530
6536
|
}
|
|
6531
6537
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -9523,8 +9529,11 @@ function findSourceMappingURLComments(ast, code) {
|
|
|
9523
9529
|
}
|
|
9524
9530
|
let sourcemappingUrlMatch;
|
|
9525
9531
|
const interStatmentCode = code.slice(start, end);
|
|
9526
|
-
while (sourcemappingUrlMatch = SOURCEMAPPING_URL_COMMENT_RE.exec(interStatmentCode)) {
|
|
9527
|
-
ret.push([
|
|
9532
|
+
while ((sourcemappingUrlMatch = SOURCEMAPPING_URL_COMMENT_RE.exec(interStatmentCode))) {
|
|
9533
|
+
ret.push([
|
|
9534
|
+
start + sourcemappingUrlMatch.index,
|
|
9535
|
+
start + SOURCEMAPPING_URL_COMMENT_RE.lastIndex
|
|
9536
|
+
]);
|
|
9528
9537
|
}
|
|
9529
9538
|
};
|
|
9530
9539
|
let prevStmtEnd = 0;
|
|
@@ -9535,7 +9544,7 @@ function findSourceMappingURLComments(ast, code) {
|
|
|
9535
9544
|
addCommentsPos(prevStmtEnd, code.length);
|
|
9536
9545
|
return ret;
|
|
9537
9546
|
}
|
|
9538
|
-
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9547
|
+
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map(), skipExternalNamespaceReexports) {
|
|
9539
9548
|
const searchedModules = searchedNamesAndModules.get(name);
|
|
9540
9549
|
if (searchedModules) {
|
|
9541
9550
|
if (searchedModules.has(target)) {
|
|
@@ -9546,7 +9555,12 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
|
|
|
9546
9555
|
else {
|
|
9547
9556
|
searchedNamesAndModules.set(name, new Set([target]));
|
|
9548
9557
|
}
|
|
9549
|
-
return target.getVariableForExportName(name,
|
|
9558
|
+
return target.getVariableForExportName(name, {
|
|
9559
|
+
importerForSideEffects,
|
|
9560
|
+
isExportAllSearch,
|
|
9561
|
+
searchedNamesAndModules,
|
|
9562
|
+
skipExternalNamespaceReexports
|
|
9563
|
+
});
|
|
9550
9564
|
}
|
|
9551
9565
|
function getAndExtendSideEffectModules(variable, module) {
|
|
9552
9566
|
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, () => new Set());
|
|
@@ -9611,6 +9625,7 @@ class Module {
|
|
|
9611
9625
|
this.exportAllModules = [];
|
|
9612
9626
|
this.exportNamesByVariable = null;
|
|
9613
9627
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
9628
|
+
this.namespaceReexportsByName = Object.create(null);
|
|
9614
9629
|
this.relevantDependencies = null;
|
|
9615
9630
|
this.syntheticExports = new Map();
|
|
9616
9631
|
this.syntheticNamespace = null;
|
|
@@ -9702,7 +9717,10 @@ class Module {
|
|
|
9702
9717
|
this.implicitlyLoadedAfter.size > 0) {
|
|
9703
9718
|
dependencyVariables = new Set(dependencyVariables);
|
|
9704
9719
|
for (const exportName of [...this.getReexports(), ...this.getExports()]) {
|
|
9705
|
-
|
|
9720
|
+
const exportedVariable = this.getVariableForExportName(exportName);
|
|
9721
|
+
if (exportedVariable) {
|
|
9722
|
+
dependencyVariables.add(exportedVariable);
|
|
9723
|
+
}
|
|
9706
9724
|
}
|
|
9707
9725
|
}
|
|
9708
9726
|
for (let variable of dependencyVariables) {
|
|
@@ -9807,7 +9825,7 @@ class Module {
|
|
|
9807
9825
|
}
|
|
9808
9826
|
return this.syntheticNamespace;
|
|
9809
9827
|
}
|
|
9810
|
-
getVariableForExportName(name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules) {
|
|
9828
|
+
getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, searchedNamesAndModules, skipExternalNamespaceReexports } = EMPTY_OBJECT) {
|
|
9811
9829
|
if (name[0] === '*') {
|
|
9812
9830
|
if (name.length === 1) {
|
|
9813
9831
|
// export * from './other'
|
|
@@ -9822,7 +9840,7 @@ class Module {
|
|
|
9822
9840
|
// export { foo } from './other'
|
|
9823
9841
|
const reexportDeclaration = this.reexportDescriptions[name];
|
|
9824
9842
|
if (reexportDeclaration) {
|
|
9825
|
-
const variable = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
|
|
9843
|
+
const variable = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, false);
|
|
9826
9844
|
if (!variable) {
|
|
9827
9845
|
return this.error(errMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
|
|
9828
9846
|
}
|
|
@@ -9845,20 +9863,11 @@ class Module {
|
|
|
9845
9863
|
return variable;
|
|
9846
9864
|
}
|
|
9847
9865
|
if (name !== 'default') {
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
return declaration;
|
|
9854
|
-
}
|
|
9855
|
-
if (!foundSyntheticDeclaration) {
|
|
9856
|
-
foundSyntheticDeclaration = declaration;
|
|
9857
|
-
}
|
|
9858
|
-
}
|
|
9859
|
-
}
|
|
9860
|
-
if (foundSyntheticDeclaration) {
|
|
9861
|
-
return foundSyntheticDeclaration;
|
|
9866
|
+
const foundNamespaceReexport = name in this.namespaceReexportsByName
|
|
9867
|
+
? this.namespaceReexportsByName[name]
|
|
9868
|
+
: (this.namespaceReexportsByName[name] = this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports));
|
|
9869
|
+
if (foundNamespaceReexport) {
|
|
9870
|
+
return foundNamespaceReexport;
|
|
9862
9871
|
}
|
|
9863
9872
|
}
|
|
9864
9873
|
if (this.info.syntheticNamedExports) {
|
|
@@ -9906,12 +9915,14 @@ class Module {
|
|
|
9906
9915
|
}
|
|
9907
9916
|
for (const name of this.getReexports()) {
|
|
9908
9917
|
const variable = this.getVariableForExportName(name);
|
|
9909
|
-
variable
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
variable
|
|
9918
|
+
if (variable) {
|
|
9919
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
9920
|
+
if (!variable.included) {
|
|
9921
|
+
this.includeVariable(variable);
|
|
9922
|
+
}
|
|
9923
|
+
if (variable instanceof ExternalVariable) {
|
|
9924
|
+
variable.module.reexported = true;
|
|
9925
|
+
}
|
|
9915
9926
|
}
|
|
9916
9927
|
}
|
|
9917
9928
|
if (includeNamespaceMembers) {
|
|
@@ -10050,7 +10061,9 @@ class Module {
|
|
|
10050
10061
|
if (otherModule instanceof Module && importDeclaration.name === '*') {
|
|
10051
10062
|
return otherModule.namespace;
|
|
10052
10063
|
}
|
|
10053
|
-
const declaration = otherModule.getVariableForExportName(importDeclaration.name,
|
|
10064
|
+
const declaration = otherModule.getVariableForExportName(importDeclaration.name, {
|
|
10065
|
+
importerForSideEffects: importerForSideEffects || this
|
|
10066
|
+
});
|
|
10054
10067
|
if (!declaration) {
|
|
10055
10068
|
return this.error(errMissingExport(importDeclaration.name, this.id, otherModule.id), importDeclaration.start);
|
|
10056
10069
|
}
|
|
@@ -10248,6 +10261,42 @@ class Module {
|
|
|
10248
10261
|
addSideEffectDependencies(this.dependencies);
|
|
10249
10262
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
10250
10263
|
}
|
|
10264
|
+
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports = false) {
|
|
10265
|
+
let foundSyntheticDeclaration = null;
|
|
10266
|
+
const skipExternalNamespaceValues = new Set([true, skipExternalNamespaceReexports]);
|
|
10267
|
+
for (const skipExternalNamespaces of skipExternalNamespaceValues) {
|
|
10268
|
+
const foundDeclarations = new Set();
|
|
10269
|
+
for (const module of this.exportAllModules) {
|
|
10270
|
+
if (module instanceof Module || !skipExternalNamespaces) {
|
|
10271
|
+
const declaration = getVariableForExportNameRecursive(module, name, importerForSideEffects, true, searchedNamesAndModules, skipExternalNamespaces);
|
|
10272
|
+
if (declaration) {
|
|
10273
|
+
if (!(declaration instanceof SyntheticNamedExportVariable)) {
|
|
10274
|
+
foundDeclarations.add(declaration);
|
|
10275
|
+
}
|
|
10276
|
+
else if (!foundSyntheticDeclaration) {
|
|
10277
|
+
foundSyntheticDeclaration = declaration;
|
|
10278
|
+
}
|
|
10279
|
+
}
|
|
10280
|
+
}
|
|
10281
|
+
}
|
|
10282
|
+
if (foundDeclarations.size === 1) {
|
|
10283
|
+
return [...foundDeclarations][0];
|
|
10284
|
+
}
|
|
10285
|
+
if (foundDeclarations.size > 1) {
|
|
10286
|
+
if (skipExternalNamespaces) {
|
|
10287
|
+
return null;
|
|
10288
|
+
}
|
|
10289
|
+
const foundDeclarationList = [...foundDeclarations];
|
|
10290
|
+
const usedDeclaration = foundDeclarationList[0];
|
|
10291
|
+
this.options.onwarn(errAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
|
|
10292
|
+
return usedDeclaration;
|
|
10293
|
+
}
|
|
10294
|
+
}
|
|
10295
|
+
if (foundSyntheticDeclaration) {
|
|
10296
|
+
return foundSyntheticDeclaration;
|
|
10297
|
+
}
|
|
10298
|
+
return null;
|
|
10299
|
+
}
|
|
10251
10300
|
includeAndGetAdditionalMergedNamespaces() {
|
|
10252
10301
|
const mergedNamespaces = [];
|
|
10253
10302
|
for (const module of this.exportAllModules) {
|
|
@@ -10787,14 +10836,14 @@ function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemap
|
|
|
10787
10836
|
}
|
|
10788
10837
|
|
|
10789
10838
|
function renderNamePattern(pattern, patternName, replacements) {
|
|
10790
|
-
if (
|
|
10791
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths
|
|
10839
|
+
if (isPathFragment(pattern))
|
|
10840
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths.`));
|
|
10792
10841
|
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
10793
10842
|
if (!replacements.hasOwnProperty(type)) {
|
|
10794
10843
|
return error(errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`));
|
|
10795
10844
|
}
|
|
10796
10845
|
const replacement = replacements[type]();
|
|
10797
|
-
if (
|
|
10846
|
+
if (isPathFragment(replacement))
|
|
10798
10847
|
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
10799
10848
|
return replacement;
|
|
10800
10849
|
});
|
|
@@ -10849,6 +10898,7 @@ class Chunk {
|
|
|
10849
10898
|
this.dependencies = new Set();
|
|
10850
10899
|
this.dynamicDependencies = new Set();
|
|
10851
10900
|
this.dynamicEntryModules = [];
|
|
10901
|
+
this.dynamicName = null;
|
|
10852
10902
|
this.exportNamesByVariable = new Map();
|
|
10853
10903
|
this.exports = new Set();
|
|
10854
10904
|
this.exportsByName = Object.create(null);
|
|
@@ -11013,7 +11063,7 @@ class Chunk {
|
|
|
11013
11063
|
this.facadeModule = module;
|
|
11014
11064
|
this.facadeChunkByModule.set(module, this);
|
|
11015
11065
|
this.strictFacade = true;
|
|
11016
|
-
this.
|
|
11066
|
+
this.dynamicName = getChunkNameFromModule(module);
|
|
11017
11067
|
}
|
|
11018
11068
|
else if (this.facadeModule === module &&
|
|
11019
11069
|
!this.strictFacade &&
|
|
@@ -11044,7 +11094,7 @@ class Chunk {
|
|
|
11044
11094
|
}
|
|
11045
11095
|
generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
|
|
11046
11096
|
const id = this.orderedModules[0].id;
|
|
11047
|
-
const sanitizedId = sanitizeFileName(id);
|
|
11097
|
+
const sanitizedId = this.outputOptions.sanitizeFileName(id);
|
|
11048
11098
|
let path;
|
|
11049
11099
|
if (isAbsolute(id)) {
|
|
11050
11100
|
const extension = extname(id);
|
|
@@ -11103,7 +11153,7 @@ class Chunk {
|
|
|
11103
11153
|
});
|
|
11104
11154
|
}
|
|
11105
11155
|
getChunkName() {
|
|
11106
|
-
return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
|
|
11156
|
+
return this.name || (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName()));
|
|
11107
11157
|
}
|
|
11108
11158
|
getExportNames() {
|
|
11109
11159
|
return (this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort()));
|
|
@@ -11362,7 +11412,7 @@ class Chunk {
|
|
|
11362
11412
|
this.fileName = fileName;
|
|
11363
11413
|
}
|
|
11364
11414
|
else {
|
|
11365
|
-
this.name = sanitizeFileName(name ||
|
|
11415
|
+
this.name = this.outputOptions.sanitizeFileName(name || getChunkNameFromModule(facadedModule));
|
|
11366
11416
|
}
|
|
11367
11417
|
}
|
|
11368
11418
|
checkCircularDependencyImport(variable, importingModule) {
|
|
@@ -11581,6 +11631,9 @@ class Chunk {
|
|
|
11581
11631
|
if (this.manualChunkAlias) {
|
|
11582
11632
|
return this.manualChunkAlias;
|
|
11583
11633
|
}
|
|
11634
|
+
if (this.dynamicName) {
|
|
11635
|
+
return this.dynamicName;
|
|
11636
|
+
}
|
|
11584
11637
|
if (this.fileName) {
|
|
11585
11638
|
return getAliasName(this.fileName);
|
|
11586
11639
|
}
|
|
@@ -11830,6 +11883,9 @@ class Chunk {
|
|
|
11830
11883
|
}
|
|
11831
11884
|
}
|
|
11832
11885
|
}
|
|
11886
|
+
function getChunkNameFromModule(module) {
|
|
11887
|
+
return module.chunkName || getAliasName(module.id);
|
|
11888
|
+
}
|
|
11833
11889
|
|
|
11834
11890
|
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
11835
11891
|
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -12086,11 +12142,11 @@ var BuildPhase;
|
|
|
12086
12142
|
BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
|
|
12087
12143
|
})(BuildPhase || (BuildPhase = {}));
|
|
12088
12144
|
|
|
12089
|
-
function generateAssetFileName(name, source,
|
|
12090
|
-
const emittedName = name || 'asset';
|
|
12091
|
-
return makeUnique(renderNamePattern(typeof
|
|
12092
|
-
?
|
|
12093
|
-
:
|
|
12145
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
12146
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
12147
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
12148
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
12149
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
12094
12150
|
hash() {
|
|
12095
12151
|
const hash = createHash();
|
|
12096
12152
|
hash.update(emittedName);
|
|
@@ -12101,7 +12157,7 @@ function generateAssetFileName(name, source, output) {
|
|
|
12101
12157
|
ext: () => extname(emittedName).substr(1),
|
|
12102
12158
|
extname: () => extname(emittedName),
|
|
12103
12159
|
name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length)
|
|
12104
|
-
}),
|
|
12160
|
+
}), bundle);
|
|
12105
12161
|
}
|
|
12106
12162
|
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
12107
12163
|
if (fileName in bundle) {
|
|
@@ -12119,7 +12175,7 @@ function hasValidType(emittedFile) {
|
|
|
12119
12175
|
}
|
|
12120
12176
|
function hasValidName(emittedFile) {
|
|
12121
12177
|
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
12122
|
-
return
|
|
12178
|
+
return !validatedName || typeof validatedName === 'string' && !isPathFragment(validatedName);
|
|
12123
12179
|
}
|
|
12124
12180
|
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
12125
12181
|
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
@@ -12145,8 +12201,9 @@ class FileEmitter {
|
|
|
12145
12201
|
constructor(graph, options, baseFileEmitter) {
|
|
12146
12202
|
this.graph = graph;
|
|
12147
12203
|
this.options = options;
|
|
12204
|
+
this.bundle = null;
|
|
12148
12205
|
this.facadeChunkByModule = null;
|
|
12149
|
-
this.
|
|
12206
|
+
this.outputOptions = null;
|
|
12150
12207
|
this.assertAssetsFinalized = () => {
|
|
12151
12208
|
for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
|
|
12152
12209
|
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
@@ -12158,7 +12215,7 @@ class FileEmitter {
|
|
|
12158
12215
|
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
12159
12216
|
}
|
|
12160
12217
|
if (!hasValidName(emittedFile)) {
|
|
12161
|
-
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths
|
|
12218
|
+
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}".`));
|
|
12162
12219
|
}
|
|
12163
12220
|
if (emittedFile.type === 'chunk') {
|
|
12164
12221
|
return this.emitChunk(emittedFile);
|
|
@@ -12189,27 +12246,25 @@ class FileEmitter {
|
|
|
12189
12246
|
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
12190
12247
|
}
|
|
12191
12248
|
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
12192
|
-
if (this.
|
|
12193
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.
|
|
12249
|
+
if (this.bundle) {
|
|
12250
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
12194
12251
|
}
|
|
12195
12252
|
else {
|
|
12196
12253
|
consumedFile.source = source;
|
|
12197
12254
|
}
|
|
12198
12255
|
};
|
|
12199
|
-
this.setOutputBundle = (outputBundle,
|
|
12200
|
-
this.
|
|
12201
|
-
|
|
12202
|
-
bundle: outputBundle
|
|
12203
|
-
};
|
|
12256
|
+
this.setOutputBundle = (outputBundle, outputOptions, facadeChunkByModule) => {
|
|
12257
|
+
this.outputOptions = outputOptions;
|
|
12258
|
+
this.bundle = outputBundle;
|
|
12204
12259
|
this.facadeChunkByModule = facadeChunkByModule;
|
|
12205
12260
|
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
12206
12261
|
if (emittedFile.fileName) {
|
|
12207
|
-
reserveFileNameInBundle(emittedFile.fileName, this.
|
|
12262
|
+
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
12208
12263
|
}
|
|
12209
12264
|
}
|
|
12210
12265
|
for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) {
|
|
12211
12266
|
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
12212
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.
|
|
12267
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
12213
12268
|
}
|
|
12214
12269
|
}
|
|
12215
12270
|
};
|
|
@@ -12243,12 +12298,12 @@ class FileEmitter {
|
|
|
12243
12298
|
type: 'asset'
|
|
12244
12299
|
};
|
|
12245
12300
|
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
12246
|
-
if (this.
|
|
12301
|
+
if (this.bundle) {
|
|
12247
12302
|
if (emittedAsset.fileName) {
|
|
12248
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.
|
|
12303
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
12249
12304
|
}
|
|
12250
12305
|
if (source !== undefined) {
|
|
12251
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.
|
|
12306
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
12252
12307
|
}
|
|
12253
12308
|
}
|
|
12254
12309
|
return referenceId;
|
|
@@ -12275,15 +12330,15 @@ class FileEmitter {
|
|
|
12275
12330
|
});
|
|
12276
12331
|
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
12277
12332
|
}
|
|
12278
|
-
finalizeAsset(consumedFile, source, referenceId,
|
|
12333
|
+
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
12279
12334
|
const fileName = consumedFile.fileName ||
|
|
12280
|
-
findExistingAssetFileNameWithSource(
|
|
12281
|
-
generateAssetFileName(consumedFile.name, source,
|
|
12335
|
+
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
12336
|
+
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
12282
12337
|
// We must not modify the original assets to avoid interaction between outputs
|
|
12283
12338
|
const assetWithFileName = { ...consumedFile, source, fileName };
|
|
12284
12339
|
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
12285
12340
|
const options = this.options;
|
|
12286
|
-
|
|
12341
|
+
bundle[fileName] = {
|
|
12287
12342
|
fileName,
|
|
12288
12343
|
name: consumedFile.name,
|
|
12289
12344
|
get isAsset() {
|
|
@@ -12337,7 +12392,7 @@ class Bundle {
|
|
|
12337
12392
|
async generate(isWrite) {
|
|
12338
12393
|
timeStart('GENERATE', 1);
|
|
12339
12394
|
const outputBundle = Object.create(null);
|
|
12340
|
-
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions
|
|
12395
|
+
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions, this.facadeChunkByModule);
|
|
12341
12396
|
try {
|
|
12342
12397
|
await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
|
|
12343
12398
|
timeStart('generate chunks', 2);
|
|
@@ -18571,7 +18626,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
18571
18626
|
cache: cacheInstance,
|
|
18572
18627
|
emitAsset: getDeprecatedContextHandler((name, source) => fileEmitter.emitFile({ type: 'asset', name, source }), 'emitAsset', 'emitFile', plugin.name, true, options),
|
|
18573
18628
|
emitChunk: getDeprecatedContextHandler((id, options) => fileEmitter.emitFile({ type: 'chunk', id, name: options && options.name }), 'emitChunk', 'emitFile', plugin.name, true, options),
|
|
18574
|
-
emitFile: fileEmitter.emitFile,
|
|
18629
|
+
emitFile: fileEmitter.emitFile.bind(fileEmitter),
|
|
18575
18630
|
error(err) {
|
|
18576
18631
|
return throwPluginError(err, plugin.name);
|
|
18577
18632
|
},
|
|
@@ -18646,10 +18701,10 @@ class PluginDriver {
|
|
|
18646
18701
|
warnDeprecatedHooks(userPlugins, options);
|
|
18647
18702
|
this.pluginCache = pluginCache;
|
|
18648
18703
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
18649
|
-
this.emitFile = this.fileEmitter.emitFile;
|
|
18650
|
-
this.getFileName = this.fileEmitter.getFileName;
|
|
18651
|
-
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized;
|
|
18652
|
-
this.setOutputBundle = this.fileEmitter.setOutputBundle;
|
|
18704
|
+
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
18705
|
+
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
18706
|
+
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized.bind(this.fileEmitter);
|
|
18707
|
+
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
|
|
18653
18708
|
this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []);
|
|
18654
18709
|
const existingPluginNames = new Set();
|
|
18655
18710
|
for (const plugin of this.plugins) {
|
|
@@ -19900,6 +19955,14 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules, w
|
|
|
19900
19955
|
return (id, external) => !(external && isPureExternalModule(id));
|
|
19901
19956
|
};
|
|
19902
19957
|
|
|
19958
|
+
function sanitizeFileName(name) {
|
|
19959
|
+
const match = /^[a-z]:/i.exec(name);
|
|
19960
|
+
const driveLetter = match ? match[0] : "";
|
|
19961
|
+
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
|
|
19962
|
+
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
|
|
19963
|
+
return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_');
|
|
19964
|
+
}
|
|
19965
|
+
|
|
19903
19966
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
19904
19967
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
19905
19968
|
// These are options that may trigger special warnings or behaviour later
|
|
@@ -19944,6 +20007,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
19944
20007
|
preferConst: config.preferConst || false,
|
|
19945
20008
|
preserveModules,
|
|
19946
20009
|
preserveModulesRoot: getPreserveModulesRoot(config),
|
|
20010
|
+
sanitizeFileName: (typeof config.sanitizeFileName === 'function' ? config.sanitizeFileName : config.sanitizeFileName === false ? (id) => id : sanitizeFileName),
|
|
19947
20011
|
sourcemap: config.sourcemap || false,
|
|
19948
20012
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
19949
20013
|
sourcemapFile: config.sourcemapFile,
|
|
@@ -20237,8 +20301,9 @@ async function getInputOptions(rawInputOptions, watchMode) {
|
|
|
20237
20301
|
}
|
|
20238
20302
|
function applyOptionHook(watchMode) {
|
|
20239
20303
|
return async (inputOptions, plugin) => {
|
|
20240
|
-
if (plugin.options)
|
|
20241
|
-
return (plugin.options.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions) || inputOptions);
|
|
20304
|
+
if (plugin.options) {
|
|
20305
|
+
return ((await plugin.options.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) || inputOptions);
|
|
20306
|
+
}
|
|
20242
20307
|
return inputOptions;
|
|
20243
20308
|
};
|
|
20244
20309
|
}
|