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/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
|
|
@@ -32,7 +32,7 @@ function _interopNamespaceDefaultOnly(e) {
|
|
|
32
32
|
|
|
33
33
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
34
34
|
|
|
35
|
-
var version$1 = "2.
|
|
35
|
+
var version$1 = "2.47.0";
|
|
36
36
|
|
|
37
37
|
function ensureArray(items) {
|
|
38
38
|
if (Array.isArray(items)) {
|
|
@@ -74,14 +74,6 @@ function normalize(path) {
|
|
|
74
74
|
return path.replace(/\\/g, '/');
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function sanitizeFileName(name) {
|
|
78
|
-
const match = /^[a-z]:/i.exec(name);
|
|
79
|
-
const driveLetter = match ? match[0] : "";
|
|
80
|
-
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
|
|
81
|
-
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
|
|
82
|
-
return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
77
|
function getAliasName(id) {
|
|
86
78
|
const base = path.basename(id);
|
|
87
79
|
return base.substr(0, base.length - path.extname(id).length);
|
|
@@ -91,12 +83,9 @@ function relativeId(id) {
|
|
|
91
83
|
return id;
|
|
92
84
|
return path.relative(path.resolve(), id);
|
|
93
85
|
}
|
|
94
|
-
function
|
|
95
|
-
//
|
|
96
|
-
return
|
|
97
|
-
!(name[0] === '.' && (name[1] === '/' || name[1] === '.')) &&
|
|
98
|
-
sanitizeFileName(name) === name &&
|
|
99
|
-
!isAbsolute(name));
|
|
86
|
+
function isPathFragment(name) {
|
|
87
|
+
// starting with "/", "./", "../", "C:/"
|
|
88
|
+
return name[0] === '/' || name[0] === '.' && (name[1] === '/' || name[1] === '.') || isAbsolute(name);
|
|
100
89
|
}
|
|
101
90
|
|
|
102
91
|
let fsEvents;
|
|
@@ -4473,14 +4462,17 @@ class NamespaceVariable extends Variable {
|
|
|
4473
4462
|
this.references.push(identifier);
|
|
4474
4463
|
this.name = identifier.name;
|
|
4475
4464
|
}
|
|
4476
|
-
|
|
4477
|
-
// build fails due to an illegal namespace reassignment or MemberExpression already forwards
|
|
4478
|
-
// the reassignment to the right variable. This means we lost track of this variable and thus
|
|
4479
|
-
// need to reassign all exports.
|
|
4480
|
-
deoptimizePath() {
|
|
4465
|
+
deoptimizePath(path) {
|
|
4481
4466
|
const memberVariables = this.getMemberVariables();
|
|
4482
|
-
|
|
4483
|
-
|
|
4467
|
+
const memberPath = path.length <= 1 ? UNKNOWN_PATH : path.slice(1);
|
|
4468
|
+
const key = path[0];
|
|
4469
|
+
if (typeof key !== 'string') {
|
|
4470
|
+
for (const key of Object.keys(memberVariables)) {
|
|
4471
|
+
memberVariables[key].deoptimizePath(memberPath);
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
else {
|
|
4475
|
+
memberVariables[key].deoptimizePath(memberPath);
|
|
4484
4476
|
}
|
|
4485
4477
|
}
|
|
4486
4478
|
getMemberVariables() {
|
|
@@ -4490,7 +4482,10 @@ class NamespaceVariable extends Variable {
|
|
|
4490
4482
|
const memberVariables = Object.create(null);
|
|
4491
4483
|
for (const name of this.context.getExports().concat(this.context.getReexports())) {
|
|
4492
4484
|
if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
|
|
4493
|
-
|
|
4485
|
+
const exportedVariable = this.context.traceExport(name);
|
|
4486
|
+
if (exportedVariable) {
|
|
4487
|
+
memberVariables[name] = exportedVariable;
|
|
4488
|
+
}
|
|
4494
4489
|
}
|
|
4495
4490
|
}
|
|
4496
4491
|
return (this.memberVariables = memberVariables);
|
|
@@ -4649,6 +4644,18 @@ function makeLegal(str) {
|
|
|
4649
4644
|
return str || '_';
|
|
4650
4645
|
}
|
|
4651
4646
|
|
|
4647
|
+
function printQuotedStringList(list, verbs) {
|
|
4648
|
+
const isSingleItem = list.length <= 1;
|
|
4649
|
+
const quotedList = list.map(item => `"${item}"`);
|
|
4650
|
+
let output = isSingleItem
|
|
4651
|
+
? quotedList[0]
|
|
4652
|
+
: `${quotedList.slice(0, -1).join(', ')} and ${quotedList.slice(-1)[0]}`;
|
|
4653
|
+
if (verbs) {
|
|
4654
|
+
output += ` ${isSingleItem ? verbs[0] : verbs[1]}`;
|
|
4655
|
+
}
|
|
4656
|
+
return output;
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4652
4659
|
class ExternalModule {
|
|
4653
4660
|
constructor(options, id, hasModuleSideEffects, meta, renormalizeRenderPath) {
|
|
4654
4661
|
this.options = options;
|
|
@@ -4726,17 +4733,20 @@ class ExternalModule {
|
|
|
4726
4733
|
});
|
|
4727
4734
|
if (unused.length === 0)
|
|
4728
4735
|
return;
|
|
4729
|
-
const
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
.
|
|
4734
|
-
|
|
4736
|
+
const importersSet = new Set();
|
|
4737
|
+
for (const name of unused) {
|
|
4738
|
+
const { importers } = this.declarations[name].module;
|
|
4739
|
+
for (const importer of importers) {
|
|
4740
|
+
importersSet.add(importer);
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
const importersArray = [...importersSet];
|
|
4735
4744
|
this.options.onwarn({
|
|
4736
4745
|
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
4737
|
-
message: `${
|
|
4746
|
+
message: `${printQuotedStringList(unused, ['is', 'are'])} imported from external module "${this.id}" but never used in ${printQuotedStringList(importersArray.map(importer => relativeId(importer)))}.`,
|
|
4738
4747
|
names: unused,
|
|
4739
|
-
source: this.id
|
|
4748
|
+
source: this.id,
|
|
4749
|
+
sources: importersArray
|
|
4740
4750
|
});
|
|
4741
4751
|
}
|
|
4742
4752
|
}
|
|
@@ -5057,15 +5067,9 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
5057
5067
|
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins);
|
|
5058
5068
|
if (!externalBuiltins.length)
|
|
5059
5069
|
return;
|
|
5060
|
-
const detail = externalBuiltins.length === 1
|
|
5061
|
-
? `module ('${externalBuiltins[0]}')`
|
|
5062
|
-
: `modules (${externalBuiltins
|
|
5063
|
-
.slice(0, -1)
|
|
5064
|
-
.map(name => `'${name}'`)
|
|
5065
|
-
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
5066
5070
|
warn({
|
|
5067
5071
|
code: 'MISSING_NODE_BUILTINS',
|
|
5068
|
-
message: `Creating a browser bundle that depends on Node.js built-in ${
|
|
5072
|
+
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`,
|
|
5069
5073
|
modules: externalBuiltins
|
|
5070
5074
|
});
|
|
5071
5075
|
}
|
|
@@ -5348,6 +5352,7 @@ var Errors;
|
|
|
5348
5352
|
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
5349
5353
|
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
5350
5354
|
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
5355
|
+
Errors["AMBIGUOUS_EXTERNAL_NAMESPACES"] = "AMBIGUOUS_EXTERNAL_NAMESPACES";
|
|
5351
5356
|
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
5352
5357
|
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
5353
5358
|
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
@@ -5513,9 +5518,7 @@ function errImplicitDependantIsNotIncluded(module) {
|
|
|
5513
5518
|
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
5514
5519
|
return {
|
|
5515
5520
|
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5516
|
-
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before
|
|
5517
|
-
? implicitDependencies[0]
|
|
5518
|
-
: `${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.`
|
|
5521
|
+
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.`
|
|
5519
5522
|
};
|
|
5520
5523
|
}
|
|
5521
5524
|
function errMixedExport(facadeModuleId, name) {
|
|
@@ -5529,12 +5532,21 @@ function errMixedExport(facadeModuleId, name) {
|
|
|
5529
5532
|
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
5530
5533
|
return {
|
|
5531
5534
|
code: Errors.NAMESPACE_CONFLICT,
|
|
5532
|
-
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports
|
|
5535
|
+
message: `Conflicting namespaces: "${relativeId(reexportingModule.id)}" re-exports "${name}" from both "${relativeId(reexportingModule.exportsAll[name])}" and "${relativeId(additionalExportAllModule.exportsAll[name])}" (will be ignored)`,
|
|
5533
5536
|
name,
|
|
5534
5537
|
reexporter: reexportingModule.id,
|
|
5535
5538
|
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
5536
5539
|
};
|
|
5537
5540
|
}
|
|
5541
|
+
function errAmbiguousExternalNamespaces(name, reexportingModule, usedExternalModule, externalModules) {
|
|
5542
|
+
return {
|
|
5543
|
+
code: Errors.AMBIGUOUS_EXTERNAL_NAMESPACES,
|
|
5544
|
+
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)}".`,
|
|
5545
|
+
name,
|
|
5546
|
+
reexporter: reexportingModule,
|
|
5547
|
+
sources: externalModules
|
|
5548
|
+
};
|
|
5549
|
+
}
|
|
5538
5550
|
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
5539
5551
|
return {
|
|
5540
5552
|
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
@@ -6600,15 +6612,9 @@ class MemberExpression extends NodeBase {
|
|
|
6600
6612
|
if (this.variable) {
|
|
6601
6613
|
this.variable.deoptimizePath(path);
|
|
6602
6614
|
}
|
|
6603
|
-
else {
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
this.object.deoptimizePath(UNKNOWN_PATH);
|
|
6607
|
-
}
|
|
6608
|
-
else {
|
|
6609
|
-
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6610
|
-
this.object.deoptimizePath([propertyKey, ...path]);
|
|
6611
|
-
}
|
|
6615
|
+
else if (!this.replacement) {
|
|
6616
|
+
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6617
|
+
this.object.deoptimizePath([this.getPropertyKey(), ...path]);
|
|
6612
6618
|
}
|
|
6613
6619
|
}
|
|
6614
6620
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -9606,8 +9612,11 @@ function findSourceMappingURLComments(ast, code) {
|
|
|
9606
9612
|
}
|
|
9607
9613
|
let sourcemappingUrlMatch;
|
|
9608
9614
|
const interStatmentCode = code.slice(start, end);
|
|
9609
|
-
while (sourcemappingUrlMatch = SOURCEMAPPING_URL_COMMENT_RE.exec(interStatmentCode)) {
|
|
9610
|
-
ret.push([
|
|
9615
|
+
while ((sourcemappingUrlMatch = SOURCEMAPPING_URL_COMMENT_RE.exec(interStatmentCode))) {
|
|
9616
|
+
ret.push([
|
|
9617
|
+
start + sourcemappingUrlMatch.index,
|
|
9618
|
+
start + SOURCEMAPPING_URL_COMMENT_RE.lastIndex
|
|
9619
|
+
]);
|
|
9611
9620
|
}
|
|
9612
9621
|
};
|
|
9613
9622
|
let prevStmtEnd = 0;
|
|
@@ -9618,7 +9627,7 @@ function findSourceMappingURLComments(ast, code) {
|
|
|
9618
9627
|
addCommentsPos(prevStmtEnd, code.length);
|
|
9619
9628
|
return ret;
|
|
9620
9629
|
}
|
|
9621
|
-
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9630
|
+
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map(), skipExternalNamespaceReexports) {
|
|
9622
9631
|
const searchedModules = searchedNamesAndModules.get(name);
|
|
9623
9632
|
if (searchedModules) {
|
|
9624
9633
|
if (searchedModules.has(target)) {
|
|
@@ -9629,7 +9638,12 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
|
|
|
9629
9638
|
else {
|
|
9630
9639
|
searchedNamesAndModules.set(name, new Set([target]));
|
|
9631
9640
|
}
|
|
9632
|
-
return target.getVariableForExportName(name,
|
|
9641
|
+
return target.getVariableForExportName(name, {
|
|
9642
|
+
importerForSideEffects,
|
|
9643
|
+
isExportAllSearch,
|
|
9644
|
+
searchedNamesAndModules,
|
|
9645
|
+
skipExternalNamespaceReexports
|
|
9646
|
+
});
|
|
9633
9647
|
}
|
|
9634
9648
|
function getAndExtendSideEffectModules(variable, module) {
|
|
9635
9649
|
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, () => new Set());
|
|
@@ -9694,6 +9708,7 @@ class Module {
|
|
|
9694
9708
|
this.exportAllModules = [];
|
|
9695
9709
|
this.exportNamesByVariable = null;
|
|
9696
9710
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
9711
|
+
this.namespaceReexportsByName = Object.create(null);
|
|
9697
9712
|
this.relevantDependencies = null;
|
|
9698
9713
|
this.syntheticExports = new Map();
|
|
9699
9714
|
this.syntheticNamespace = null;
|
|
@@ -9785,7 +9800,10 @@ class Module {
|
|
|
9785
9800
|
this.implicitlyLoadedAfter.size > 0) {
|
|
9786
9801
|
dependencyVariables = new Set(dependencyVariables);
|
|
9787
9802
|
for (const exportName of [...this.getReexports(), ...this.getExports()]) {
|
|
9788
|
-
|
|
9803
|
+
const exportedVariable = this.getVariableForExportName(exportName);
|
|
9804
|
+
if (exportedVariable) {
|
|
9805
|
+
dependencyVariables.add(exportedVariable);
|
|
9806
|
+
}
|
|
9789
9807
|
}
|
|
9790
9808
|
}
|
|
9791
9809
|
for (let variable of dependencyVariables) {
|
|
@@ -9890,7 +9908,7 @@ class Module {
|
|
|
9890
9908
|
}
|
|
9891
9909
|
return this.syntheticNamespace;
|
|
9892
9910
|
}
|
|
9893
|
-
getVariableForExportName(name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules) {
|
|
9911
|
+
getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, searchedNamesAndModules, skipExternalNamespaceReexports } = EMPTY_OBJECT) {
|
|
9894
9912
|
if (name[0] === '*') {
|
|
9895
9913
|
if (name.length === 1) {
|
|
9896
9914
|
// export * from './other'
|
|
@@ -9905,7 +9923,7 @@ class Module {
|
|
|
9905
9923
|
// export { foo } from './other'
|
|
9906
9924
|
const reexportDeclaration = this.reexportDescriptions[name];
|
|
9907
9925
|
if (reexportDeclaration) {
|
|
9908
|
-
const variable = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
|
|
9926
|
+
const variable = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, false);
|
|
9909
9927
|
if (!variable) {
|
|
9910
9928
|
return this.error(errMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
|
|
9911
9929
|
}
|
|
@@ -9928,20 +9946,11 @@ class Module {
|
|
|
9928
9946
|
return variable;
|
|
9929
9947
|
}
|
|
9930
9948
|
if (name !== 'default') {
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
return declaration;
|
|
9937
|
-
}
|
|
9938
|
-
if (!foundSyntheticDeclaration) {
|
|
9939
|
-
foundSyntheticDeclaration = declaration;
|
|
9940
|
-
}
|
|
9941
|
-
}
|
|
9942
|
-
}
|
|
9943
|
-
if (foundSyntheticDeclaration) {
|
|
9944
|
-
return foundSyntheticDeclaration;
|
|
9949
|
+
const foundNamespaceReexport = name in this.namespaceReexportsByName
|
|
9950
|
+
? this.namespaceReexportsByName[name]
|
|
9951
|
+
: (this.namespaceReexportsByName[name] = this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports));
|
|
9952
|
+
if (foundNamespaceReexport) {
|
|
9953
|
+
return foundNamespaceReexport;
|
|
9945
9954
|
}
|
|
9946
9955
|
}
|
|
9947
9956
|
if (this.info.syntheticNamedExports) {
|
|
@@ -9989,12 +9998,14 @@ class Module {
|
|
|
9989
9998
|
}
|
|
9990
9999
|
for (const name of this.getReexports()) {
|
|
9991
10000
|
const variable = this.getVariableForExportName(name);
|
|
9992
|
-
variable
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
variable
|
|
10001
|
+
if (variable) {
|
|
10002
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
10003
|
+
if (!variable.included) {
|
|
10004
|
+
this.includeVariable(variable);
|
|
10005
|
+
}
|
|
10006
|
+
if (variable instanceof ExternalVariable) {
|
|
10007
|
+
variable.module.reexported = true;
|
|
10008
|
+
}
|
|
9998
10009
|
}
|
|
9999
10010
|
}
|
|
10000
10011
|
if (includeNamespaceMembers) {
|
|
@@ -10133,7 +10144,9 @@ class Module {
|
|
|
10133
10144
|
if (otherModule instanceof Module && importDeclaration.name === '*') {
|
|
10134
10145
|
return otherModule.namespace;
|
|
10135
10146
|
}
|
|
10136
|
-
const declaration = otherModule.getVariableForExportName(importDeclaration.name,
|
|
10147
|
+
const declaration = otherModule.getVariableForExportName(importDeclaration.name, {
|
|
10148
|
+
importerForSideEffects: importerForSideEffects || this
|
|
10149
|
+
});
|
|
10137
10150
|
if (!declaration) {
|
|
10138
10151
|
return this.error(errMissingExport(importDeclaration.name, this.id, otherModule.id), importDeclaration.start);
|
|
10139
10152
|
}
|
|
@@ -10331,6 +10344,42 @@ class Module {
|
|
|
10331
10344
|
addSideEffectDependencies(this.dependencies);
|
|
10332
10345
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
10333
10346
|
}
|
|
10347
|
+
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports = false) {
|
|
10348
|
+
let foundSyntheticDeclaration = null;
|
|
10349
|
+
const skipExternalNamespaceValues = new Set([true, skipExternalNamespaceReexports]);
|
|
10350
|
+
for (const skipExternalNamespaces of skipExternalNamespaceValues) {
|
|
10351
|
+
const foundDeclarations = new Set();
|
|
10352
|
+
for (const module of this.exportAllModules) {
|
|
10353
|
+
if (module instanceof Module || !skipExternalNamespaces) {
|
|
10354
|
+
const declaration = getVariableForExportNameRecursive(module, name, importerForSideEffects, true, searchedNamesAndModules, skipExternalNamespaces);
|
|
10355
|
+
if (declaration) {
|
|
10356
|
+
if (!(declaration instanceof SyntheticNamedExportVariable)) {
|
|
10357
|
+
foundDeclarations.add(declaration);
|
|
10358
|
+
}
|
|
10359
|
+
else if (!foundSyntheticDeclaration) {
|
|
10360
|
+
foundSyntheticDeclaration = declaration;
|
|
10361
|
+
}
|
|
10362
|
+
}
|
|
10363
|
+
}
|
|
10364
|
+
}
|
|
10365
|
+
if (foundDeclarations.size === 1) {
|
|
10366
|
+
return [...foundDeclarations][0];
|
|
10367
|
+
}
|
|
10368
|
+
if (foundDeclarations.size > 1) {
|
|
10369
|
+
if (skipExternalNamespaces) {
|
|
10370
|
+
return null;
|
|
10371
|
+
}
|
|
10372
|
+
const foundDeclarationList = [...foundDeclarations];
|
|
10373
|
+
const usedDeclaration = foundDeclarationList[0];
|
|
10374
|
+
this.options.onwarn(errAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
|
|
10375
|
+
return usedDeclaration;
|
|
10376
|
+
}
|
|
10377
|
+
}
|
|
10378
|
+
if (foundSyntheticDeclaration) {
|
|
10379
|
+
return foundSyntheticDeclaration;
|
|
10380
|
+
}
|
|
10381
|
+
return null;
|
|
10382
|
+
}
|
|
10334
10383
|
includeAndGetAdditionalMergedNamespaces() {
|
|
10335
10384
|
const mergedNamespaces = [];
|
|
10336
10385
|
for (const module of this.exportAllModules) {
|
|
@@ -10870,14 +10919,14 @@ function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemap
|
|
|
10870
10919
|
}
|
|
10871
10920
|
|
|
10872
10921
|
function renderNamePattern(pattern, patternName, replacements) {
|
|
10873
|
-
if (
|
|
10874
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths
|
|
10922
|
+
if (isPathFragment(pattern))
|
|
10923
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths.`));
|
|
10875
10924
|
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
10876
10925
|
if (!replacements.hasOwnProperty(type)) {
|
|
10877
10926
|
return error(errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`));
|
|
10878
10927
|
}
|
|
10879
10928
|
const replacement = replacements[type]();
|
|
10880
|
-
if (
|
|
10929
|
+
if (isPathFragment(replacement))
|
|
10881
10930
|
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
10882
10931
|
return replacement;
|
|
10883
10932
|
});
|
|
@@ -10932,6 +10981,7 @@ class Chunk {
|
|
|
10932
10981
|
this.dependencies = new Set();
|
|
10933
10982
|
this.dynamicDependencies = new Set();
|
|
10934
10983
|
this.dynamicEntryModules = [];
|
|
10984
|
+
this.dynamicName = null;
|
|
10935
10985
|
this.exportNamesByVariable = new Map();
|
|
10936
10986
|
this.exports = new Set();
|
|
10937
10987
|
this.exportsByName = Object.create(null);
|
|
@@ -11096,7 +11146,7 @@ class Chunk {
|
|
|
11096
11146
|
this.facadeModule = module;
|
|
11097
11147
|
this.facadeChunkByModule.set(module, this);
|
|
11098
11148
|
this.strictFacade = true;
|
|
11099
|
-
this.
|
|
11149
|
+
this.dynamicName = getChunkNameFromModule(module);
|
|
11100
11150
|
}
|
|
11101
11151
|
else if (this.facadeModule === module &&
|
|
11102
11152
|
!this.strictFacade &&
|
|
@@ -11127,7 +11177,7 @@ class Chunk {
|
|
|
11127
11177
|
}
|
|
11128
11178
|
generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
|
|
11129
11179
|
const id = this.orderedModules[0].id;
|
|
11130
|
-
const sanitizedId = sanitizeFileName(id);
|
|
11180
|
+
const sanitizedId = this.outputOptions.sanitizeFileName(id);
|
|
11131
11181
|
let path$1;
|
|
11132
11182
|
if (isAbsolute(id)) {
|
|
11133
11183
|
const extension = path.extname(id);
|
|
@@ -11186,7 +11236,7 @@ class Chunk {
|
|
|
11186
11236
|
});
|
|
11187
11237
|
}
|
|
11188
11238
|
getChunkName() {
|
|
11189
|
-
return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
|
|
11239
|
+
return this.name || (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName()));
|
|
11190
11240
|
}
|
|
11191
11241
|
getExportNames() {
|
|
11192
11242
|
return (this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort()));
|
|
@@ -11445,7 +11495,7 @@ class Chunk {
|
|
|
11445
11495
|
this.fileName = fileName;
|
|
11446
11496
|
}
|
|
11447
11497
|
else {
|
|
11448
|
-
this.name = sanitizeFileName(name ||
|
|
11498
|
+
this.name = this.outputOptions.sanitizeFileName(name || getChunkNameFromModule(facadedModule));
|
|
11449
11499
|
}
|
|
11450
11500
|
}
|
|
11451
11501
|
checkCircularDependencyImport(variable, importingModule) {
|
|
@@ -11664,6 +11714,9 @@ class Chunk {
|
|
|
11664
11714
|
if (this.manualChunkAlias) {
|
|
11665
11715
|
return this.manualChunkAlias;
|
|
11666
11716
|
}
|
|
11717
|
+
if (this.dynamicName) {
|
|
11718
|
+
return this.dynamicName;
|
|
11719
|
+
}
|
|
11667
11720
|
if (this.fileName) {
|
|
11668
11721
|
return getAliasName(this.fileName);
|
|
11669
11722
|
}
|
|
@@ -11913,6 +11966,9 @@ class Chunk {
|
|
|
11913
11966
|
}
|
|
11914
11967
|
}
|
|
11915
11968
|
}
|
|
11969
|
+
function getChunkNameFromModule(module) {
|
|
11970
|
+
return module.chunkName || getAliasName(module.id);
|
|
11971
|
+
}
|
|
11916
11972
|
|
|
11917
11973
|
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
11918
11974
|
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -12169,11 +12225,11 @@ var BuildPhase;
|
|
|
12169
12225
|
BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
|
|
12170
12226
|
})(BuildPhase || (BuildPhase = {}));
|
|
12171
12227
|
|
|
12172
|
-
function generateAssetFileName(name, source,
|
|
12173
|
-
const emittedName = name || 'asset';
|
|
12174
|
-
return makeUnique(renderNamePattern(typeof
|
|
12175
|
-
?
|
|
12176
|
-
:
|
|
12228
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
12229
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
12230
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
12231
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
12232
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
12177
12233
|
hash() {
|
|
12178
12234
|
const hash = createHash();
|
|
12179
12235
|
hash.update(emittedName);
|
|
@@ -12184,7 +12240,7 @@ function generateAssetFileName(name, source, output) {
|
|
|
12184
12240
|
ext: () => path.extname(emittedName).substr(1),
|
|
12185
12241
|
extname: () => path.extname(emittedName),
|
|
12186
12242
|
name: () => emittedName.substr(0, emittedName.length - path.extname(emittedName).length)
|
|
12187
|
-
}),
|
|
12243
|
+
}), bundle);
|
|
12188
12244
|
}
|
|
12189
12245
|
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
12190
12246
|
if (fileName in bundle) {
|
|
@@ -12202,7 +12258,7 @@ function hasValidType(emittedFile) {
|
|
|
12202
12258
|
}
|
|
12203
12259
|
function hasValidName(emittedFile) {
|
|
12204
12260
|
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
12205
|
-
return
|
|
12261
|
+
return !validatedName || typeof validatedName === 'string' && !isPathFragment(validatedName);
|
|
12206
12262
|
}
|
|
12207
12263
|
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
12208
12264
|
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
@@ -12228,8 +12284,9 @@ class FileEmitter {
|
|
|
12228
12284
|
constructor(graph, options, baseFileEmitter) {
|
|
12229
12285
|
this.graph = graph;
|
|
12230
12286
|
this.options = options;
|
|
12287
|
+
this.bundle = null;
|
|
12231
12288
|
this.facadeChunkByModule = null;
|
|
12232
|
-
this.
|
|
12289
|
+
this.outputOptions = null;
|
|
12233
12290
|
this.assertAssetsFinalized = () => {
|
|
12234
12291
|
for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
|
|
12235
12292
|
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
@@ -12241,7 +12298,7 @@ class FileEmitter {
|
|
|
12241
12298
|
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
12242
12299
|
}
|
|
12243
12300
|
if (!hasValidName(emittedFile)) {
|
|
12244
|
-
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths
|
|
12301
|
+
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}".`));
|
|
12245
12302
|
}
|
|
12246
12303
|
if (emittedFile.type === 'chunk') {
|
|
12247
12304
|
return this.emitChunk(emittedFile);
|
|
@@ -12272,27 +12329,25 @@ class FileEmitter {
|
|
|
12272
12329
|
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
12273
12330
|
}
|
|
12274
12331
|
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
12275
|
-
if (this.
|
|
12276
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.
|
|
12332
|
+
if (this.bundle) {
|
|
12333
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
12277
12334
|
}
|
|
12278
12335
|
else {
|
|
12279
12336
|
consumedFile.source = source;
|
|
12280
12337
|
}
|
|
12281
12338
|
};
|
|
12282
|
-
this.setOutputBundle = (outputBundle,
|
|
12283
|
-
this.
|
|
12284
|
-
|
|
12285
|
-
bundle: outputBundle
|
|
12286
|
-
};
|
|
12339
|
+
this.setOutputBundle = (outputBundle, outputOptions, facadeChunkByModule) => {
|
|
12340
|
+
this.outputOptions = outputOptions;
|
|
12341
|
+
this.bundle = outputBundle;
|
|
12287
12342
|
this.facadeChunkByModule = facadeChunkByModule;
|
|
12288
12343
|
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
12289
12344
|
if (emittedFile.fileName) {
|
|
12290
|
-
reserveFileNameInBundle(emittedFile.fileName, this.
|
|
12345
|
+
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
12291
12346
|
}
|
|
12292
12347
|
}
|
|
12293
12348
|
for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) {
|
|
12294
12349
|
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
12295
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.
|
|
12350
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
12296
12351
|
}
|
|
12297
12352
|
}
|
|
12298
12353
|
};
|
|
@@ -12326,12 +12381,12 @@ class FileEmitter {
|
|
|
12326
12381
|
type: 'asset'
|
|
12327
12382
|
};
|
|
12328
12383
|
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
12329
|
-
if (this.
|
|
12384
|
+
if (this.bundle) {
|
|
12330
12385
|
if (emittedAsset.fileName) {
|
|
12331
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.
|
|
12386
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
12332
12387
|
}
|
|
12333
12388
|
if (source !== undefined) {
|
|
12334
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.
|
|
12389
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
12335
12390
|
}
|
|
12336
12391
|
}
|
|
12337
12392
|
return referenceId;
|
|
@@ -12358,15 +12413,15 @@ class FileEmitter {
|
|
|
12358
12413
|
});
|
|
12359
12414
|
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
12360
12415
|
}
|
|
12361
|
-
finalizeAsset(consumedFile, source, referenceId,
|
|
12416
|
+
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
12362
12417
|
const fileName = consumedFile.fileName ||
|
|
12363
|
-
findExistingAssetFileNameWithSource(
|
|
12364
|
-
generateAssetFileName(consumedFile.name, source,
|
|
12418
|
+
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
12419
|
+
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
12365
12420
|
// We must not modify the original assets to avoid interaction between outputs
|
|
12366
12421
|
const assetWithFileName = { ...consumedFile, source, fileName };
|
|
12367
12422
|
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
12368
12423
|
const options = this.options;
|
|
12369
|
-
|
|
12424
|
+
bundle[fileName] = {
|
|
12370
12425
|
fileName,
|
|
12371
12426
|
name: consumedFile.name,
|
|
12372
12427
|
get isAsset() {
|
|
@@ -12420,7 +12475,7 @@ class Bundle {
|
|
|
12420
12475
|
async generate(isWrite) {
|
|
12421
12476
|
timeStart('GENERATE', 1);
|
|
12422
12477
|
const outputBundle = Object.create(null);
|
|
12423
|
-
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions
|
|
12478
|
+
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions, this.facadeChunkByModule);
|
|
12424
12479
|
try {
|
|
12425
12480
|
await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
|
|
12426
12481
|
timeStart('generate chunks', 2);
|
|
@@ -18654,7 +18709,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
18654
18709
|
cache: cacheInstance,
|
|
18655
18710
|
emitAsset: getDeprecatedContextHandler((name, source) => fileEmitter.emitFile({ type: 'asset', name, source }), 'emitAsset', 'emitFile', plugin.name, true, options),
|
|
18656
18711
|
emitChunk: getDeprecatedContextHandler((id, options) => fileEmitter.emitFile({ type: 'chunk', id, name: options && options.name }), 'emitChunk', 'emitFile', plugin.name, true, options),
|
|
18657
|
-
emitFile: fileEmitter.emitFile,
|
|
18712
|
+
emitFile: fileEmitter.emitFile.bind(fileEmitter),
|
|
18658
18713
|
error(err) {
|
|
18659
18714
|
return throwPluginError(err, plugin.name);
|
|
18660
18715
|
},
|
|
@@ -18729,10 +18784,10 @@ class PluginDriver {
|
|
|
18729
18784
|
warnDeprecatedHooks(userPlugins, options);
|
|
18730
18785
|
this.pluginCache = pluginCache;
|
|
18731
18786
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
18732
|
-
this.emitFile = this.fileEmitter.emitFile;
|
|
18733
|
-
this.getFileName = this.fileEmitter.getFileName;
|
|
18734
|
-
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized;
|
|
18735
|
-
this.setOutputBundle = this.fileEmitter.setOutputBundle;
|
|
18787
|
+
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
18788
|
+
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
18789
|
+
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized.bind(this.fileEmitter);
|
|
18790
|
+
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
|
|
18736
18791
|
this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []);
|
|
18737
18792
|
const existingPluginNames = new Set();
|
|
18738
18793
|
for (const plugin of this.plugins) {
|
|
@@ -19942,6 +19997,14 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules, w
|
|
|
19942
19997
|
return (id, external) => !(external && isPureExternalModule(id));
|
|
19943
19998
|
};
|
|
19944
19999
|
|
|
20000
|
+
function sanitizeFileName(name) {
|
|
20001
|
+
const match = /^[a-z]:/i.exec(name);
|
|
20002
|
+
const driveLetter = match ? match[0] : "";
|
|
20003
|
+
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
|
|
20004
|
+
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
|
|
20005
|
+
return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_');
|
|
20006
|
+
}
|
|
20007
|
+
|
|
19945
20008
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
19946
20009
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
19947
20010
|
// These are options that may trigger special warnings or behaviour later
|
|
@@ -19986,6 +20049,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
19986
20049
|
preferConst: config.preferConst || false,
|
|
19987
20050
|
preserveModules,
|
|
19988
20051
|
preserveModulesRoot: getPreserveModulesRoot(config),
|
|
20052
|
+
sanitizeFileName: (typeof config.sanitizeFileName === 'function' ? config.sanitizeFileName : config.sanitizeFileName === false ? (id) => id : sanitizeFileName),
|
|
19989
20053
|
sourcemap: config.sourcemap || false,
|
|
19990
20054
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
19991
20055
|
sourcemapFile: config.sourcemapFile,
|
|
@@ -20279,8 +20343,9 @@ async function getInputOptions(rawInputOptions, watchMode) {
|
|
|
20279
20343
|
}
|
|
20280
20344
|
function applyOptionHook(watchMode) {
|
|
20281
20345
|
return async (inputOptions, plugin) => {
|
|
20282
|
-
if (plugin.options)
|
|
20283
|
-
return (plugin.options.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions) || inputOptions);
|
|
20346
|
+
if (plugin.options) {
|
|
20347
|
+
return ((await plugin.options.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) || inputOptions);
|
|
20348
|
+
}
|
|
20284
20349
|
return inputOptions;
|
|
20285
20350
|
};
|
|
20286
20351
|
}
|
|
@@ -20414,6 +20479,7 @@ exports.getAliasName = getAliasName;
|
|
|
20414
20479
|
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
20415
20480
|
exports.getOrCreate = getOrCreate;
|
|
20416
20481
|
exports.loadFsEvents = loadFsEvents;
|
|
20482
|
+
exports.printQuotedStringList = printQuotedStringList;
|
|
20417
20483
|
exports.relativeId = relativeId;
|
|
20418
20484
|
exports.rollup = rollup;
|
|
20419
20485
|
exports.rollupInternal = rollupInternal;
|