rollup 2.38.0 → 2.38.4
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 +41 -0
- package/README.md +2 -2
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +1044 -1045
- package/dist/es/shared/watch.js +15 -6
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +4 -3
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +15 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +1025 -1026
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +19 -20
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.38.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.38.4
|
|
4
|
+
Tue, 02 Feb 2021 05:54:38 GMT - commit 991bb98fad1f3f76226bfe6243fd6cc45a19a39b
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -19,7 +19,7 @@ function _interopNamespaceDefaultOnly(e) {
|
|
|
19
19
|
return {__proto__: null, 'default': e};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
var version = "2.38.
|
|
22
|
+
var version = "2.38.4";
|
|
23
23
|
|
|
24
24
|
function ensureArray(items) {
|
|
25
25
|
if (Array.isArray(items)) {
|
|
@@ -70,9 +70,9 @@ function getAliasName(id) {
|
|
|
70
70
|
return base.substr(0, base.length - sysPath.extname(id).length);
|
|
71
71
|
}
|
|
72
72
|
function relativeId(id) {
|
|
73
|
-
if (
|
|
73
|
+
if (!isAbsolute(id))
|
|
74
74
|
return id;
|
|
75
|
-
return sysPath.relative(
|
|
75
|
+
return sysPath.relative(sysPath.resolve(), id);
|
|
76
76
|
}
|
|
77
77
|
function isPlainPathFragment(name) {
|
|
78
78
|
// not starting with "/", "./", "../"
|
|
@@ -2765,7 +2765,7 @@ class NodeBase {
|
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
2767
|
}
|
|
2768
|
-
|
|
2768
|
+
includeAsSingleStatement(context, includeChildrenRecursively) {
|
|
2769
2769
|
this.include(context, includeChildrenRecursively);
|
|
2770
2770
|
}
|
|
2771
2771
|
includeCallArguments(context, args) {
|
|
@@ -4352,7 +4352,9 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
4352
4352
|
return this.originalId &&
|
|
4353
4353
|
(this.hasId ||
|
|
4354
4354
|
!(this.originalId.variable.isReassigned ||
|
|
4355
|
-
this.originalId.variable instanceof UndefinedVariable
|
|
4355
|
+
this.originalId.variable instanceof UndefinedVariable ||
|
|
4356
|
+
// this avoids a circular dependency
|
|
4357
|
+
'syntheticNamespace' in this.originalId.variable))
|
|
4356
4358
|
? this.originalId.variable
|
|
4357
4359
|
: null;
|
|
4358
4360
|
}
|
|
@@ -4489,1081 +4491,1076 @@ class NamespaceVariable extends Variable {
|
|
|
4489
4491
|
}
|
|
4490
4492
|
NamespaceVariable.prototype.isNamespace = true;
|
|
4491
4493
|
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4494
|
+
class SyntheticNamedExportVariable extends Variable {
|
|
4495
|
+
constructor(context, name, syntheticNamespace) {
|
|
4496
|
+
super(name);
|
|
4497
|
+
this.baseVariable = null;
|
|
4498
|
+
this.context = context;
|
|
4499
|
+
this.module = context.module;
|
|
4500
|
+
this.syntheticNamespace = syntheticNamespace;
|
|
4501
|
+
}
|
|
4502
|
+
getBaseVariable() {
|
|
4503
|
+
if (this.baseVariable)
|
|
4504
|
+
return this.baseVariable;
|
|
4505
|
+
let baseVariable = this.syntheticNamespace;
|
|
4506
|
+
while (baseVariable instanceof ExportDefaultVariable ||
|
|
4507
|
+
baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4508
|
+
if (baseVariable instanceof ExportDefaultVariable) {
|
|
4509
|
+
const original = baseVariable.getOriginalVariable();
|
|
4510
|
+
if (original === baseVariable)
|
|
4511
|
+
break;
|
|
4512
|
+
baseVariable = original;
|
|
4513
|
+
}
|
|
4514
|
+
if (baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4515
|
+
baseVariable = baseVariable.syntheticNamespace;
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
return (this.baseVariable = baseVariable);
|
|
4519
|
+
}
|
|
4520
|
+
getBaseVariableName() {
|
|
4521
|
+
return this.syntheticNamespace.getBaseVariableName();
|
|
4522
|
+
}
|
|
4523
|
+
getName() {
|
|
4524
|
+
const name = this.name;
|
|
4525
|
+
return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`;
|
|
4526
|
+
}
|
|
4527
|
+
include() {
|
|
4528
|
+
if (!this.included) {
|
|
4529
|
+
this.included = true;
|
|
4530
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4533
|
+
setRenderNames(baseName, name) {
|
|
4534
|
+
super.setRenderNames(baseName, name);
|
|
4535
|
+
}
|
|
4497
4536
|
}
|
|
4498
|
-
|
|
4499
|
-
return
|
|
4537
|
+
const getPropertyAccess = (name) => {
|
|
4538
|
+
return !RESERVED_NAMES[name] && /^(?!\d)[\w$]+$/.test(name)
|
|
4539
|
+
? `.${name}`
|
|
4540
|
+
: `[${JSON.stringify(name)}]`;
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
class ExternalVariable extends Variable {
|
|
4544
|
+
constructor(module, name) {
|
|
4545
|
+
super(name);
|
|
4546
|
+
this.module = module;
|
|
4547
|
+
this.isNamespace = name === '*';
|
|
4548
|
+
this.referenced = false;
|
|
4549
|
+
}
|
|
4550
|
+
addReference(identifier) {
|
|
4551
|
+
this.referenced = true;
|
|
4552
|
+
if (this.name === 'default' || this.name === '*') {
|
|
4553
|
+
this.module.suggestName(identifier.name);
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
include() {
|
|
4557
|
+
if (!this.included) {
|
|
4558
|
+
this.included = true;
|
|
4559
|
+
this.module.used = true;
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4500
4562
|
}
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4563
|
+
|
|
4564
|
+
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' ');
|
|
4565
|
+
const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' ');
|
|
4566
|
+
const blacklisted = new Set(reservedWords.concat(builtins));
|
|
4567
|
+
const illegalCharacters = /[^$_a-zA-Z0-9]/g;
|
|
4568
|
+
const startsWithDigit = (str) => /\d/.test(str[0]);
|
|
4569
|
+
function isLegal(str) {
|
|
4570
|
+
if (startsWithDigit(str) || blacklisted.has(str)) {
|
|
4571
|
+
return false;
|
|
4509
4572
|
}
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4573
|
+
return !illegalCharacters.test(str);
|
|
4574
|
+
}
|
|
4575
|
+
function makeLegal(str) {
|
|
4576
|
+
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
|
|
4577
|
+
if (startsWithDigit(str) || blacklisted.has(str))
|
|
4578
|
+
str = `_${str}`;
|
|
4579
|
+
return str || '_';
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
class ExternalModule {
|
|
4583
|
+
constructor(options, id, hasModuleSideEffects, meta) {
|
|
4584
|
+
this.options = options;
|
|
4585
|
+
this.id = id;
|
|
4586
|
+
this.defaultVariableName = '';
|
|
4587
|
+
this.dynamicImporters = [];
|
|
4588
|
+
this.importers = [];
|
|
4589
|
+
this.mostCommonSuggestion = 0;
|
|
4590
|
+
this.namespaceVariableName = '';
|
|
4591
|
+
this.reexported = false;
|
|
4592
|
+
this.renderPath = undefined;
|
|
4593
|
+
this.renormalizeRenderPath = false;
|
|
4594
|
+
this.used = false;
|
|
4595
|
+
this.variableName = '';
|
|
4596
|
+
this.execIndex = Infinity;
|
|
4597
|
+
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
4598
|
+
this.nameSuggestions = Object.create(null);
|
|
4599
|
+
this.declarations = Object.create(null);
|
|
4600
|
+
this.exportedVariables = new Map();
|
|
4601
|
+
const module = this;
|
|
4602
|
+
this.info = {
|
|
4603
|
+
ast: null,
|
|
4604
|
+
code: null,
|
|
4605
|
+
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
4606
|
+
get dynamicImporters() {
|
|
4607
|
+
return module.dynamicImporters.sort();
|
|
4608
|
+
},
|
|
4609
|
+
hasModuleSideEffects,
|
|
4610
|
+
id,
|
|
4611
|
+
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
4612
|
+
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
4613
|
+
importedIds: EMPTY_ARRAY,
|
|
4614
|
+
get importers() {
|
|
4615
|
+
return module.importers.sort();
|
|
4616
|
+
},
|
|
4617
|
+
isEntry: false,
|
|
4618
|
+
isExternal: true,
|
|
4619
|
+
meta,
|
|
4620
|
+
syntheticNamedExports: false
|
|
4621
|
+
};
|
|
4622
|
+
}
|
|
4623
|
+
getVariableForExportName(name) {
|
|
4624
|
+
let declaration = this.declarations[name];
|
|
4625
|
+
if (declaration)
|
|
4626
|
+
return declaration;
|
|
4627
|
+
this.declarations[name] = declaration = new ExternalVariable(this, name);
|
|
4628
|
+
this.exportedVariables.set(declaration, name);
|
|
4629
|
+
return declaration;
|
|
4630
|
+
}
|
|
4631
|
+
setRenderPath(options, inputBase) {
|
|
4632
|
+
this.renderPath =
|
|
4633
|
+
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
4634
|
+
if (!this.renderPath) {
|
|
4635
|
+
if (!isAbsolute(this.id)) {
|
|
4636
|
+
this.renderPath = this.id;
|
|
4637
|
+
}
|
|
4638
|
+
else {
|
|
4639
|
+
this.renderPath = normalize(sysPath.relative(inputBase, this.id));
|
|
4640
|
+
this.renormalizeRenderPath = true;
|
|
4641
|
+
}
|
|
4520
4642
|
}
|
|
4521
|
-
return
|
|
4522
|
-
}
|
|
4523
|
-
|
|
4643
|
+
return this.renderPath;
|
|
4644
|
+
}
|
|
4645
|
+
suggestName(name) {
|
|
4646
|
+
if (!this.nameSuggestions[name])
|
|
4647
|
+
this.nameSuggestions[name] = 0;
|
|
4648
|
+
this.nameSuggestions[name] += 1;
|
|
4649
|
+
if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
|
|
4650
|
+
this.mostCommonSuggestion = this.nameSuggestions[name];
|
|
4651
|
+
this.suggestedVariableName = name;
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
warnUnusedImports() {
|
|
4655
|
+
const unused = Object.keys(this.declarations).filter(name => {
|
|
4656
|
+
if (name === '*')
|
|
4657
|
+
return false;
|
|
4658
|
+
const declaration = this.declarations[name];
|
|
4659
|
+
return !declaration.included && !this.reexported && !declaration.referenced;
|
|
4660
|
+
});
|
|
4661
|
+
if (unused.length === 0)
|
|
4662
|
+
return;
|
|
4663
|
+
const names = unused.length === 1
|
|
4664
|
+
? `'${unused[0]}' is`
|
|
4665
|
+
: `${unused
|
|
4666
|
+
.slice(0, -1)
|
|
4667
|
+
.map(name => `'${name}'`)
|
|
4668
|
+
.join(', ')} and '${unused.slice(-1)}' are`;
|
|
4669
|
+
this.options.onwarn({
|
|
4670
|
+
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
4671
|
+
message: `${names} imported from external module '${this.id}' but never used`,
|
|
4672
|
+
names: unused,
|
|
4673
|
+
source: this.id
|
|
4674
|
+
});
|
|
4675
|
+
}
|
|
4524
4676
|
}
|
|
4525
4677
|
|
|
4526
|
-
function
|
|
4527
|
-
|
|
4528
|
-
base = Object.assign(new Error(base.message), base);
|
|
4529
|
-
throw base;
|
|
4678
|
+
function removeJsExtension(name) {
|
|
4679
|
+
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
4530
4680
|
}
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4681
|
+
|
|
4682
|
+
function getCompleteAmdId(options, chunkId) {
|
|
4683
|
+
if (!options.autoId) {
|
|
4684
|
+
return options.id || '';
|
|
4535
4685
|
}
|
|
4536
4686
|
else {
|
|
4537
|
-
|
|
4538
|
-
const { line, column } = locate(source, pos, { offsetLine: 1 });
|
|
4539
|
-
props.loc = { file: id, line, column };
|
|
4540
|
-
}
|
|
4541
|
-
if (props.frame === undefined) {
|
|
4542
|
-
const { line, column } = props.loc;
|
|
4543
|
-
props.frame = getCodeFrame(source, line, column);
|
|
4687
|
+
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
4544
4688
|
}
|
|
4545
4689
|
}
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
|
|
4564
|
-
Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
|
|
4565
|
-
Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
|
|
4566
|
-
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
4567
|
-
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
4568
|
-
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
4569
|
-
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
4570
|
-
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
4571
|
-
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
4572
|
-
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
4573
|
-
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
4574
|
-
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
4575
|
-
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
4576
|
-
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
|
|
4577
|
-
Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
|
|
4578
|
-
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
4579
|
-
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
4580
|
-
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
4581
|
-
})(Errors || (Errors = {}));
|
|
4582
|
-
function errAssetNotFinalisedForFileName(name) {
|
|
4583
|
-
return {
|
|
4584
|
-
code: Errors.ASSET_NOT_FINALISED,
|
|
4585
|
-
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
4586
|
-
};
|
|
4587
|
-
}
|
|
4588
|
-
function errCannotEmitFromOptionsHook() {
|
|
4589
|
-
return {
|
|
4590
|
-
code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
|
|
4591
|
-
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
4592
|
-
};
|
|
4593
|
-
}
|
|
4594
|
-
function errChunkNotGeneratedForFileName(name) {
|
|
4595
|
-
return {
|
|
4596
|
-
code: Errors.CHUNK_NOT_GENERATED,
|
|
4597
|
-
message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
|
|
4598
|
-
};
|
|
4599
|
-
}
|
|
4600
|
-
function errCircularReexport(exportName, importedModule) {
|
|
4601
|
-
return {
|
|
4602
|
-
code: Errors.CIRCULAR_REEXPORT,
|
|
4603
|
-
id: importedModule,
|
|
4604
|
-
message: `"${exportName}" cannot be exported from ${relativeId(importedModule)} as it is a reexport that references itself.`
|
|
4605
|
-
};
|
|
4606
|
-
}
|
|
4607
|
-
function errCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
4608
|
-
return {
|
|
4609
|
-
code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
4610
|
-
exporter,
|
|
4611
|
-
importer,
|
|
4612
|
-
message: `Export "${exportName}" of module ${relativeId(exporter)} was reexported through module ${relativeId(reexporter)} while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in ${relativeId(importer)} to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
|
|
4613
|
-
reexporter
|
|
4614
|
-
};
|
|
4690
|
+
|
|
4691
|
+
const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
|
|
4692
|
+
const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
|
|
4693
|
+
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
4694
|
+
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
4695
|
+
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
4696
|
+
const defaultInteropHelpersByInteropType = {
|
|
4697
|
+
auto: INTEROP_DEFAULT_VARIABLE,
|
|
4698
|
+
default: null,
|
|
4699
|
+
defaultOnly: null,
|
|
4700
|
+
esModule: null,
|
|
4701
|
+
false: null,
|
|
4702
|
+
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
4703
|
+
};
|
|
4704
|
+
function isDefaultAProperty(interopType, externalLiveBindings) {
|
|
4705
|
+
return (interopType === 'esModule' ||
|
|
4706
|
+
(externalLiveBindings && (interopType === 'auto' || interopType === 'true')));
|
|
4615
4707
|
}
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4708
|
+
const namespaceInteropHelpersByInteropType = {
|
|
4709
|
+
auto: INTEROP_NAMESPACE_VARIABLE,
|
|
4710
|
+
default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
|
|
4711
|
+
defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
|
|
4712
|
+
esModule: null,
|
|
4713
|
+
false: null,
|
|
4714
|
+
true: INTEROP_NAMESPACE_VARIABLE
|
|
4715
|
+
};
|
|
4716
|
+
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
4717
|
+
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
4718
|
+
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
4621
4719
|
}
|
|
4622
|
-
function
|
|
4623
|
-
return
|
|
4624
|
-
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
4625
|
-
message: `Unable to set the source for asset "${name}", source already set.`
|
|
4626
|
-
};
|
|
4720
|
+
function getDefaultOnlyHelper() {
|
|
4721
|
+
return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
|
|
4627
4722
|
}
|
|
4628
|
-
function
|
|
4629
|
-
return
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
};
|
|
4723
|
+
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
|
|
4724
|
+
return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
|
|
4725
|
+
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
|
|
4726
|
+
: '').join('');
|
|
4633
4727
|
}
|
|
4634
|
-
|
|
4635
|
-
return
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
}
|
|
4728
|
+
const HELPER_GENERATORS = {
|
|
4729
|
+
[INTEROP_DEFAULT_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
4730
|
+
`e${_}&&${_}e.__esModule${_}?${_}` +
|
|
4731
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
4732
|
+
[INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
4733
|
+
`e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
|
|
4734
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
4735
|
+
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
4736
|
+
(usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
|
|
4737
|
+
? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
|
|
4738
|
+
: `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
|
|
4739
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
|
|
4740
|
+
`}${n}${n}`,
|
|
4741
|
+
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
4742
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
4743
|
+
`}${n}${n}`,
|
|
4744
|
+
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
4745
|
+
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
4746
|
+
`}${n}${n}`
|
|
4747
|
+
};
|
|
4748
|
+
function getDefaultLiveBinding(_) {
|
|
4749
|
+
return `e${_}:${_}{${_}'default':${_}e${_}}`;
|
|
4639
4750
|
}
|
|
4640
|
-
function
|
|
4641
|
-
return {
|
|
4642
|
-
code: Errors.DEPRECATED_FEATURE,
|
|
4643
|
-
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
4644
|
-
};
|
|
4751
|
+
function getDefaultStatic(_) {
|
|
4752
|
+
return `e['default']${_}:${_}e`;
|
|
4645
4753
|
}
|
|
4646
|
-
function
|
|
4647
|
-
return {
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4754
|
+
function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
|
|
4755
|
+
return (`${i}var n${_}=${_}${namespaceToStringTag
|
|
4756
|
+
? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
|
|
4757
|
+
: 'Object.create(null)'};${n}` +
|
|
4758
|
+
`${i}if${_}(e)${_}{${n}` +
|
|
4759
|
+
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
4760
|
+
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
4761
|
+
`${i}${t}});${n}` +
|
|
4762
|
+
`${i}}${n}` +
|
|
4763
|
+
`${i}n['default']${_}=${_}e;${n}` +
|
|
4764
|
+
`${i}return ${getFrozen('n', freeze)};${n}`);
|
|
4651
4765
|
}
|
|
4652
|
-
function
|
|
4653
|
-
return {
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4766
|
+
function copyPropertyLiveBinding(_, n, t, i) {
|
|
4767
|
+
return (`${i}if${_}(k${_}!==${_}'default')${_}{${n}` +
|
|
4768
|
+
`${i}${t}var d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` +
|
|
4769
|
+
`${i}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
|
|
4770
|
+
`${i}${t}${t}enumerable:${_}true,${n}` +
|
|
4771
|
+
`${i}${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4772
|
+
`${i}${t}${t}${t}return e[k];${n}` +
|
|
4773
|
+
`${i}${t}${t}}${n}` +
|
|
4774
|
+
`${i}${t}});${n}` +
|
|
4775
|
+
`${i}}${n}`);
|
|
4657
4776
|
}
|
|
4658
|
-
function
|
|
4659
|
-
return {
|
|
4660
|
-
code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
4661
|
-
message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
|
|
4662
|
-
};
|
|
4777
|
+
function copyPropertyStatic(_, n, _t, i) {
|
|
4778
|
+
return `${i}n[k]${_}=${_}e[k];${n}`;
|
|
4663
4779
|
}
|
|
4664
|
-
function
|
|
4665
|
-
return {
|
|
4666
|
-
code: Errors.INVALID_CHUNK,
|
|
4667
|
-
message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
4668
|
-
};
|
|
4780
|
+
function getFrozen(fragment, freeze) {
|
|
4781
|
+
return freeze ? `Object.freeze(${fragment})` : fragment;
|
|
4669
4782
|
}
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4783
|
+
const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
|
|
4784
|
+
|
|
4785
|
+
function getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, mechanism = 'return ') {
|
|
4786
|
+
const _ = compact ? '' : ' ';
|
|
4787
|
+
const n = compact ? '' : '\n';
|
|
4788
|
+
if (!namedExportsMode) {
|
|
4789
|
+
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings)};`;
|
|
4790
|
+
}
|
|
4791
|
+
let exportBlock = '';
|
|
4792
|
+
// star exports must always output first for precedence
|
|
4793
|
+
for (const { name, reexports } of dependencies) {
|
|
4794
|
+
if (reexports && namedExportsMode) {
|
|
4795
|
+
for (const specifier of reexports) {
|
|
4796
|
+
if (specifier.reexported === '*') {
|
|
4797
|
+
if (exportBlock)
|
|
4798
|
+
exportBlock += n;
|
|
4799
|
+
if (specifier.needsLiveBinding) {
|
|
4800
|
+
exportBlock +=
|
|
4801
|
+
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4802
|
+
`${t}if${_}(k${_}!==${_}'default')${_}Object.defineProperty(exports,${_}k,${_}{${n}` +
|
|
4803
|
+
`${t}${t}enumerable:${_}true,${n}` +
|
|
4804
|
+
`${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4805
|
+
`${t}${t}${t}return ${name}[k];${n}` +
|
|
4806
|
+
`${t}${t}}${n}${t}});${n}});`;
|
|
4807
|
+
}
|
|
4808
|
+
else {
|
|
4809
|
+
exportBlock +=
|
|
4810
|
+
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4811
|
+
`${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4818
|
+
if (reexports && namedExportsMode) {
|
|
4819
|
+
for (const specifier of reexports) {
|
|
4820
|
+
if (specifier.reexported !== '*') {
|
|
4821
|
+
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4822
|
+
if (exportBlock)
|
|
4823
|
+
exportBlock += n;
|
|
4824
|
+
exportBlock +=
|
|
4825
|
+
specifier.imported !== '*' && specifier.needsLiveBinding
|
|
4826
|
+
? `Object.defineProperty(exports,${_}'${specifier.reexported}',${_}{${n}` +
|
|
4827
|
+
`${t}enumerable:${_}true,${n}` +
|
|
4828
|
+
`${t}get:${_}function${_}()${_}{${n}` +
|
|
4829
|
+
`${t}${t}return ${importName};${n}${t}}${n}});`
|
|
4830
|
+
: `exports.${specifier.reexported}${_}=${_}${importName};`;
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
for (const chunkExport of exports) {
|
|
4836
|
+
const lhs = `exports.${chunkExport.exported}`;
|
|
4837
|
+
const rhs = chunkExport.local;
|
|
4838
|
+
if (lhs !== rhs) {
|
|
4839
|
+
if (exportBlock)
|
|
4840
|
+
exportBlock += n;
|
|
4841
|
+
exportBlock += `${lhs}${_}=${_}${rhs};`;
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
if (exportBlock) {
|
|
4845
|
+
return `${n}${n}${exportBlock}`;
|
|
4846
|
+
}
|
|
4847
|
+
return '';
|
|
4676
4848
|
}
|
|
4677
|
-
function
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4849
|
+
function getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings) {
|
|
4850
|
+
if (exports.length > 0) {
|
|
4851
|
+
return exports[0].local;
|
|
4852
|
+
}
|
|
4853
|
+
else {
|
|
4854
|
+
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4855
|
+
if (reexports) {
|
|
4856
|
+
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4682
4860
|
}
|
|
4683
|
-
function
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
message: `Cannot emit chunks after module loading has finished.`
|
|
4705
|
-
};
|
|
4706
|
-
}
|
|
4707
|
-
function errMissingExport(exportName, importingModule, importedModule) {
|
|
4708
|
-
return {
|
|
4709
|
-
code: Errors.MISSING_EXPORT,
|
|
4710
|
-
message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule)}`,
|
|
4711
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
4712
|
-
};
|
|
4713
|
-
}
|
|
4714
|
-
function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
|
|
4715
|
-
return {
|
|
4716
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4717
|
-
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
|
|
4718
|
-
};
|
|
4719
|
-
}
|
|
4720
|
-
function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
|
|
4721
|
-
return {
|
|
4722
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4723
|
-
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
|
|
4724
|
-
};
|
|
4725
|
-
}
|
|
4726
|
-
function errImplicitDependantIsNotIncluded(module) {
|
|
4727
|
-
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
4728
|
-
return {
|
|
4729
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4730
|
-
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${implicitDependencies.length === 1
|
|
4731
|
-
? implicitDependencies[0]
|
|
4732
|
-
: `${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.`
|
|
4733
|
-
};
|
|
4734
|
-
}
|
|
4735
|
-
function errMixedExport(facadeModuleId, name) {
|
|
4736
|
-
return {
|
|
4737
|
-
code: Errors.MIXED_EXPORTS,
|
|
4738
|
-
id: facadeModuleId,
|
|
4739
|
-
message: `Entry module "${relativeId(facadeModuleId)}" is using named and default exports together. Consumers of your bundle will have to use \`${name || 'chunk'}["default"]\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning`,
|
|
4740
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
4741
|
-
};
|
|
4742
|
-
}
|
|
4743
|
-
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
4744
|
-
return {
|
|
4745
|
-
code: Errors.NAMESPACE_CONFLICT,
|
|
4746
|
-
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports '${name}' from both ${relativeId(reexportingModule.exportsAll[name])} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`,
|
|
4747
|
-
name,
|
|
4748
|
-
reexporter: reexportingModule.id,
|
|
4749
|
-
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
4750
|
-
};
|
|
4751
|
-
}
|
|
4752
|
-
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
4753
|
-
return {
|
|
4754
|
-
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
4755
|
-
message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
|
|
4756
|
-
'a "code". This will be ignored.'
|
|
4757
|
-
};
|
|
4758
|
-
}
|
|
4759
|
-
function errPreferNamedExports(facadeModuleId) {
|
|
4760
|
-
const file = relativeId(facadeModuleId);
|
|
4761
|
-
return {
|
|
4762
|
-
code: Errors.PREFER_NAMED_EXPORTS,
|
|
4763
|
-
id: facadeModuleId,
|
|
4764
|
-
message: `Entry module "${file}" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "${file}" to use named exports only.`,
|
|
4765
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
4766
|
-
};
|
|
4767
|
-
}
|
|
4768
|
-
function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
|
|
4769
|
-
return {
|
|
4770
|
-
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
4771
|
-
id,
|
|
4772
|
-
message: `Module "${relativeId(id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}' needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
|
|
4773
|
-
? `an export named "${syntheticNamedExportsOption}"`
|
|
4774
|
-
: 'a default export'} that does not reexport an unresolved named export of the same module.`
|
|
4775
|
-
};
|
|
4776
|
-
}
|
|
4777
|
-
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
4778
|
-
const importType = isReexport ? 'reexport' : 'import';
|
|
4779
|
-
return {
|
|
4780
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
4781
|
-
id,
|
|
4782
|
-
message: `The named export "${imported}" was ${importType}ed from the external module ${relativeId(id)} even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`,
|
|
4783
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
4784
|
-
};
|
|
4785
|
-
}
|
|
4786
|
-
function errUnexpectedNamespaceReexport(id) {
|
|
4787
|
-
return {
|
|
4788
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
4789
|
-
id,
|
|
4790
|
-
message: `There was a namespace "*" reexport from the external module ${relativeId(id)} even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`,
|
|
4791
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
4792
|
-
};
|
|
4793
|
-
}
|
|
4794
|
-
function errEntryCannotBeExternal(unresolvedId) {
|
|
4795
|
-
return {
|
|
4796
|
-
code: Errors.UNRESOLVED_ENTRY,
|
|
4797
|
-
message: `Entry module cannot be external (${relativeId(unresolvedId)}).`
|
|
4798
|
-
};
|
|
4799
|
-
}
|
|
4800
|
-
function errUnresolvedEntry(unresolvedId) {
|
|
4801
|
-
return {
|
|
4802
|
-
code: Errors.UNRESOLVED_ENTRY,
|
|
4803
|
-
message: `Could not resolve entry module (${relativeId(unresolvedId)}).`
|
|
4804
|
-
};
|
|
4805
|
-
}
|
|
4806
|
-
function errUnresolvedImport(source, importer) {
|
|
4807
|
-
return {
|
|
4808
|
-
code: Errors.UNRESOLVED_IMPORT,
|
|
4809
|
-
message: `Could not resolve '${source}' from ${relativeId(importer)}`
|
|
4810
|
-
};
|
|
4811
|
-
}
|
|
4812
|
-
function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
4813
|
-
return {
|
|
4814
|
-
code: Errors.UNRESOLVED_IMPORT,
|
|
4815
|
-
importer: relativeId(importer),
|
|
4816
|
-
message: `'${source}' is imported by ${relativeId(importer)}, but could not be resolved – treating it as an external dependency`,
|
|
4817
|
-
source,
|
|
4818
|
-
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
4819
|
-
};
|
|
4820
|
-
}
|
|
4821
|
-
function errExternalSyntheticExports(source, importer) {
|
|
4822
|
-
return {
|
|
4823
|
-
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
4824
|
-
importer: relativeId(importer),
|
|
4825
|
-
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
4826
|
-
source
|
|
4827
|
-
};
|
|
4828
|
-
}
|
|
4829
|
-
function errFailedValidation(message) {
|
|
4830
|
-
return {
|
|
4831
|
-
code: Errors.VALIDATION_ERROR,
|
|
4832
|
-
message
|
|
4833
|
-
};
|
|
4861
|
+
function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings) {
|
|
4862
|
+
if (imported === 'default') {
|
|
4863
|
+
if (!isChunk) {
|
|
4864
|
+
const moduleInterop = String(interop(moduleId));
|
|
4865
|
+
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
4866
|
+
? defaultVariableName
|
|
4867
|
+
: moduleVariableName;
|
|
4868
|
+
return isDefaultAProperty(moduleInterop, externalLiveBindings)
|
|
4869
|
+
? `${variableName}['default']`
|
|
4870
|
+
: variableName;
|
|
4871
|
+
}
|
|
4872
|
+
return depNamedExportsMode ? `${moduleVariableName}['default']` : moduleVariableName;
|
|
4873
|
+
}
|
|
4874
|
+
if (imported === '*') {
|
|
4875
|
+
return (isChunk
|
|
4876
|
+
? !depNamedExportsMode
|
|
4877
|
+
: namespaceInteropHelpersByInteropType[String(interop(moduleId))])
|
|
4878
|
+
? namespaceVariableName
|
|
4879
|
+
: moduleVariableName;
|
|
4880
|
+
}
|
|
4881
|
+
return `${moduleVariableName}.${imported}`;
|
|
4834
4882
|
}
|
|
4835
|
-
function
|
|
4836
|
-
return {
|
|
4837
|
-
code: Errors.ALREADY_CLOSED,
|
|
4838
|
-
message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
|
|
4839
|
-
};
|
|
4883
|
+
function getEsModuleExport(_) {
|
|
4884
|
+
return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
|
|
4840
4885
|
}
|
|
4841
|
-
function
|
|
4842
|
-
|
|
4886
|
+
function getNamespaceToStringExport(_) {
|
|
4887
|
+
return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
|
|
4843
4888
|
}
|
|
4844
|
-
function
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
if (
|
|
4848
|
-
|
|
4889
|
+
function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
|
|
4890
|
+
let namespaceMarkers = '';
|
|
4891
|
+
if (hasNamedExports) {
|
|
4892
|
+
if (addEsModule) {
|
|
4893
|
+
namespaceMarkers += getEsModuleExport(_);
|
|
4894
|
+
}
|
|
4895
|
+
if (addNamespaceToStringTag) {
|
|
4896
|
+
if (namespaceMarkers) {
|
|
4897
|
+
namespaceMarkers += n;
|
|
4898
|
+
}
|
|
4899
|
+
namespaceMarkers += getNamespaceToStringExport(_);
|
|
4849
4900
|
}
|
|
4850
|
-
warn(warning);
|
|
4851
4901
|
}
|
|
4902
|
+
return namespaceMarkers;
|
|
4852
4903
|
}
|
|
4853
4904
|
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
}
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
const original = baseVariable.getOriginalVariable();
|
|
4872
|
-
if (original === baseVariable)
|
|
4905
|
+
function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t) {
|
|
4906
|
+
const neededInteropHelpers = new Set();
|
|
4907
|
+
const interopStatements = [];
|
|
4908
|
+
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
4909
|
+
neededInteropHelpers.add(helper);
|
|
4910
|
+
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
4911
|
+
};
|
|
4912
|
+
for (const { defaultVariableName, imports, id, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4913
|
+
if (isChunk) {
|
|
4914
|
+
for (const { imported, reexported } of [
|
|
4915
|
+
...(imports || []),
|
|
4916
|
+
...(reexports || [])
|
|
4917
|
+
]) {
|
|
4918
|
+
if (imported === '*' && reexported !== '*') {
|
|
4919
|
+
if (!namedExportsMode) {
|
|
4920
|
+
addInteropStatement(namespaceVariableName, getDefaultOnlyHelper(), name);
|
|
4921
|
+
}
|
|
4873
4922
|
break;
|
|
4874
|
-
|
|
4875
|
-
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
else {
|
|
4927
|
+
const moduleInterop = String(interop(id));
|
|
4928
|
+
let hasDefault = false;
|
|
4929
|
+
let hasNamespace = false;
|
|
4930
|
+
for (const { imported, reexported } of [
|
|
4931
|
+
...(imports || []),
|
|
4932
|
+
...(reexports || [])
|
|
4933
|
+
]) {
|
|
4934
|
+
let helper;
|
|
4935
|
+
let variableName;
|
|
4936
|
+
if (imported === 'default') {
|
|
4937
|
+
if (!hasDefault) {
|
|
4938
|
+
hasDefault = true;
|
|
4939
|
+
if (defaultVariableName !== namespaceVariableName) {
|
|
4940
|
+
variableName = defaultVariableName;
|
|
4941
|
+
helper = defaultInteropHelpersByInteropType[moduleInterop];
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4945
|
+
else if (imported === '*' && reexported !== '*') {
|
|
4946
|
+
if (!hasNamespace) {
|
|
4947
|
+
hasNamespace = true;
|
|
4948
|
+
helper = namespaceInteropHelpersByInteropType[moduleInterop];
|
|
4949
|
+
variableName = namespaceVariableName;
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
if (helper) {
|
|
4953
|
+
addInteropStatement(variableName, helper, name);
|
|
4954
|
+
}
|
|
4881
4955
|
}
|
|
4882
4956
|
}
|
|
4883
|
-
return (this.baseVariable = baseVariable);
|
|
4884
|
-
}
|
|
4885
|
-
getBaseVariableName() {
|
|
4886
|
-
return this.syntheticNamespace.getBaseVariableName();
|
|
4887
|
-
}
|
|
4888
|
-
getName() {
|
|
4889
|
-
const name = this.name;
|
|
4890
|
-
return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`;
|
|
4891
|
-
}
|
|
4892
|
-
include() {
|
|
4893
|
-
if (!this.included) {
|
|
4894
|
-
this.included = true;
|
|
4895
|
-
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
4896
|
-
}
|
|
4897
|
-
}
|
|
4898
|
-
setRenderNames(baseName, name) {
|
|
4899
|
-
super.setRenderNames(baseName, name);
|
|
4900
4957
|
}
|
|
4958
|
+
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4901
4959
|
}
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4960
|
+
|
|
4961
|
+
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
4962
|
+
// The assumption is that this makes sense for all relative ids:
|
|
4963
|
+
// https://requirejs.org/docs/api.html#jsfiles
|
|
4964
|
+
function removeExtensionFromRelativeAmdId(id) {
|
|
4965
|
+
return id[0] === '.' ? removeJsExtension(id) : id;
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
const builtins$1 = {
|
|
4969
|
+
assert: true,
|
|
4970
|
+
buffer: true,
|
|
4971
|
+
console: true,
|
|
4972
|
+
constants: true,
|
|
4973
|
+
domain: true,
|
|
4974
|
+
events: true,
|
|
4975
|
+
http: true,
|
|
4976
|
+
https: true,
|
|
4977
|
+
os: true,
|
|
4978
|
+
path: true,
|
|
4979
|
+
process: true,
|
|
4980
|
+
punycode: true,
|
|
4981
|
+
querystring: true,
|
|
4982
|
+
stream: true,
|
|
4983
|
+
string_decoder: true,
|
|
4984
|
+
timers: true,
|
|
4985
|
+
tty: true,
|
|
4986
|
+
url: true,
|
|
4987
|
+
util: true,
|
|
4988
|
+
vm: true,
|
|
4989
|
+
zlib: true
|
|
4906
4990
|
};
|
|
4991
|
+
function warnOnBuiltins(warn, dependencies) {
|
|
4992
|
+
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins$1);
|
|
4993
|
+
if (!externalBuiltins.length)
|
|
4994
|
+
return;
|
|
4995
|
+
const detail = externalBuiltins.length === 1
|
|
4996
|
+
? `module ('${externalBuiltins[0]}')`
|
|
4997
|
+
: `modules (${externalBuiltins
|
|
4998
|
+
.slice(0, -1)
|
|
4999
|
+
.map(name => `'${name}'`)
|
|
5000
|
+
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
5001
|
+
warn({
|
|
5002
|
+
code: 'MISSING_NODE_BUILTINS',
|
|
5003
|
+
message: `Creating a browser bundle that depends on Node.js built-in ${detail}. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills`,
|
|
5004
|
+
modules: externalBuiltins
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
4907
5007
|
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
5008
|
+
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst, warn }, { amd, compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
5009
|
+
warnOnBuiltins(warn, dependencies);
|
|
5010
|
+
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
5011
|
+
const args = dependencies.map(m => m.name);
|
|
5012
|
+
const n = compact ? '' : '\n';
|
|
5013
|
+
const s = compact ? '' : ';';
|
|
5014
|
+
const _ = compact ? '' : ' ';
|
|
5015
|
+
if (namedExportsMode && hasExports) {
|
|
5016
|
+
args.unshift(`exports`);
|
|
5017
|
+
deps.unshift(`'exports'`);
|
|
4914
5018
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
this.module.suggestName(identifier.name);
|
|
4919
|
-
}
|
|
5019
|
+
if (accessedGlobals.has('require')) {
|
|
5020
|
+
args.unshift('require');
|
|
5021
|
+
deps.unshift(`'require'`);
|
|
4920
5022
|
}
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
this.module.used = true;
|
|
4925
|
-
}
|
|
5023
|
+
if (accessedGlobals.has('module')) {
|
|
5024
|
+
args.unshift('module');
|
|
5025
|
+
deps.unshift(`'module'`);
|
|
4926
5026
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
const
|
|
4931
|
-
|
|
4932
|
-
const
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
return false;
|
|
5027
|
+
const completeAmdId = getCompleteAmdId(amd, id);
|
|
5028
|
+
const params = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
5029
|
+
(deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
5030
|
+
const useStrict = strict ? `${_}'use strict';` : '';
|
|
5031
|
+
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
5032
|
+
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
5033
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5034
|
+
if (namespaceMarkers) {
|
|
5035
|
+
namespaceMarkers = n + n + namespaceMarkers;
|
|
4937
5036
|
}
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
str = `_${str}`;
|
|
4944
|
-
return str || '_';
|
|
5037
|
+
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
5038
|
+
return magicString
|
|
5039
|
+
.indent(t)
|
|
5040
|
+
.prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
5041
|
+
.append(`${n}${n}});`);
|
|
4945
5042
|
}
|
|
4946
5043
|
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
this.namespaceVariableName = '';
|
|
4956
|
-
this.reexported = false;
|
|
4957
|
-
this.renderPath = undefined;
|
|
4958
|
-
this.renormalizeRenderPath = false;
|
|
4959
|
-
this.used = false;
|
|
4960
|
-
this.variableName = '';
|
|
4961
|
-
this.execIndex = Infinity;
|
|
4962
|
-
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
4963
|
-
this.nameSuggestions = Object.create(null);
|
|
4964
|
-
this.declarations = Object.create(null);
|
|
4965
|
-
this.exportedVariables = new Map();
|
|
4966
|
-
const module = this;
|
|
4967
|
-
this.info = {
|
|
4968
|
-
ast: null,
|
|
4969
|
-
code: null,
|
|
4970
|
-
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
4971
|
-
get dynamicImporters() {
|
|
4972
|
-
return module.dynamicImporters.sort();
|
|
4973
|
-
},
|
|
4974
|
-
hasModuleSideEffects,
|
|
4975
|
-
id,
|
|
4976
|
-
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
4977
|
-
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
4978
|
-
importedIds: EMPTY_ARRAY,
|
|
4979
|
-
get importers() {
|
|
4980
|
-
return module.importers.sort();
|
|
4981
|
-
},
|
|
4982
|
-
isEntry: false,
|
|
4983
|
-
isExternal: true,
|
|
4984
|
-
meta,
|
|
4985
|
-
syntheticNamedExports: false
|
|
4986
|
-
};
|
|
4987
|
-
}
|
|
4988
|
-
getVariableForExportName(name) {
|
|
4989
|
-
let declaration = this.declarations[name];
|
|
4990
|
-
if (declaration)
|
|
4991
|
-
return declaration;
|
|
4992
|
-
this.declarations[name] = declaration = new ExternalVariable(this, name);
|
|
4993
|
-
this.exportedVariables.set(declaration, name);
|
|
4994
|
-
return declaration;
|
|
5044
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
5045
|
+
const n = compact ? '' : '\n';
|
|
5046
|
+
const s = compact ? '' : ';';
|
|
5047
|
+
const _ = compact ? '' : ' ';
|
|
5048
|
+
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
5049
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5050
|
+
if (namespaceMarkers) {
|
|
5051
|
+
namespaceMarkers += n + n;
|
|
4995
5052
|
}
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5053
|
+
const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
|
|
5054
|
+
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
5055
|
+
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
5056
|
+
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
5057
|
+
return magicString.append(`${exportBlock}${outro}`);
|
|
5058
|
+
}
|
|
5059
|
+
function getImportBlock(dependencies, compact, varOrConst, n, _) {
|
|
5060
|
+
let importBlock = '';
|
|
5061
|
+
let definingVariable = false;
|
|
5062
|
+
for (const { id, name, reexports, imports } of dependencies) {
|
|
5063
|
+
if (!reexports && !imports) {
|
|
5064
|
+
if (importBlock) {
|
|
5065
|
+
importBlock += !compact || definingVariable ? `;${n}` : ',';
|
|
5006
5066
|
}
|
|
5067
|
+
definingVariable = false;
|
|
5068
|
+
importBlock += `require('${id}')`;
|
|
5007
5069
|
}
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
this.nameSuggestions[name] += 1;
|
|
5014
|
-
if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
|
|
5015
|
-
this.mostCommonSuggestion = this.nameSuggestions[name];
|
|
5016
|
-
this.suggestedVariableName = name;
|
|
5070
|
+
else {
|
|
5071
|
+
importBlock +=
|
|
5072
|
+
compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${varOrConst} `;
|
|
5073
|
+
definingVariable = true;
|
|
5074
|
+
importBlock += `${name}${_}=${_}require('${id}')`;
|
|
5017
5075
|
}
|
|
5018
5076
|
}
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
if (name === '*')
|
|
5022
|
-
return false;
|
|
5023
|
-
const declaration = this.declarations[name];
|
|
5024
|
-
return !declaration.included && !this.reexported && !declaration.referenced;
|
|
5025
|
-
});
|
|
5026
|
-
if (unused.length === 0)
|
|
5027
|
-
return;
|
|
5028
|
-
const names = unused.length === 1
|
|
5029
|
-
? `'${unused[0]}' is`
|
|
5030
|
-
: `${unused
|
|
5031
|
-
.slice(0, -1)
|
|
5032
|
-
.map(name => `'${name}'`)
|
|
5033
|
-
.join(', ')} and '${unused.slice(-1)}' are`;
|
|
5034
|
-
this.options.onwarn({
|
|
5035
|
-
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
5036
|
-
message: `${names} imported from external module '${this.id}' but never used`,
|
|
5037
|
-
names: unused,
|
|
5038
|
-
source: this.id
|
|
5039
|
-
});
|
|
5040
|
-
}
|
|
5041
|
-
}
|
|
5042
|
-
|
|
5043
|
-
function removeJsExtension(name) {
|
|
5044
|
-
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
5045
|
-
}
|
|
5046
|
-
|
|
5047
|
-
function getCompleteAmdId(options, chunkId) {
|
|
5048
|
-
if (!options.autoId) {
|
|
5049
|
-
return options.id || '';
|
|
5050
|
-
}
|
|
5051
|
-
else {
|
|
5052
|
-
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
5077
|
+
if (importBlock) {
|
|
5078
|
+
return `${importBlock};${n}${n}`;
|
|
5053
5079
|
}
|
|
5080
|
+
return '';
|
|
5054
5081
|
}
|
|
5055
5082
|
|
|
5056
|
-
|
|
5057
|
-
const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
|
|
5058
|
-
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
5059
|
-
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
5060
|
-
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
5061
|
-
const defaultInteropHelpersByInteropType = {
|
|
5062
|
-
auto: INTEROP_DEFAULT_VARIABLE,
|
|
5063
|
-
default: null,
|
|
5064
|
-
defaultOnly: null,
|
|
5065
|
-
esModule: null,
|
|
5066
|
-
false: null,
|
|
5067
|
-
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
5068
|
-
};
|
|
5069
|
-
function isDefaultAProperty(interopType, externalLiveBindings) {
|
|
5070
|
-
return (interopType === 'esModule' ||
|
|
5071
|
-
(externalLiveBindings && (interopType === 'auto' || interopType === 'true')));
|
|
5072
|
-
}
|
|
5073
|
-
const namespaceInteropHelpersByInteropType = {
|
|
5074
|
-
auto: INTEROP_NAMESPACE_VARIABLE,
|
|
5075
|
-
default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
|
|
5076
|
-
defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
|
|
5077
|
-
esModule: null,
|
|
5078
|
-
false: null,
|
|
5079
|
-
true: INTEROP_NAMESPACE_VARIABLE
|
|
5080
|
-
};
|
|
5081
|
-
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
5082
|
-
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
5083
|
-
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
5084
|
-
}
|
|
5085
|
-
function getDefaultOnlyHelper() {
|
|
5086
|
-
return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
|
|
5087
|
-
}
|
|
5088
|
-
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
|
|
5089
|
-
return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
|
|
5090
|
-
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
|
|
5091
|
-
: '').join('');
|
|
5092
|
-
}
|
|
5093
|
-
const HELPER_GENERATORS = {
|
|
5094
|
-
[INTEROP_DEFAULT_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
5095
|
-
`e${_}&&${_}e.__esModule${_}?${_}` +
|
|
5096
|
-
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
5097
|
-
[INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
5098
|
-
`e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
|
|
5099
|
-
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
5100
|
-
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
5101
|
-
(usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
|
|
5102
|
-
? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
|
|
5103
|
-
: `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
|
|
5104
|
-
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
|
|
5105
|
-
`}${n}${n}`,
|
|
5106
|
-
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
5107
|
-
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
5108
|
-
`}${n}${n}`,
|
|
5109
|
-
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
5110
|
-
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
5111
|
-
`}${n}${n}`
|
|
5112
|
-
};
|
|
5113
|
-
function getDefaultLiveBinding(_) {
|
|
5114
|
-
return `e${_}:${_}{${_}'default':${_}e${_}}`;
|
|
5115
|
-
}
|
|
5116
|
-
function getDefaultStatic(_) {
|
|
5117
|
-
return `e['default']${_}:${_}e`;
|
|
5118
|
-
}
|
|
5119
|
-
function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
|
|
5120
|
-
return (`${i}var n${_}=${_}${namespaceToStringTag
|
|
5121
|
-
? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
|
|
5122
|
-
: 'Object.create(null)'};${n}` +
|
|
5123
|
-
`${i}if${_}(e)${_}{${n}` +
|
|
5124
|
-
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
5125
|
-
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
5126
|
-
`${i}${t}});${n}` +
|
|
5127
|
-
`${i}}${n}` +
|
|
5128
|
-
`${i}n['default']${_}=${_}e;${n}` +
|
|
5129
|
-
`${i}return ${getFrozen('n', freeze)};${n}`);
|
|
5130
|
-
}
|
|
5131
|
-
function copyPropertyLiveBinding(_, n, t, i) {
|
|
5132
|
-
return (`${i}if${_}(k${_}!==${_}'default')${_}{${n}` +
|
|
5133
|
-
`${i}${t}var d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` +
|
|
5134
|
-
`${i}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
|
|
5135
|
-
`${i}${t}${t}enumerable:${_}true,${n}` +
|
|
5136
|
-
`${i}${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
5137
|
-
`${i}${t}${t}${t}return e[k];${n}` +
|
|
5138
|
-
`${i}${t}${t}}${n}` +
|
|
5139
|
-
`${i}${t}});${n}` +
|
|
5140
|
-
`${i}}${n}`);
|
|
5141
|
-
}
|
|
5142
|
-
function copyPropertyStatic(_, n, _t, i) {
|
|
5143
|
-
return `${i}n[k]${_}=${_}e[k];${n}`;
|
|
5144
|
-
}
|
|
5145
|
-
function getFrozen(fragment, freeze) {
|
|
5146
|
-
return freeze ? `Object.freeze(${fragment})` : fragment;
|
|
5147
|
-
}
|
|
5148
|
-
const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
|
|
5149
|
-
|
|
5150
|
-
function getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, mechanism = 'return ') {
|
|
5083
|
+
function es(magicString, { intro, outro, dependencies, exports, varOrConst }, { compact }) {
|
|
5151
5084
|
const _ = compact ? '' : ' ';
|
|
5152
5085
|
const n = compact ? '' : '\n';
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5086
|
+
const importBlock = getImportBlock$1(dependencies, _);
|
|
5087
|
+
if (importBlock.length > 0)
|
|
5088
|
+
intro += importBlock.join(n) + n + n;
|
|
5089
|
+
if (intro)
|
|
5090
|
+
magicString.prepend(intro);
|
|
5091
|
+
const exportBlock = getExportBlock$1(exports, _, varOrConst);
|
|
5092
|
+
if (exportBlock.length)
|
|
5093
|
+
magicString.append(n + n + exportBlock.join(n).trim());
|
|
5094
|
+
if (outro)
|
|
5095
|
+
magicString.append(outro);
|
|
5096
|
+
return magicString.trim();
|
|
5097
|
+
}
|
|
5098
|
+
function getImportBlock$1(dependencies, _) {
|
|
5099
|
+
const importBlock = [];
|
|
5100
|
+
for (const { id, reexports, imports, name } of dependencies) {
|
|
5101
|
+
if (!reexports && !imports) {
|
|
5102
|
+
importBlock.push(`import${_}'${id}';`);
|
|
5103
|
+
continue;
|
|
5104
|
+
}
|
|
5105
|
+
if (imports) {
|
|
5106
|
+
let defaultImport = null;
|
|
5107
|
+
let starImport = null;
|
|
5108
|
+
const importedNames = [];
|
|
5109
|
+
for (const specifier of imports) {
|
|
5110
|
+
if (specifier.imported === 'default') {
|
|
5111
|
+
defaultImport = specifier;
|
|
5112
|
+
}
|
|
5113
|
+
else if (specifier.imported === '*') {
|
|
5114
|
+
starImport = specifier;
|
|
5115
|
+
}
|
|
5116
|
+
else {
|
|
5117
|
+
importedNames.push(specifier);
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
if (starImport) {
|
|
5121
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
|
|
5122
|
+
}
|
|
5123
|
+
if (defaultImport && importedNames.length === 0) {
|
|
5124
|
+
importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
|
|
5125
|
+
}
|
|
5126
|
+
else if (importedNames.length > 0) {
|
|
5127
|
+
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
5128
|
+
.map(specifier => {
|
|
5129
|
+
if (specifier.imported === specifier.local) {
|
|
5130
|
+
return specifier.imported;
|
|
5172
5131
|
}
|
|
5173
5132
|
else {
|
|
5174
|
-
|
|
5175
|
-
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
5176
|
-
`${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
|
|
5133
|
+
return `${specifier.imported} as ${specifier.local}`;
|
|
5177
5134
|
}
|
|
5178
|
-
}
|
|
5135
|
+
})
|
|
5136
|
+
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5179
5137
|
}
|
|
5180
5138
|
}
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5139
|
+
if (reexports) {
|
|
5140
|
+
let starExport = null;
|
|
5141
|
+
const namespaceReexports = [];
|
|
5142
|
+
const namedReexports = [];
|
|
5184
5143
|
for (const specifier of reexports) {
|
|
5185
|
-
if (specifier.reexported
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
`${t}get:${_}function${_}()${_}{${n}` +
|
|
5194
|
-
`${t}${t}return ${importName};${n}${t}}${n}});`
|
|
5195
|
-
: `exports.${specifier.reexported}${_}=${_}${importName};`;
|
|
5144
|
+
if (specifier.reexported === '*') {
|
|
5145
|
+
starExport = specifier;
|
|
5146
|
+
}
|
|
5147
|
+
else if (specifier.imported === '*') {
|
|
5148
|
+
namespaceReexports.push(specifier);
|
|
5149
|
+
}
|
|
5150
|
+
else {
|
|
5151
|
+
namedReexports.push(specifier);
|
|
5196
5152
|
}
|
|
5197
5153
|
}
|
|
5154
|
+
if (starExport) {
|
|
5155
|
+
importBlock.push(`export${_}*${_}from${_}'${id}';`);
|
|
5156
|
+
}
|
|
5157
|
+
if (namespaceReexports.length > 0) {
|
|
5158
|
+
if (!imports ||
|
|
5159
|
+
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
5160
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`);
|
|
5161
|
+
}
|
|
5162
|
+
for (const specifier of namespaceReexports) {
|
|
5163
|
+
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
if (namedReexports.length > 0) {
|
|
5167
|
+
importBlock.push(`export${_}{${_}${namedReexports
|
|
5168
|
+
.map(specifier => {
|
|
5169
|
+
if (specifier.imported === specifier.reexported) {
|
|
5170
|
+
return specifier.imported;
|
|
5171
|
+
}
|
|
5172
|
+
else {
|
|
5173
|
+
return `${specifier.imported} as ${specifier.reexported}`;
|
|
5174
|
+
}
|
|
5175
|
+
})
|
|
5176
|
+
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5177
|
+
}
|
|
5198
5178
|
}
|
|
5199
5179
|
}
|
|
5200
|
-
|
|
5201
|
-
const lhs = `exports.${chunkExport.exported}`;
|
|
5202
|
-
const rhs = chunkExport.local;
|
|
5203
|
-
if (lhs !== rhs) {
|
|
5204
|
-
if (exportBlock)
|
|
5205
|
-
exportBlock += n;
|
|
5206
|
-
exportBlock += `${lhs}${_}=${_}${rhs};`;
|
|
5207
|
-
}
|
|
5208
|
-
}
|
|
5209
|
-
if (exportBlock) {
|
|
5210
|
-
return `${n}${n}${exportBlock}`;
|
|
5211
|
-
}
|
|
5212
|
-
return '';
|
|
5180
|
+
return importBlock;
|
|
5213
5181
|
}
|
|
5214
|
-
function
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5182
|
+
function getExportBlock$1(exports, _, varOrConst) {
|
|
5183
|
+
const exportBlock = [];
|
|
5184
|
+
const exportDeclaration = [];
|
|
5185
|
+
for (const specifier of exports) {
|
|
5186
|
+
if (specifier.exported === 'default') {
|
|
5187
|
+
exportBlock.push(`export default ${specifier.local};`);
|
|
5188
|
+
}
|
|
5189
|
+
else {
|
|
5190
|
+
if (specifier.expression) {
|
|
5191
|
+
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
5222
5192
|
}
|
|
5193
|
+
exportDeclaration.push(specifier.exported === specifier.local
|
|
5194
|
+
? specifier.local
|
|
5195
|
+
: `${specifier.local} as ${specifier.exported}`);
|
|
5223
5196
|
}
|
|
5224
5197
|
}
|
|
5198
|
+
if (exportDeclaration.length) {
|
|
5199
|
+
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
5200
|
+
}
|
|
5201
|
+
return exportBlock;
|
|
5225
5202
|
}
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5203
|
+
|
|
5204
|
+
function spaces(i) {
|
|
5205
|
+
let result = '';
|
|
5206
|
+
while (i--)
|
|
5207
|
+
result += ' ';
|
|
5208
|
+
return result;
|
|
5209
|
+
}
|
|
5210
|
+
function tabsToSpaces(str) {
|
|
5211
|
+
return str.replace(/^\t+/, match => match.split('\t').join(' '));
|
|
5212
|
+
}
|
|
5213
|
+
function getCodeFrame(source, line, column) {
|
|
5214
|
+
let lines = source.split('\n');
|
|
5215
|
+
const frameStart = Math.max(0, line - 3);
|
|
5216
|
+
let frameEnd = Math.min(line + 2, lines.length);
|
|
5217
|
+
lines = lines.slice(frameStart, frameEnd);
|
|
5218
|
+
while (!/\S/.test(lines[lines.length - 1])) {
|
|
5219
|
+
lines.pop();
|
|
5220
|
+
frameEnd -= 1;
|
|
5221
|
+
}
|
|
5222
|
+
const digits = String(frameEnd).length;
|
|
5223
|
+
return lines
|
|
5224
|
+
.map((str, i) => {
|
|
5225
|
+
const isErrorLine = frameStart + i + 1 === line;
|
|
5226
|
+
let lineNum = String(i + frameStart + 1);
|
|
5227
|
+
while (lineNum.length < digits)
|
|
5228
|
+
lineNum = ` ${lineNum}`;
|
|
5229
|
+
if (isErrorLine) {
|
|
5230
|
+
const indicator = spaces(digits + 2 + tabsToSpaces(str.slice(0, column)).length) + '^';
|
|
5231
|
+
return `${lineNum}: ${tabsToSpaces(str)}\n${indicator}`;
|
|
5236
5232
|
}
|
|
5237
|
-
return
|
|
5233
|
+
return `${lineNum}: ${tabsToSpaces(str)}`;
|
|
5234
|
+
})
|
|
5235
|
+
.join('\n');
|
|
5236
|
+
}
|
|
5237
|
+
|
|
5238
|
+
function error(base) {
|
|
5239
|
+
if (!(base instanceof Error))
|
|
5240
|
+
base = Object.assign(new Error(base.message), base);
|
|
5241
|
+
throw base;
|
|
5242
|
+
}
|
|
5243
|
+
function augmentCodeLocation(props, pos, source, id) {
|
|
5244
|
+
if (typeof pos === 'object') {
|
|
5245
|
+
const { line, column } = pos;
|
|
5246
|
+
props.loc = { file: id, line, column };
|
|
5238
5247
|
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5248
|
+
else {
|
|
5249
|
+
props.pos = pos;
|
|
5250
|
+
const { line, column } = locate(source, pos, { offsetLine: 1 });
|
|
5251
|
+
props.loc = { file: id, line, column };
|
|
5252
|
+
}
|
|
5253
|
+
if (props.frame === undefined) {
|
|
5254
|
+
const { line, column } = props.loc;
|
|
5255
|
+
props.frame = getCodeFrame(source, line, column);
|
|
5245
5256
|
}
|
|
5246
|
-
return `${moduleVariableName}.${imported}`;
|
|
5247
5257
|
}
|
|
5248
|
-
|
|
5249
|
-
|
|
5258
|
+
var Errors;
|
|
5259
|
+
(function (Errors) {
|
|
5260
|
+
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
5261
|
+
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
5262
|
+
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
5263
|
+
Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
|
|
5264
|
+
Errors["ASSET_SOURCE_MISSING"] = "ASSET_SOURCE_MISSING";
|
|
5265
|
+
Errors["BAD_LOADER"] = "BAD_LOADER";
|
|
5266
|
+
Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
|
|
5267
|
+
Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
|
|
5268
|
+
Errors["CIRCULAR_REEXPORT"] = "CIRCULAR_REEXPORT";
|
|
5269
|
+
Errors["CYCLIC_CROSS_CHUNK_REEXPORT"] = "CYCLIC_CROSS_CHUNK_REEXPORT";
|
|
5270
|
+
Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
|
|
5271
|
+
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
5272
|
+
Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
|
|
5273
|
+
Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
5274
|
+
Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
5275
|
+
Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
|
|
5276
|
+
Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
|
|
5277
|
+
Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
|
|
5278
|
+
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
5279
|
+
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
5280
|
+
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
5281
|
+
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
5282
|
+
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
5283
|
+
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
5284
|
+
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
5285
|
+
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
5286
|
+
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
5287
|
+
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
5288
|
+
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
|
|
5289
|
+
Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
|
|
5290
|
+
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
5291
|
+
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
5292
|
+
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
5293
|
+
})(Errors || (Errors = {}));
|
|
5294
|
+
function errAssetNotFinalisedForFileName(name) {
|
|
5295
|
+
return {
|
|
5296
|
+
code: Errors.ASSET_NOT_FINALISED,
|
|
5297
|
+
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
5298
|
+
};
|
|
5250
5299
|
}
|
|
5251
|
-
function
|
|
5252
|
-
return
|
|
5300
|
+
function errCannotEmitFromOptionsHook() {
|
|
5301
|
+
return {
|
|
5302
|
+
code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
|
|
5303
|
+
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
5304
|
+
};
|
|
5253
5305
|
}
|
|
5254
|
-
function
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
}
|
|
5260
|
-
if (addNamespaceToStringTag) {
|
|
5261
|
-
if (namespaceMarkers) {
|
|
5262
|
-
namespaceMarkers += n;
|
|
5263
|
-
}
|
|
5264
|
-
namespaceMarkers += getNamespaceToStringExport(_);
|
|
5265
|
-
}
|
|
5266
|
-
}
|
|
5267
|
-
return namespaceMarkers;
|
|
5306
|
+
function errChunkNotGeneratedForFileName(name) {
|
|
5307
|
+
return {
|
|
5308
|
+
code: Errors.CHUNK_NOT_GENERATED,
|
|
5309
|
+
message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
|
|
5310
|
+
};
|
|
5268
5311
|
}
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
neededInteropHelpers.add(helper);
|
|
5275
|
-
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
5312
|
+
function errCircularReexport(exportName, importedModule) {
|
|
5313
|
+
return {
|
|
5314
|
+
code: Errors.CIRCULAR_REEXPORT,
|
|
5315
|
+
id: importedModule,
|
|
5316
|
+
message: `"${exportName}" cannot be exported from ${relativeId(importedModule)} as it is a reexport that references itself.`
|
|
5276
5317
|
};
|
|
5277
|
-
for (const { defaultVariableName, imports, id, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
5278
|
-
if (isChunk) {
|
|
5279
|
-
for (const { imported, reexported } of [
|
|
5280
|
-
...(imports || []),
|
|
5281
|
-
...(reexports || [])
|
|
5282
|
-
]) {
|
|
5283
|
-
if (imported === '*' && reexported !== '*') {
|
|
5284
|
-
if (!namedExportsMode) {
|
|
5285
|
-
addInteropStatement(namespaceVariableName, getDefaultOnlyHelper(), name);
|
|
5286
|
-
}
|
|
5287
|
-
break;
|
|
5288
|
-
}
|
|
5289
|
-
}
|
|
5290
|
-
}
|
|
5291
|
-
else {
|
|
5292
|
-
const moduleInterop = String(interop(id));
|
|
5293
|
-
let hasDefault = false;
|
|
5294
|
-
let hasNamespace = false;
|
|
5295
|
-
for (const { imported, reexported } of [
|
|
5296
|
-
...(imports || []),
|
|
5297
|
-
...(reexports || [])
|
|
5298
|
-
]) {
|
|
5299
|
-
let helper;
|
|
5300
|
-
let variableName;
|
|
5301
|
-
if (imported === 'default') {
|
|
5302
|
-
if (!hasDefault) {
|
|
5303
|
-
hasDefault = true;
|
|
5304
|
-
if (defaultVariableName !== namespaceVariableName) {
|
|
5305
|
-
variableName = defaultVariableName;
|
|
5306
|
-
helper = defaultInteropHelpersByInteropType[moduleInterop];
|
|
5307
|
-
}
|
|
5308
|
-
}
|
|
5309
|
-
}
|
|
5310
|
-
else if (imported === '*' && reexported !== '*') {
|
|
5311
|
-
if (!hasNamespace) {
|
|
5312
|
-
hasNamespace = true;
|
|
5313
|
-
helper = namespaceInteropHelpersByInteropType[moduleInterop];
|
|
5314
|
-
variableName = namespaceVariableName;
|
|
5315
|
-
}
|
|
5316
|
-
}
|
|
5317
|
-
if (helper) {
|
|
5318
|
-
addInteropStatement(variableName, helper, name);
|
|
5319
|
-
}
|
|
5320
|
-
}
|
|
5321
|
-
}
|
|
5322
|
-
}
|
|
5323
|
-
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
5324
5318
|
}
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5319
|
+
function errCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
5320
|
+
return {
|
|
5321
|
+
code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
5322
|
+
exporter,
|
|
5323
|
+
importer,
|
|
5324
|
+
message: `Export "${exportName}" of module ${relativeId(exporter)} was reexported through module ${relativeId(reexporter)} while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in ${relativeId(importer)} to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
|
|
5325
|
+
reexporter
|
|
5326
|
+
};
|
|
5331
5327
|
}
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
}
|
|
5356
|
-
function
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5328
|
+
function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
|
|
5329
|
+
return {
|
|
5330
|
+
code: Errors.ASSET_NOT_FOUND,
|
|
5331
|
+
message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
|
|
5332
|
+
};
|
|
5333
|
+
}
|
|
5334
|
+
function errAssetSourceAlreadySet(name) {
|
|
5335
|
+
return {
|
|
5336
|
+
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
5337
|
+
message: `Unable to set the source for asset "${name}", source already set.`
|
|
5338
|
+
};
|
|
5339
|
+
}
|
|
5340
|
+
function errNoAssetSourceSet(assetName) {
|
|
5341
|
+
return {
|
|
5342
|
+
code: Errors.ASSET_SOURCE_MISSING,
|
|
5343
|
+
message: `Plugin error creating asset "${assetName}" - no asset source set.`
|
|
5344
|
+
};
|
|
5345
|
+
}
|
|
5346
|
+
function errBadLoader(id) {
|
|
5347
|
+
return {
|
|
5348
|
+
code: Errors.BAD_LOADER,
|
|
5349
|
+
message: `Error loading ${relativeId(id)}: plugin load hook should return a string, a { code, map } object, or nothing/null`
|
|
5350
|
+
};
|
|
5351
|
+
}
|
|
5352
|
+
function errDeprecation(deprecation) {
|
|
5353
|
+
return {
|
|
5354
|
+
code: Errors.DEPRECATED_FEATURE,
|
|
5355
|
+
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
5356
|
+
};
|
|
5357
|
+
}
|
|
5358
|
+
function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
|
|
5359
|
+
return {
|
|
5360
|
+
code: Errors.FILE_NOT_FOUND,
|
|
5361
|
+
message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
|
|
5362
|
+
};
|
|
5363
|
+
}
|
|
5364
|
+
function errFileNameConflict(fileName) {
|
|
5365
|
+
return {
|
|
5366
|
+
code: Errors.FILE_NAME_CONFLICT,
|
|
5367
|
+
message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
|
|
5368
|
+
};
|
|
5369
|
+
}
|
|
5370
|
+
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
5371
|
+
return {
|
|
5372
|
+
code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
5373
|
+
message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
|
|
5374
|
+
};
|
|
5375
|
+
}
|
|
5376
|
+
function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
|
|
5377
|
+
return {
|
|
5378
|
+
code: Errors.INVALID_CHUNK,
|
|
5379
|
+
message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
5380
|
+
};
|
|
5381
|
+
}
|
|
5382
|
+
function errInvalidExportOptionValue(optionValue) {
|
|
5383
|
+
return {
|
|
5384
|
+
code: Errors.INVALID_EXPORT_OPTION,
|
|
5385
|
+
message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`,
|
|
5386
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5387
|
+
};
|
|
5388
|
+
}
|
|
5389
|
+
function errIncompatibleExportOptionValue(optionValue, keys, entryModule) {
|
|
5390
|
+
return {
|
|
5391
|
+
code: 'INVALID_EXPORT_OPTION',
|
|
5392
|
+
message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${keys.join(', ')}`
|
|
5393
|
+
};
|
|
5394
|
+
}
|
|
5395
|
+
function errInternalIdCannotBeExternal(source, importer) {
|
|
5396
|
+
return {
|
|
5397
|
+
code: Errors.INVALID_EXTERNAL_ID,
|
|
5398
|
+
message: `'${source}' is imported as an external by ${relativeId(importer)}, but is already an existing non-external module id.`
|
|
5399
|
+
};
|
|
5400
|
+
}
|
|
5401
|
+
function errInvalidOption(option, explanation) {
|
|
5402
|
+
return {
|
|
5403
|
+
code: Errors.INVALID_OPTION,
|
|
5404
|
+
message: `Invalid value for option "${option}" - ${explanation}.`
|
|
5405
|
+
};
|
|
5406
|
+
}
|
|
5407
|
+
function errInvalidRollupPhaseForAddWatchFile() {
|
|
5408
|
+
return {
|
|
5409
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5410
|
+
message: `Cannot call addWatchFile after the build has finished.`
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
function errInvalidRollupPhaseForChunkEmission() {
|
|
5414
|
+
return {
|
|
5415
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5416
|
+
message: `Cannot emit chunks after module loading has finished.`
|
|
5417
|
+
};
|
|
5418
|
+
}
|
|
5419
|
+
function errMissingExport(exportName, importingModule, importedModule) {
|
|
5420
|
+
return {
|
|
5421
|
+
code: Errors.MISSING_EXPORT,
|
|
5422
|
+
message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule)}`,
|
|
5423
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
5424
|
+
};
|
|
5425
|
+
}
|
|
5426
|
+
function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
|
|
5427
|
+
return {
|
|
5428
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5429
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
|
|
5430
|
+
};
|
|
5431
|
+
}
|
|
5432
|
+
function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
|
|
5433
|
+
return {
|
|
5434
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5435
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5438
|
+
function errImplicitDependantIsNotIncluded(module) {
|
|
5439
|
+
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
5440
|
+
return {
|
|
5441
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5442
|
+
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${implicitDependencies.length === 1
|
|
5443
|
+
? implicitDependencies[0]
|
|
5444
|
+
: `${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.`
|
|
5445
|
+
};
|
|
5446
|
+
}
|
|
5447
|
+
function errMixedExport(facadeModuleId, name) {
|
|
5448
|
+
return {
|
|
5449
|
+
code: Errors.MIXED_EXPORTS,
|
|
5450
|
+
id: facadeModuleId,
|
|
5451
|
+
message: `Entry module "${relativeId(facadeModuleId)}" is using named and default exports together. Consumers of your bundle will have to use \`${name || 'chunk'}["default"]\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning`,
|
|
5452
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5453
|
+
};
|
|
5454
|
+
}
|
|
5455
|
+
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
5456
|
+
return {
|
|
5457
|
+
code: Errors.NAMESPACE_CONFLICT,
|
|
5458
|
+
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports '${name}' from both ${relativeId(reexportingModule.exportsAll[name])} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`,
|
|
5459
|
+
name,
|
|
5460
|
+
reexporter: reexportingModule.id,
|
|
5461
|
+
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
5462
|
+
};
|
|
5463
|
+
}
|
|
5464
|
+
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
5465
|
+
return {
|
|
5466
|
+
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
5467
|
+
message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
|
|
5468
|
+
'a "code". This will be ignored.'
|
|
5469
|
+
};
|
|
5470
|
+
}
|
|
5471
|
+
function errPreferNamedExports(facadeModuleId) {
|
|
5472
|
+
const file = relativeId(facadeModuleId);
|
|
5473
|
+
return {
|
|
5474
|
+
code: Errors.PREFER_NAMED_EXPORTS,
|
|
5475
|
+
id: facadeModuleId,
|
|
5476
|
+
message: `Entry module "${file}" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "${file}" to use named exports only.`,
|
|
5477
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5478
|
+
};
|
|
5479
|
+
}
|
|
5480
|
+
function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
|
|
5481
|
+
return {
|
|
5482
|
+
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
5483
|
+
id,
|
|
5484
|
+
message: `Module "${relativeId(id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}' needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
|
|
5485
|
+
? `an export named "${syntheticNamedExportsOption}"`
|
|
5486
|
+
: 'a default export'} that does not reexport an unresolved named export of the same module.`
|
|
5487
|
+
};
|
|
5488
|
+
}
|
|
5489
|
+
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
5490
|
+
const importType = isReexport ? 'reexport' : 'import';
|
|
5491
|
+
return {
|
|
5492
|
+
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5493
|
+
id,
|
|
5494
|
+
message: `The named export "${imported}" was ${importType}ed from the external module ${relativeId(id)} even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`,
|
|
5495
|
+
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5496
|
+
};
|
|
5497
|
+
}
|
|
5498
|
+
function errUnexpectedNamespaceReexport(id) {
|
|
5499
|
+
return {
|
|
5500
|
+
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5501
|
+
id,
|
|
5502
|
+
message: `There was a namespace "*" reexport from the external module ${relativeId(id)} even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`,
|
|
5503
|
+
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5504
|
+
};
|
|
5371
5505
|
}
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
const n = compact ? '' : '\n';
|
|
5378
|
-
const s = compact ? '' : ';';
|
|
5379
|
-
const _ = compact ? '' : ' ';
|
|
5380
|
-
if (namedExportsMode && hasExports) {
|
|
5381
|
-
args.unshift(`exports`);
|
|
5382
|
-
deps.unshift(`'exports'`);
|
|
5383
|
-
}
|
|
5384
|
-
if (accessedGlobals.has('require')) {
|
|
5385
|
-
args.unshift('require');
|
|
5386
|
-
deps.unshift(`'require'`);
|
|
5387
|
-
}
|
|
5388
|
-
if (accessedGlobals.has('module')) {
|
|
5389
|
-
args.unshift('module');
|
|
5390
|
-
deps.unshift(`'module'`);
|
|
5391
|
-
}
|
|
5392
|
-
const completeAmdId = getCompleteAmdId(amd, id);
|
|
5393
|
-
const params = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
5394
|
-
(deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
5395
|
-
const useStrict = strict ? `${_}'use strict';` : '';
|
|
5396
|
-
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
5397
|
-
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
5398
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5399
|
-
if (namespaceMarkers) {
|
|
5400
|
-
namespaceMarkers = n + n + namespaceMarkers;
|
|
5401
|
-
}
|
|
5402
|
-
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
5403
|
-
return magicString
|
|
5404
|
-
.indent(t)
|
|
5405
|
-
.prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
5406
|
-
.append(`${n}${n}});`);
|
|
5506
|
+
function errEntryCannotBeExternal(unresolvedId) {
|
|
5507
|
+
return {
|
|
5508
|
+
code: Errors.UNRESOLVED_ENTRY,
|
|
5509
|
+
message: `Entry module cannot be external (${relativeId(unresolvedId)}).`
|
|
5510
|
+
};
|
|
5407
5511
|
}
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
5414
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5415
|
-
if (namespaceMarkers) {
|
|
5416
|
-
namespaceMarkers += n + n;
|
|
5417
|
-
}
|
|
5418
|
-
const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
|
|
5419
|
-
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
5420
|
-
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
5421
|
-
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
5422
|
-
return magicString.append(`${exportBlock}${outro}`);
|
|
5512
|
+
function errUnresolvedEntry(unresolvedId) {
|
|
5513
|
+
return {
|
|
5514
|
+
code: Errors.UNRESOLVED_ENTRY,
|
|
5515
|
+
message: `Could not resolve entry module (${relativeId(unresolvedId)}).`
|
|
5516
|
+
};
|
|
5423
5517
|
}
|
|
5424
|
-
function
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
if (importBlock) {
|
|
5430
|
-
importBlock += !compact || definingVariable ? `;${n}` : ',';
|
|
5431
|
-
}
|
|
5432
|
-
definingVariable = false;
|
|
5433
|
-
importBlock += `require('${id}')`;
|
|
5434
|
-
}
|
|
5435
|
-
else {
|
|
5436
|
-
importBlock +=
|
|
5437
|
-
compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${varOrConst} `;
|
|
5438
|
-
definingVariable = true;
|
|
5439
|
-
importBlock += `${name}${_}=${_}require('${id}')`;
|
|
5440
|
-
}
|
|
5441
|
-
}
|
|
5442
|
-
if (importBlock) {
|
|
5443
|
-
return `${importBlock};${n}${n}`;
|
|
5444
|
-
}
|
|
5445
|
-
return '';
|
|
5518
|
+
function errUnresolvedImport(source, importer) {
|
|
5519
|
+
return {
|
|
5520
|
+
code: Errors.UNRESOLVED_IMPORT,
|
|
5521
|
+
message: `Could not resolve '${source}' from ${relativeId(importer)}`
|
|
5522
|
+
};
|
|
5446
5523
|
}
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
magicString.prepend(intro);
|
|
5456
|
-
const exportBlock = getExportBlock$1(exports, _, varOrConst);
|
|
5457
|
-
if (exportBlock.length)
|
|
5458
|
-
magicString.append(n + n + exportBlock.join(n).trim());
|
|
5459
|
-
if (outro)
|
|
5460
|
-
magicString.append(outro);
|
|
5461
|
-
return magicString.trim();
|
|
5524
|
+
function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
5525
|
+
return {
|
|
5526
|
+
code: Errors.UNRESOLVED_IMPORT,
|
|
5527
|
+
importer: relativeId(importer),
|
|
5528
|
+
message: `'${source}' is imported by ${relativeId(importer)}, but could not be resolved – treating it as an external dependency`,
|
|
5529
|
+
source,
|
|
5530
|
+
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
5531
|
+
};
|
|
5462
5532
|
}
|
|
5463
|
-
function
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
if (imports) {
|
|
5471
|
-
let defaultImport = null;
|
|
5472
|
-
let starImport = null;
|
|
5473
|
-
const importedNames = [];
|
|
5474
|
-
for (const specifier of imports) {
|
|
5475
|
-
if (specifier.imported === 'default') {
|
|
5476
|
-
defaultImport = specifier;
|
|
5477
|
-
}
|
|
5478
|
-
else if (specifier.imported === '*') {
|
|
5479
|
-
starImport = specifier;
|
|
5480
|
-
}
|
|
5481
|
-
else {
|
|
5482
|
-
importedNames.push(specifier);
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
if (starImport) {
|
|
5486
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
|
|
5487
|
-
}
|
|
5488
|
-
if (defaultImport && importedNames.length === 0) {
|
|
5489
|
-
importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
|
|
5490
|
-
}
|
|
5491
|
-
else if (importedNames.length > 0) {
|
|
5492
|
-
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
5493
|
-
.map(specifier => {
|
|
5494
|
-
if (specifier.imported === specifier.local) {
|
|
5495
|
-
return specifier.imported;
|
|
5496
|
-
}
|
|
5497
|
-
else {
|
|
5498
|
-
return `${specifier.imported} as ${specifier.local}`;
|
|
5499
|
-
}
|
|
5500
|
-
})
|
|
5501
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5502
|
-
}
|
|
5503
|
-
}
|
|
5504
|
-
if (reexports) {
|
|
5505
|
-
let starExport = null;
|
|
5506
|
-
const namespaceReexports = [];
|
|
5507
|
-
const namedReexports = [];
|
|
5508
|
-
for (const specifier of reexports) {
|
|
5509
|
-
if (specifier.reexported === '*') {
|
|
5510
|
-
starExport = specifier;
|
|
5511
|
-
}
|
|
5512
|
-
else if (specifier.imported === '*') {
|
|
5513
|
-
namespaceReexports.push(specifier);
|
|
5514
|
-
}
|
|
5515
|
-
else {
|
|
5516
|
-
namedReexports.push(specifier);
|
|
5517
|
-
}
|
|
5518
|
-
}
|
|
5519
|
-
if (starExport) {
|
|
5520
|
-
importBlock.push(`export${_}*${_}from${_}'${id}';`);
|
|
5521
|
-
}
|
|
5522
|
-
if (namespaceReexports.length > 0) {
|
|
5523
|
-
if (!imports ||
|
|
5524
|
-
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
5525
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`);
|
|
5526
|
-
}
|
|
5527
|
-
for (const specifier of namespaceReexports) {
|
|
5528
|
-
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
5529
|
-
}
|
|
5530
|
-
}
|
|
5531
|
-
if (namedReexports.length > 0) {
|
|
5532
|
-
importBlock.push(`export${_}{${_}${namedReexports
|
|
5533
|
-
.map(specifier => {
|
|
5534
|
-
if (specifier.imported === specifier.reexported) {
|
|
5535
|
-
return specifier.imported;
|
|
5536
|
-
}
|
|
5537
|
-
else {
|
|
5538
|
-
return `${specifier.imported} as ${specifier.reexported}`;
|
|
5539
|
-
}
|
|
5540
|
-
})
|
|
5541
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5542
|
-
}
|
|
5543
|
-
}
|
|
5544
|
-
}
|
|
5545
|
-
return importBlock;
|
|
5533
|
+
function errExternalSyntheticExports(source, importer) {
|
|
5534
|
+
return {
|
|
5535
|
+
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
5536
|
+
importer: relativeId(importer),
|
|
5537
|
+
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
5538
|
+
source
|
|
5539
|
+
};
|
|
5546
5540
|
}
|
|
5547
|
-
function
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5541
|
+
function errFailedValidation(message) {
|
|
5542
|
+
return {
|
|
5543
|
+
code: Errors.VALIDATION_ERROR,
|
|
5544
|
+
message
|
|
5545
|
+
};
|
|
5546
|
+
}
|
|
5547
|
+
function errAlreadyClosed() {
|
|
5548
|
+
return {
|
|
5549
|
+
code: Errors.ALREADY_CLOSED,
|
|
5550
|
+
message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
|
|
5551
|
+
};
|
|
5552
|
+
}
|
|
5553
|
+
function warnDeprecation(deprecation, activeDeprecation, options) {
|
|
5554
|
+
warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
|
|
5555
|
+
}
|
|
5556
|
+
function warnDeprecationWithOptions(deprecation, activeDeprecation, warn, strictDeprecations) {
|
|
5557
|
+
if (activeDeprecation || strictDeprecations) {
|
|
5558
|
+
const warning = errDeprecation(deprecation);
|
|
5559
|
+
if (strictDeprecations) {
|
|
5560
|
+
return error(warning);
|
|
5561
5561
|
}
|
|
5562
|
+
warn(warning);
|
|
5562
5563
|
}
|
|
5563
|
-
if (exportDeclaration.length) {
|
|
5564
|
-
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
5565
|
-
}
|
|
5566
|
-
return exportBlock;
|
|
5567
5564
|
}
|
|
5568
5565
|
|
|
5569
5566
|
// Generate strings which dereference dotted properties, but use array notation `['prop-deref']`
|
|
@@ -7179,7 +7176,7 @@ class DoWhileStatement extends NodeBase {
|
|
|
7179
7176
|
this.included = true;
|
|
7180
7177
|
this.test.include(context, includeChildrenRecursively);
|
|
7181
7178
|
const { brokenFlow } = context;
|
|
7182
|
-
this.body.
|
|
7179
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7183
7180
|
context.brokenFlow = brokenFlow;
|
|
7184
7181
|
}
|
|
7185
7182
|
}
|
|
@@ -7253,11 +7250,11 @@ class ForInStatement extends NodeBase {
|
|
|
7253
7250
|
}
|
|
7254
7251
|
include(context, includeChildrenRecursively) {
|
|
7255
7252
|
this.included = true;
|
|
7256
|
-
this.left.
|
|
7253
|
+
this.left.include(context, includeChildrenRecursively || true);
|
|
7257
7254
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7258
7255
|
this.right.include(context, includeChildrenRecursively);
|
|
7259
7256
|
const { brokenFlow } = context;
|
|
7260
|
-
this.body.
|
|
7257
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7261
7258
|
context.brokenFlow = brokenFlow;
|
|
7262
7259
|
}
|
|
7263
7260
|
render(code, options) {
|
|
@@ -7287,11 +7284,11 @@ class ForOfStatement extends NodeBase {
|
|
|
7287
7284
|
}
|
|
7288
7285
|
include(context, includeChildrenRecursively) {
|
|
7289
7286
|
this.included = true;
|
|
7290
|
-
this.left.
|
|
7287
|
+
this.left.include(context, includeChildrenRecursively || true);
|
|
7291
7288
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7292
7289
|
this.right.include(context, includeChildrenRecursively);
|
|
7293
7290
|
const { brokenFlow } = context;
|
|
7294
|
-
this.body.
|
|
7291
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7295
7292
|
context.brokenFlow = brokenFlow;
|
|
7296
7293
|
}
|
|
7297
7294
|
render(code, options) {
|
|
@@ -7327,13 +7324,13 @@ class ForStatement extends NodeBase {
|
|
|
7327
7324
|
include(context, includeChildrenRecursively) {
|
|
7328
7325
|
this.included = true;
|
|
7329
7326
|
if (this.init)
|
|
7330
|
-
this.init.
|
|
7327
|
+
this.init.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7331
7328
|
if (this.test)
|
|
7332
7329
|
this.test.include(context, includeChildrenRecursively);
|
|
7333
7330
|
const { brokenFlow } = context;
|
|
7334
7331
|
if (this.update)
|
|
7335
7332
|
this.update.include(context, includeChildrenRecursively);
|
|
7336
|
-
this.body.
|
|
7333
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7337
7334
|
context.brokenFlow = brokenFlow;
|
|
7338
7335
|
}
|
|
7339
7336
|
render(code, options) {
|
|
@@ -7474,10 +7471,10 @@ class IfStatement extends NodeBase {
|
|
|
7474
7471
|
this.test.include(context, false);
|
|
7475
7472
|
}
|
|
7476
7473
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
7477
|
-
this.consequent.
|
|
7474
|
+
this.consequent.includeAsSingleStatement(context, false);
|
|
7478
7475
|
}
|
|
7479
7476
|
if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) {
|
|
7480
|
-
this.alternate.
|
|
7477
|
+
this.alternate.includeAsSingleStatement(context, false);
|
|
7481
7478
|
}
|
|
7482
7479
|
}
|
|
7483
7480
|
includeRecursively(includeChildrenRecursively, context) {
|
|
@@ -7492,12 +7489,12 @@ class IfStatement extends NodeBase {
|
|
|
7492
7489
|
const { brokenFlow } = context;
|
|
7493
7490
|
let consequentBrokenFlow = BROKEN_FLOW_NONE;
|
|
7494
7491
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
7495
|
-
this.consequent.
|
|
7492
|
+
this.consequent.includeAsSingleStatement(context, false);
|
|
7496
7493
|
consequentBrokenFlow = context.brokenFlow;
|
|
7497
7494
|
context.brokenFlow = brokenFlow;
|
|
7498
7495
|
}
|
|
7499
7496
|
if (this.alternate !== null && this.alternate.shouldBeIncluded(context)) {
|
|
7500
|
-
this.alternate.
|
|
7497
|
+
this.alternate.includeAsSingleStatement(context, false);
|
|
7501
7498
|
context.brokenFlow =
|
|
7502
7499
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
7503
7500
|
}
|
|
@@ -9013,11 +9010,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
9013
9010
|
declarator.include(context, includeChildrenRecursively);
|
|
9014
9011
|
}
|
|
9015
9012
|
}
|
|
9016
|
-
|
|
9013
|
+
includeAsSingleStatement(context, includeChildrenRecursively) {
|
|
9017
9014
|
this.included = true;
|
|
9018
9015
|
for (const declarator of this.declarations) {
|
|
9019
|
-
declarator.
|
|
9020
|
-
|
|
9016
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
|
|
9017
|
+
declarator.include(context, includeChildrenRecursively);
|
|
9018
|
+
declarator.id.include(context, includeChildrenRecursively);
|
|
9019
|
+
}
|
|
9021
9020
|
}
|
|
9022
9021
|
}
|
|
9023
9022
|
initialise() {
|
|
@@ -9039,11 +9038,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
9039
9038
|
this.renderReplacedDeclarations(code, options, nodeRenderOptions);
|
|
9040
9039
|
}
|
|
9041
9040
|
}
|
|
9042
|
-
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
9041
|
+
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement) {
|
|
9043
9042
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
9044
9043
|
code.remove(this.end - 1, this.end);
|
|
9045
9044
|
}
|
|
9046
|
-
|
|
9045
|
+
if (!isNoStatement) {
|
|
9046
|
+
separatorString += ';';
|
|
9047
|
+
}
|
|
9047
9048
|
if (lastSeparatorPos !== null) {
|
|
9048
9049
|
if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
|
|
9049
9050
|
(code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
|
|
@@ -9068,7 +9069,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9068
9069
|
code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
|
|
9069
9070
|
}
|
|
9070
9071
|
}
|
|
9071
|
-
renderReplacedDeclarations(code, options, { start = this.start, end = this.end }) {
|
|
9072
|
+
renderReplacedDeclarations(code, options, { start = this.start, end = this.end, isNoStatement }) {
|
|
9072
9073
|
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
|
|
9073
9074
|
let actualContentEnd, renderedContentEnd;
|
|
9074
9075
|
renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
|
|
@@ -9139,7 +9140,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9139
9140
|
separatorString = nextSeparatorString;
|
|
9140
9141
|
}
|
|
9141
9142
|
if (hasRenderedContent) {
|
|
9142
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options);
|
|
9143
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement);
|
|
9143
9144
|
}
|
|
9144
9145
|
else {
|
|
9145
9146
|
code.remove(start, end);
|
|
@@ -9166,10 +9167,6 @@ class VariableDeclarator extends NodeBase {
|
|
|
9166
9167
|
this.init.include(context, includeChildrenRecursively);
|
|
9167
9168
|
}
|
|
9168
9169
|
}
|
|
9169
|
-
includeAllDeclaredVariables(context, includeChildrenRecursively) {
|
|
9170
|
-
this.included = true;
|
|
9171
|
-
this.id.include(context, includeChildrenRecursively);
|
|
9172
|
-
}
|
|
9173
9170
|
render(code, options) {
|
|
9174
9171
|
const renderId = this.id.included;
|
|
9175
9172
|
if (renderId) {
|
|
@@ -9203,7 +9200,7 @@ class WhileStatement extends NodeBase {
|
|
|
9203
9200
|
this.included = true;
|
|
9204
9201
|
this.test.include(context, includeChildrenRecursively);
|
|
9205
9202
|
const { brokenFlow } = context;
|
|
9206
|
-
this.body.
|
|
9203
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
9207
9204
|
context.brokenFlow = brokenFlow;
|
|
9208
9205
|
}
|
|
9209
9206
|
}
|
|
@@ -9830,7 +9827,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
9830
9827
|
if (!currentVariable || referencedVariables.has(currentVariable)) {
|
|
9831
9828
|
break;
|
|
9832
9829
|
}
|
|
9833
|
-
referencedVariables.add(
|
|
9830
|
+
referencedVariables.add(currentVariable);
|
|
9834
9831
|
sideEffectModules.add(importingModule);
|
|
9835
9832
|
const originalSideEffects = importingModule.sideEffectDependenciesByVariable.get(currentVariable);
|
|
9836
9833
|
if (originalSideEffects) {
|
|
@@ -10532,14 +10529,16 @@ class Module {
|
|
|
10532
10529
|
variable.include();
|
|
10533
10530
|
this.graph.needsTreeshakingPass = true;
|
|
10534
10531
|
const variableModule = variable.module;
|
|
10535
|
-
if (variableModule && variableModule
|
|
10532
|
+
if (variableModule && variableModule instanceof Module) {
|
|
10536
10533
|
if (!variableModule.isExecuted) {
|
|
10537
10534
|
markModuleAndImpureDependenciesAsExecuted(variableModule);
|
|
10538
10535
|
}
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10536
|
+
if (variableModule !== this) {
|
|
10537
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
10538
|
+
for (const module of sideEffectModules) {
|
|
10539
|
+
if (!module.isExecuted) {
|
|
10540
|
+
markModuleAndImpureDependenciesAsExecuted(module);
|
|
10541
|
+
}
|
|
10543
10542
|
}
|
|
10544
10543
|
}
|
|
10545
10544
|
}
|
|
@@ -18113,7 +18112,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, skip,
|
|
|
18113
18112
|
// absolute path is created. Absolute importees therefore shortcircuit the
|
|
18114
18113
|
// resolve call and require no special handing on our part.
|
|
18115
18114
|
// See https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
18116
|
-
return addJsExtensionIfNecessary(
|
|
18115
|
+
return addJsExtensionIfNecessary(importer ? sysPath.resolve(sysPath.dirname(importer), source) : sysPath.resolve(source), preserveSymlinks);
|
|
18117
18116
|
}
|
|
18118
18117
|
function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
18119
18118
|
let found = findFile(file, preserveSymlinks);
|