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/es/shared/rollup.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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
|
|
8
8
|
|
|
9
9
|
Released under the MIT License.
|
|
10
10
|
*/
|
|
11
|
-
import { relative as relative$1, extname, basename, dirname
|
|
11
|
+
import { relative as relative$1, resolve, extname, basename, dirname } from 'path';
|
|
12
12
|
import { createHash as createHash$1 } from 'crypto';
|
|
13
13
|
import { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$1, lstatSync, realpathSync } from 'fs';
|
|
14
14
|
import { EventEmitter } from 'events';
|
|
15
15
|
|
|
16
|
-
var version = "2.38.
|
|
16
|
+
var version = "2.38.4";
|
|
17
17
|
|
|
18
18
|
var charToInteger = {};
|
|
19
19
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -2674,7 +2674,7 @@ class NodeBase {
|
|
|
2674
2674
|
}
|
|
2675
2675
|
}
|
|
2676
2676
|
}
|
|
2677
|
-
|
|
2677
|
+
includeAsSingleStatement(context, includeChildrenRecursively) {
|
|
2678
2678
|
this.include(context, includeChildrenRecursively);
|
|
2679
2679
|
}
|
|
2680
2680
|
includeCallArguments(context, args) {
|
|
@@ -4261,7 +4261,9 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
4261
4261
|
return this.originalId &&
|
|
4262
4262
|
(this.hasId ||
|
|
4263
4263
|
!(this.originalId.variable.isReassigned ||
|
|
4264
|
-
this.originalId.variable instanceof UndefinedVariable
|
|
4264
|
+
this.originalId.variable instanceof UndefinedVariable ||
|
|
4265
|
+
// this avoids a circular dependency
|
|
4266
|
+
'syntheticNamespace' in this.originalId.variable))
|
|
4265
4267
|
? this.originalId.variable
|
|
4266
4268
|
: null;
|
|
4267
4269
|
}
|
|
@@ -4398,38 +4400,92 @@ class NamespaceVariable extends Variable {
|
|
|
4398
4400
|
}
|
|
4399
4401
|
NamespaceVariable.prototype.isNamespace = true;
|
|
4400
4402
|
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4403
|
+
class SyntheticNamedExportVariable extends Variable {
|
|
4404
|
+
constructor(context, name, syntheticNamespace) {
|
|
4405
|
+
super(name);
|
|
4406
|
+
this.baseVariable = null;
|
|
4407
|
+
this.context = context;
|
|
4408
|
+
this.module = context.module;
|
|
4409
|
+
this.syntheticNamespace = syntheticNamespace;
|
|
4410
|
+
}
|
|
4411
|
+
getBaseVariable() {
|
|
4412
|
+
if (this.baseVariable)
|
|
4413
|
+
return this.baseVariable;
|
|
4414
|
+
let baseVariable = this.syntheticNamespace;
|
|
4415
|
+
while (baseVariable instanceof ExportDefaultVariable ||
|
|
4416
|
+
baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4417
|
+
if (baseVariable instanceof ExportDefaultVariable) {
|
|
4418
|
+
const original = baseVariable.getOriginalVariable();
|
|
4419
|
+
if (original === baseVariable)
|
|
4420
|
+
break;
|
|
4421
|
+
baseVariable = original;
|
|
4422
|
+
}
|
|
4423
|
+
if (baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4424
|
+
baseVariable = baseVariable.syntheticNamespace;
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
return (this.baseVariable = baseVariable);
|
|
4428
|
+
}
|
|
4429
|
+
getBaseVariableName() {
|
|
4430
|
+
return this.syntheticNamespace.getBaseVariableName();
|
|
4431
|
+
}
|
|
4432
|
+
getName() {
|
|
4433
|
+
const name = this.name;
|
|
4434
|
+
return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`;
|
|
4435
|
+
}
|
|
4436
|
+
include() {
|
|
4437
|
+
if (!this.included) {
|
|
4438
|
+
this.included = true;
|
|
4439
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
setRenderNames(baseName, name) {
|
|
4443
|
+
super.setRenderNames(baseName, name);
|
|
4444
|
+
}
|
|
4409
4445
|
}
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4446
|
+
const getPropertyAccess = (name) => {
|
|
4447
|
+
return !RESERVED_NAMES[name] && /^(?!\d)[\w$]+$/.test(name)
|
|
4448
|
+
? `.${name}`
|
|
4449
|
+
: `[${JSON.stringify(name)}]`;
|
|
4450
|
+
};
|
|
4451
|
+
|
|
4452
|
+
class ExternalVariable extends Variable {
|
|
4453
|
+
constructor(module, name) {
|
|
4454
|
+
super(name);
|
|
4455
|
+
this.module = module;
|
|
4456
|
+
this.isNamespace = name === '*';
|
|
4457
|
+
this.referenced = false;
|
|
4418
4458
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
.
|
|
4422
|
-
|
|
4423
|
-
let lineNum = String(i + frameStart + 1);
|
|
4424
|
-
while (lineNum.length < digits)
|
|
4425
|
-
lineNum = ` ${lineNum}`;
|
|
4426
|
-
if (isErrorLine) {
|
|
4427
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(str.slice(0, column)).length) + '^';
|
|
4428
|
-
return `${lineNum}: ${tabsToSpaces(str)}\n${indicator}`;
|
|
4459
|
+
addReference(identifier) {
|
|
4460
|
+
this.referenced = true;
|
|
4461
|
+
if (this.name === 'default' || this.name === '*') {
|
|
4462
|
+
this.module.suggestName(identifier.name);
|
|
4429
4463
|
}
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
.
|
|
4464
|
+
}
|
|
4465
|
+
include() {
|
|
4466
|
+
if (!this.included) {
|
|
4467
|
+
this.included = true;
|
|
4468
|
+
this.module.used = true;
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
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(' ');
|
|
4474
|
+
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(' ');
|
|
4475
|
+
const blacklisted = new Set(reservedWords.concat(builtins));
|
|
4476
|
+
const illegalCharacters = /[^$_a-zA-Z0-9]/g;
|
|
4477
|
+
const startsWithDigit = (str) => /\d/.test(str[0]);
|
|
4478
|
+
function isLegal(str) {
|
|
4479
|
+
if (startsWithDigit(str) || blacklisted.has(str)) {
|
|
4480
|
+
return false;
|
|
4481
|
+
}
|
|
4482
|
+
return !illegalCharacters.test(str);
|
|
4483
|
+
}
|
|
4484
|
+
function makeLegal(str) {
|
|
4485
|
+
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
|
|
4486
|
+
if (startsWithDigit(str) || blacklisted.has(str))
|
|
4487
|
+
str = `_${str}`;
|
|
4488
|
+
return str || '_';
|
|
4433
4489
|
}
|
|
4434
4490
|
|
|
4435
4491
|
const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
|
@@ -4446,1068 +4502,1009 @@ function normalize(path) {
|
|
|
4446
4502
|
return path.replace(/\\/g, '/');
|
|
4447
4503
|
}
|
|
4448
4504
|
|
|
4449
|
-
|
|
4450
|
-
|
|
4505
|
+
class ExternalModule {
|
|
4506
|
+
constructor(options, id, hasModuleSideEffects, meta) {
|
|
4507
|
+
this.options = options;
|
|
4508
|
+
this.id = id;
|
|
4509
|
+
this.defaultVariableName = '';
|
|
4510
|
+
this.dynamicImporters = [];
|
|
4511
|
+
this.importers = [];
|
|
4512
|
+
this.mostCommonSuggestion = 0;
|
|
4513
|
+
this.namespaceVariableName = '';
|
|
4514
|
+
this.reexported = false;
|
|
4515
|
+
this.renderPath = undefined;
|
|
4516
|
+
this.renormalizeRenderPath = false;
|
|
4517
|
+
this.used = false;
|
|
4518
|
+
this.variableName = '';
|
|
4519
|
+
this.execIndex = Infinity;
|
|
4520
|
+
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
4521
|
+
this.nameSuggestions = Object.create(null);
|
|
4522
|
+
this.declarations = Object.create(null);
|
|
4523
|
+
this.exportedVariables = new Map();
|
|
4524
|
+
const module = this;
|
|
4525
|
+
this.info = {
|
|
4526
|
+
ast: null,
|
|
4527
|
+
code: null,
|
|
4528
|
+
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
4529
|
+
get dynamicImporters() {
|
|
4530
|
+
return module.dynamicImporters.sort();
|
|
4531
|
+
},
|
|
4532
|
+
hasModuleSideEffects,
|
|
4533
|
+
id,
|
|
4534
|
+
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
4535
|
+
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
4536
|
+
importedIds: EMPTY_ARRAY,
|
|
4537
|
+
get importers() {
|
|
4538
|
+
return module.importers.sort();
|
|
4539
|
+
},
|
|
4540
|
+
isEntry: false,
|
|
4541
|
+
isExternal: true,
|
|
4542
|
+
meta,
|
|
4543
|
+
syntheticNamedExports: false
|
|
4544
|
+
};
|
|
4545
|
+
}
|
|
4546
|
+
getVariableForExportName(name) {
|
|
4547
|
+
let declaration = this.declarations[name];
|
|
4548
|
+
if (declaration)
|
|
4549
|
+
return declaration;
|
|
4550
|
+
this.declarations[name] = declaration = new ExternalVariable(this, name);
|
|
4551
|
+
this.exportedVariables.set(declaration, name);
|
|
4552
|
+
return declaration;
|
|
4553
|
+
}
|
|
4554
|
+
setRenderPath(options, inputBase) {
|
|
4555
|
+
this.renderPath =
|
|
4556
|
+
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
4557
|
+
if (!this.renderPath) {
|
|
4558
|
+
if (!isAbsolute(this.id)) {
|
|
4559
|
+
this.renderPath = this.id;
|
|
4560
|
+
}
|
|
4561
|
+
else {
|
|
4562
|
+
this.renderPath = normalize(relative$1(inputBase, this.id));
|
|
4563
|
+
this.renormalizeRenderPath = true;
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
return this.renderPath;
|
|
4567
|
+
}
|
|
4568
|
+
suggestName(name) {
|
|
4569
|
+
if (!this.nameSuggestions[name])
|
|
4570
|
+
this.nameSuggestions[name] = 0;
|
|
4571
|
+
this.nameSuggestions[name] += 1;
|
|
4572
|
+
if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
|
|
4573
|
+
this.mostCommonSuggestion = this.nameSuggestions[name];
|
|
4574
|
+
this.suggestedVariableName = name;
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
warnUnusedImports() {
|
|
4578
|
+
const unused = Object.keys(this.declarations).filter(name => {
|
|
4579
|
+
if (name === '*')
|
|
4580
|
+
return false;
|
|
4581
|
+
const declaration = this.declarations[name];
|
|
4582
|
+
return !declaration.included && !this.reexported && !declaration.referenced;
|
|
4583
|
+
});
|
|
4584
|
+
if (unused.length === 0)
|
|
4585
|
+
return;
|
|
4586
|
+
const names = unused.length === 1
|
|
4587
|
+
? `'${unused[0]}' is`
|
|
4588
|
+
: `${unused
|
|
4589
|
+
.slice(0, -1)
|
|
4590
|
+
.map(name => `'${name}'`)
|
|
4591
|
+
.join(', ')} and '${unused.slice(-1)}' are`;
|
|
4592
|
+
this.options.onwarn({
|
|
4593
|
+
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
4594
|
+
message: `${names} imported from external module '${this.id}' but never used`,
|
|
4595
|
+
names: unused,
|
|
4596
|
+
source: this.id
|
|
4597
|
+
});
|
|
4598
|
+
}
|
|
4451
4599
|
}
|
|
4452
4600
|
|
|
4453
|
-
function
|
|
4454
|
-
|
|
4455
|
-
return base.substr(0, base.length - extname(id).length);
|
|
4456
|
-
}
|
|
4457
|
-
function relativeId(id) {
|
|
4458
|
-
if (typeof process === 'undefined' || !isAbsolute(id))
|
|
4459
|
-
return id;
|
|
4460
|
-
return relative$1(process.cwd(), id);
|
|
4461
|
-
}
|
|
4462
|
-
function isPlainPathFragment(name) {
|
|
4463
|
-
// not starting with "/", "./", "../"
|
|
4464
|
-
return (name[0] !== '/' &&
|
|
4465
|
-
!(name[0] === '.' && (name[1] === '/' || name[1] === '.')) &&
|
|
4466
|
-
sanitizeFileName(name) === name &&
|
|
4467
|
-
!isAbsolute(name));
|
|
4601
|
+
function removeJsExtension(name) {
|
|
4602
|
+
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
4468
4603
|
}
|
|
4469
4604
|
|
|
4470
|
-
function
|
|
4471
|
-
if (!
|
|
4472
|
-
|
|
4473
|
-
throw base;
|
|
4474
|
-
}
|
|
4475
|
-
function augmentCodeLocation(props, pos, source, id) {
|
|
4476
|
-
if (typeof pos === 'object') {
|
|
4477
|
-
const { line, column } = pos;
|
|
4478
|
-
props.loc = { file: id, line, column };
|
|
4605
|
+
function getCompleteAmdId(options, chunkId) {
|
|
4606
|
+
if (!options.autoId) {
|
|
4607
|
+
return options.id || '';
|
|
4479
4608
|
}
|
|
4480
4609
|
else {
|
|
4481
|
-
|
|
4482
|
-
const { line, column } = locate(source, pos, { offsetLine: 1 });
|
|
4483
|
-
props.loc = { file: id, line, column };
|
|
4484
|
-
}
|
|
4485
|
-
if (props.frame === undefined) {
|
|
4486
|
-
const { line, column } = props.loc;
|
|
4487
|
-
props.frame = getCodeFrame(source, line, column);
|
|
4610
|
+
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
4488
4611
|
}
|
|
4489
4612
|
}
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
|
|
4508
|
-
Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
|
|
4509
|
-
Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
|
|
4510
|
-
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
4511
|
-
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
4512
|
-
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
4513
|
-
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
4514
|
-
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
4515
|
-
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
4516
|
-
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
4517
|
-
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
4518
|
-
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
4519
|
-
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
4520
|
-
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
|
|
4521
|
-
Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
|
|
4522
|
-
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
4523
|
-
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
4524
|
-
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
4525
|
-
})(Errors || (Errors = {}));
|
|
4526
|
-
function errAssetNotFinalisedForFileName(name) {
|
|
4527
|
-
return {
|
|
4528
|
-
code: Errors.ASSET_NOT_FINALISED,
|
|
4529
|
-
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
4530
|
-
};
|
|
4531
|
-
}
|
|
4532
|
-
function errCannotEmitFromOptionsHook() {
|
|
4533
|
-
return {
|
|
4534
|
-
code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
|
|
4535
|
-
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
4536
|
-
};
|
|
4613
|
+
|
|
4614
|
+
const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
|
|
4615
|
+
const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
|
|
4616
|
+
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
4617
|
+
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
4618
|
+
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
4619
|
+
const defaultInteropHelpersByInteropType = {
|
|
4620
|
+
auto: INTEROP_DEFAULT_VARIABLE,
|
|
4621
|
+
default: null,
|
|
4622
|
+
defaultOnly: null,
|
|
4623
|
+
esModule: null,
|
|
4624
|
+
false: null,
|
|
4625
|
+
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
4626
|
+
};
|
|
4627
|
+
function isDefaultAProperty(interopType, externalLiveBindings) {
|
|
4628
|
+
return (interopType === 'esModule' ||
|
|
4629
|
+
(externalLiveBindings && (interopType === 'auto' || interopType === 'true')));
|
|
4537
4630
|
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4631
|
+
const namespaceInteropHelpersByInteropType = {
|
|
4632
|
+
auto: INTEROP_NAMESPACE_VARIABLE,
|
|
4633
|
+
default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
|
|
4634
|
+
defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
|
|
4635
|
+
esModule: null,
|
|
4636
|
+
false: null,
|
|
4637
|
+
true: INTEROP_NAMESPACE_VARIABLE
|
|
4638
|
+
};
|
|
4639
|
+
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
4640
|
+
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
4641
|
+
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
4543
4642
|
}
|
|
4544
|
-
function
|
|
4545
|
-
return
|
|
4546
|
-
code: Errors.CIRCULAR_REEXPORT,
|
|
4547
|
-
id: importedModule,
|
|
4548
|
-
message: `"${exportName}" cannot be exported from ${relativeId(importedModule)} as it is a reexport that references itself.`
|
|
4549
|
-
};
|
|
4643
|
+
function getDefaultOnlyHelper() {
|
|
4644
|
+
return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
|
|
4550
4645
|
}
|
|
4551
|
-
function
|
|
4552
|
-
return
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
importer,
|
|
4556
|
-
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.`,
|
|
4557
|
-
reexporter
|
|
4558
|
-
};
|
|
4646
|
+
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
|
|
4647
|
+
return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
|
|
4648
|
+
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
|
|
4649
|
+
: '').join('');
|
|
4559
4650
|
}
|
|
4560
|
-
|
|
4561
|
-
return
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
}
|
|
4651
|
+
const HELPER_GENERATORS = {
|
|
4652
|
+
[INTEROP_DEFAULT_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
4653
|
+
`e${_}&&${_}e.__esModule${_}?${_}` +
|
|
4654
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
4655
|
+
[INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
4656
|
+
`e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
|
|
4657
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
4658
|
+
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
4659
|
+
(usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
|
|
4660
|
+
? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
|
|
4661
|
+
: `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
|
|
4662
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
|
|
4663
|
+
`}${n}${n}`,
|
|
4664
|
+
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
4665
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
4666
|
+
`}${n}${n}`,
|
|
4667
|
+
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
4668
|
+
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
4669
|
+
`}${n}${n}`
|
|
4670
|
+
};
|
|
4671
|
+
function getDefaultLiveBinding(_) {
|
|
4672
|
+
return `e${_}:${_}{${_}'default':${_}e${_}}`;
|
|
4565
4673
|
}
|
|
4566
|
-
function
|
|
4567
|
-
return {
|
|
4568
|
-
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
4569
|
-
message: `Unable to set the source for asset "${name}", source already set.`
|
|
4570
|
-
};
|
|
4674
|
+
function getDefaultStatic(_) {
|
|
4675
|
+
return `e['default']${_}:${_}e`;
|
|
4571
4676
|
}
|
|
4572
|
-
function
|
|
4573
|
-
return {
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4677
|
+
function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
|
|
4678
|
+
return (`${i}var n${_}=${_}${namespaceToStringTag
|
|
4679
|
+
? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
|
|
4680
|
+
: 'Object.create(null)'};${n}` +
|
|
4681
|
+
`${i}if${_}(e)${_}{${n}` +
|
|
4682
|
+
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
4683
|
+
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
4684
|
+
`${i}${t}});${n}` +
|
|
4685
|
+
`${i}}${n}` +
|
|
4686
|
+
`${i}n['default']${_}=${_}e;${n}` +
|
|
4687
|
+
`${i}return ${getFrozen('n', freeze)};${n}`);
|
|
4577
4688
|
}
|
|
4578
|
-
function
|
|
4579
|
-
return {
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4689
|
+
function copyPropertyLiveBinding(_, n, t, i) {
|
|
4690
|
+
return (`${i}if${_}(k${_}!==${_}'default')${_}{${n}` +
|
|
4691
|
+
`${i}${t}var d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` +
|
|
4692
|
+
`${i}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
|
|
4693
|
+
`${i}${t}${t}enumerable:${_}true,${n}` +
|
|
4694
|
+
`${i}${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4695
|
+
`${i}${t}${t}${t}return e[k];${n}` +
|
|
4696
|
+
`${i}${t}${t}}${n}` +
|
|
4697
|
+
`${i}${t}});${n}` +
|
|
4698
|
+
`${i}}${n}`);
|
|
4583
4699
|
}
|
|
4584
|
-
function
|
|
4585
|
-
return {
|
|
4586
|
-
code: Errors.DEPRECATED_FEATURE,
|
|
4587
|
-
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
4588
|
-
};
|
|
4700
|
+
function copyPropertyStatic(_, n, _t, i) {
|
|
4701
|
+
return `${i}n[k]${_}=${_}e[k];${n}`;
|
|
4589
4702
|
}
|
|
4590
|
-
function
|
|
4591
|
-
return {
|
|
4592
|
-
code: Errors.FILE_NOT_FOUND,
|
|
4593
|
-
message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
|
|
4594
|
-
};
|
|
4703
|
+
function getFrozen(fragment, freeze) {
|
|
4704
|
+
return freeze ? `Object.freeze(${fragment})` : fragment;
|
|
4595
4705
|
}
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4706
|
+
const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
|
|
4707
|
+
|
|
4708
|
+
function getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, mechanism = 'return ') {
|
|
4709
|
+
const _ = compact ? '' : ' ';
|
|
4710
|
+
const n = compact ? '' : '\n';
|
|
4711
|
+
if (!namedExportsMode) {
|
|
4712
|
+
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings)};`;
|
|
4713
|
+
}
|
|
4714
|
+
let exportBlock = '';
|
|
4715
|
+
// star exports must always output first for precedence
|
|
4716
|
+
for (const { name, reexports } of dependencies) {
|
|
4717
|
+
if (reexports && namedExportsMode) {
|
|
4718
|
+
for (const specifier of reexports) {
|
|
4719
|
+
if (specifier.reexported === '*') {
|
|
4720
|
+
if (exportBlock)
|
|
4721
|
+
exportBlock += n;
|
|
4722
|
+
if (specifier.needsLiveBinding) {
|
|
4723
|
+
exportBlock +=
|
|
4724
|
+
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4725
|
+
`${t}if${_}(k${_}!==${_}'default')${_}Object.defineProperty(exports,${_}k,${_}{${n}` +
|
|
4726
|
+
`${t}${t}enumerable:${_}true,${n}` +
|
|
4727
|
+
`${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4728
|
+
`${t}${t}${t}return ${name}[k];${n}` +
|
|
4729
|
+
`${t}${t}}${n}${t}});${n}});`;
|
|
4730
|
+
}
|
|
4731
|
+
else {
|
|
4732
|
+
exportBlock +=
|
|
4733
|
+
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4734
|
+
`${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
}
|
|
4740
|
+
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4741
|
+
if (reexports && namedExportsMode) {
|
|
4742
|
+
for (const specifier of reexports) {
|
|
4743
|
+
if (specifier.reexported !== '*') {
|
|
4744
|
+
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4745
|
+
if (exportBlock)
|
|
4746
|
+
exportBlock += n;
|
|
4747
|
+
exportBlock +=
|
|
4748
|
+
specifier.imported !== '*' && specifier.needsLiveBinding
|
|
4749
|
+
? `Object.defineProperty(exports,${_}'${specifier.reexported}',${_}{${n}` +
|
|
4750
|
+
`${t}enumerable:${_}true,${n}` +
|
|
4751
|
+
`${t}get:${_}function${_}()${_}{${n}` +
|
|
4752
|
+
`${t}${t}return ${importName};${n}${t}}${n}});`
|
|
4753
|
+
: `exports.${specifier.reexported}${_}=${_}${importName};`;
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
}
|
|
4758
|
+
for (const chunkExport of exports) {
|
|
4759
|
+
const lhs = `exports.${chunkExport.exported}`;
|
|
4760
|
+
const rhs = chunkExport.local;
|
|
4761
|
+
if (lhs !== rhs) {
|
|
4762
|
+
if (exportBlock)
|
|
4763
|
+
exportBlock += n;
|
|
4764
|
+
exportBlock += `${lhs}${_}=${_}${rhs};`;
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
if (exportBlock) {
|
|
4768
|
+
return `${n}${n}${exportBlock}`;
|
|
4769
|
+
}
|
|
4770
|
+
return '';
|
|
4601
4771
|
}
|
|
4602
|
-
function
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4772
|
+
function getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings) {
|
|
4773
|
+
if (exports.length > 0) {
|
|
4774
|
+
return exports[0].local;
|
|
4775
|
+
}
|
|
4776
|
+
else {
|
|
4777
|
+
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4778
|
+
if (reexports) {
|
|
4779
|
+
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4607
4783
|
}
|
|
4608
|
-
function
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
}
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
return {
|
|
4629
|
-
code: Errors.INVALID_EXTERNAL_ID,
|
|
4630
|
-
message: `'${source}' is imported as an external by ${relativeId(importer)}, but is already an existing non-external module id.`
|
|
4631
|
-
};
|
|
4784
|
+
function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings) {
|
|
4785
|
+
if (imported === 'default') {
|
|
4786
|
+
if (!isChunk) {
|
|
4787
|
+
const moduleInterop = String(interop(moduleId));
|
|
4788
|
+
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
4789
|
+
? defaultVariableName
|
|
4790
|
+
: moduleVariableName;
|
|
4791
|
+
return isDefaultAProperty(moduleInterop, externalLiveBindings)
|
|
4792
|
+
? `${variableName}['default']`
|
|
4793
|
+
: variableName;
|
|
4794
|
+
}
|
|
4795
|
+
return depNamedExportsMode ? `${moduleVariableName}['default']` : moduleVariableName;
|
|
4796
|
+
}
|
|
4797
|
+
if (imported === '*') {
|
|
4798
|
+
return (isChunk
|
|
4799
|
+
? !depNamedExportsMode
|
|
4800
|
+
: namespaceInteropHelpersByInteropType[String(interop(moduleId))])
|
|
4801
|
+
? namespaceVariableName
|
|
4802
|
+
: moduleVariableName;
|
|
4803
|
+
}
|
|
4804
|
+
return `${moduleVariableName}.${imported}`;
|
|
4632
4805
|
}
|
|
4633
|
-
function
|
|
4634
|
-
return {
|
|
4635
|
-
code: Errors.INVALID_OPTION,
|
|
4636
|
-
message: `Invalid value for option "${option}" - ${explanation}.`
|
|
4637
|
-
};
|
|
4806
|
+
function getEsModuleExport(_) {
|
|
4807
|
+
return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
|
|
4638
4808
|
}
|
|
4639
|
-
function
|
|
4640
|
-
return {
|
|
4641
|
-
code: Errors.INVALID_ROLLUP_PHASE,
|
|
4642
|
-
message: `Cannot call addWatchFile after the build has finished.`
|
|
4643
|
-
};
|
|
4809
|
+
function getNamespaceToStringExport(_) {
|
|
4810
|
+
return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
|
|
4644
4811
|
}
|
|
4645
|
-
function
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4812
|
+
function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
|
|
4813
|
+
let namespaceMarkers = '';
|
|
4814
|
+
if (hasNamedExports) {
|
|
4815
|
+
if (addEsModule) {
|
|
4816
|
+
namespaceMarkers += getEsModuleExport(_);
|
|
4817
|
+
}
|
|
4818
|
+
if (addNamespaceToStringTag) {
|
|
4819
|
+
if (namespaceMarkers) {
|
|
4820
|
+
namespaceMarkers += n;
|
|
4821
|
+
}
|
|
4822
|
+
namespaceMarkers += getNamespaceToStringExport(_);
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
return namespaceMarkers;
|
|
4650
4826
|
}
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4827
|
+
|
|
4828
|
+
function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t) {
|
|
4829
|
+
const neededInteropHelpers = new Set();
|
|
4830
|
+
const interopStatements = [];
|
|
4831
|
+
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
4832
|
+
neededInteropHelpers.add(helper);
|
|
4833
|
+
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
4656
4834
|
};
|
|
4835
|
+
for (const { defaultVariableName, imports, id, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4836
|
+
if (isChunk) {
|
|
4837
|
+
for (const { imported, reexported } of [
|
|
4838
|
+
...(imports || []),
|
|
4839
|
+
...(reexports || [])
|
|
4840
|
+
]) {
|
|
4841
|
+
if (imported === '*' && reexported !== '*') {
|
|
4842
|
+
if (!namedExportsMode) {
|
|
4843
|
+
addInteropStatement(namespaceVariableName, getDefaultOnlyHelper(), name);
|
|
4844
|
+
}
|
|
4845
|
+
break;
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
else {
|
|
4850
|
+
const moduleInterop = String(interop(id));
|
|
4851
|
+
let hasDefault = false;
|
|
4852
|
+
let hasNamespace = false;
|
|
4853
|
+
for (const { imported, reexported } of [
|
|
4854
|
+
...(imports || []),
|
|
4855
|
+
...(reexports || [])
|
|
4856
|
+
]) {
|
|
4857
|
+
let helper;
|
|
4858
|
+
let variableName;
|
|
4859
|
+
if (imported === 'default') {
|
|
4860
|
+
if (!hasDefault) {
|
|
4861
|
+
hasDefault = true;
|
|
4862
|
+
if (defaultVariableName !== namespaceVariableName) {
|
|
4863
|
+
variableName = defaultVariableName;
|
|
4864
|
+
helper = defaultInteropHelpersByInteropType[moduleInterop];
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
else if (imported === '*' && reexported !== '*') {
|
|
4869
|
+
if (!hasNamespace) {
|
|
4870
|
+
hasNamespace = true;
|
|
4871
|
+
helper = namespaceInteropHelpersByInteropType[moduleInterop];
|
|
4872
|
+
variableName = namespaceVariableName;
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
if (helper) {
|
|
4876
|
+
addInteropStatement(variableName, helper, name);
|
|
4877
|
+
}
|
|
4878
|
+
}
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4657
4882
|
}
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4883
|
+
|
|
4884
|
+
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
4885
|
+
// The assumption is that this makes sense for all relative ids:
|
|
4886
|
+
// https://requirejs.org/docs/api.html#jsfiles
|
|
4887
|
+
function removeExtensionFromRelativeAmdId(id) {
|
|
4888
|
+
return id[0] === '.' ? removeJsExtension(id) : id;
|
|
4663
4889
|
}
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4890
|
+
|
|
4891
|
+
const builtins$1 = {
|
|
4892
|
+
assert: true,
|
|
4893
|
+
buffer: true,
|
|
4894
|
+
console: true,
|
|
4895
|
+
constants: true,
|
|
4896
|
+
domain: true,
|
|
4897
|
+
events: true,
|
|
4898
|
+
http: true,
|
|
4899
|
+
https: true,
|
|
4900
|
+
os: true,
|
|
4901
|
+
path: true,
|
|
4902
|
+
process: true,
|
|
4903
|
+
punycode: true,
|
|
4904
|
+
querystring: true,
|
|
4905
|
+
stream: true,
|
|
4906
|
+
string_decoder: true,
|
|
4907
|
+
timers: true,
|
|
4908
|
+
tty: true,
|
|
4909
|
+
url: true,
|
|
4910
|
+
util: true,
|
|
4911
|
+
vm: true,
|
|
4912
|
+
zlib: true
|
|
4913
|
+
};
|
|
4914
|
+
function warnOnBuiltins(warn, dependencies) {
|
|
4915
|
+
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins$1);
|
|
4916
|
+
if (!externalBuiltins.length)
|
|
4917
|
+
return;
|
|
4918
|
+
const detail = externalBuiltins.length === 1
|
|
4919
|
+
? `module ('${externalBuiltins[0]}')`
|
|
4920
|
+
: `modules (${externalBuiltins
|
|
4921
|
+
.slice(0, -1)
|
|
4922
|
+
.map(name => `'${name}'`)
|
|
4923
|
+
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
4924
|
+
warn({
|
|
4925
|
+
code: 'MISSING_NODE_BUILTINS',
|
|
4926
|
+
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`,
|
|
4927
|
+
modules: externalBuiltins
|
|
4928
|
+
});
|
|
4669
4929
|
}
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4930
|
+
|
|
4931
|
+
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 }) {
|
|
4932
|
+
warnOnBuiltins(warn, dependencies);
|
|
4933
|
+
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
4934
|
+
const args = dependencies.map(m => m.name);
|
|
4935
|
+
const n = compact ? '' : '\n';
|
|
4936
|
+
const s = compact ? '' : ';';
|
|
4937
|
+
const _ = compact ? '' : ' ';
|
|
4938
|
+
if (namedExportsMode && hasExports) {
|
|
4939
|
+
args.unshift(`exports`);
|
|
4940
|
+
deps.unshift(`'exports'`);
|
|
4941
|
+
}
|
|
4942
|
+
if (accessedGlobals.has('require')) {
|
|
4943
|
+
args.unshift('require');
|
|
4944
|
+
deps.unshift(`'require'`);
|
|
4945
|
+
}
|
|
4946
|
+
if (accessedGlobals.has('module')) {
|
|
4947
|
+
args.unshift('module');
|
|
4948
|
+
deps.unshift(`'module'`);
|
|
4949
|
+
}
|
|
4950
|
+
const completeAmdId = getCompleteAmdId(amd, id);
|
|
4951
|
+
const params = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
4952
|
+
(deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
4953
|
+
const useStrict = strict ? `${_}'use strict';` : '';
|
|
4954
|
+
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
4955
|
+
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
4956
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
4957
|
+
if (namespaceMarkers) {
|
|
4958
|
+
namespaceMarkers = n + n + namespaceMarkers;
|
|
4959
|
+
}
|
|
4960
|
+
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
4961
|
+
return magicString
|
|
4962
|
+
.indent(t)
|
|
4963
|
+
.prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
4964
|
+
.append(`${n}${n}});`);
|
|
4678
4965
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4966
|
+
|
|
4967
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
4968
|
+
const n = compact ? '' : '\n';
|
|
4969
|
+
const s = compact ? '' : ';';
|
|
4970
|
+
const _ = compact ? '' : ' ';
|
|
4971
|
+
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
4972
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
4973
|
+
if (namespaceMarkers) {
|
|
4974
|
+
namespaceMarkers += n + n;
|
|
4975
|
+
}
|
|
4976
|
+
const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
|
|
4977
|
+
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
4978
|
+
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
4979
|
+
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
4980
|
+
return magicString.append(`${exportBlock}${outro}`);
|
|
4686
4981
|
}
|
|
4687
|
-
function
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
}
|
|
4703
|
-
function errPreferNamedExports(facadeModuleId) {
|
|
4704
|
-
const file = relativeId(facadeModuleId);
|
|
4705
|
-
return {
|
|
4706
|
-
code: Errors.PREFER_NAMED_EXPORTS,
|
|
4707
|
-
id: facadeModuleId,
|
|
4708
|
-
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.`,
|
|
4709
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
4710
|
-
};
|
|
4711
|
-
}
|
|
4712
|
-
function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
|
|
4713
|
-
return {
|
|
4714
|
-
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
4715
|
-
id,
|
|
4716
|
-
message: `Module "${relativeId(id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}' needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
|
|
4717
|
-
? `an export named "${syntheticNamedExportsOption}"`
|
|
4718
|
-
: 'a default export'} that does not reexport an unresolved named export of the same module.`
|
|
4719
|
-
};
|
|
4720
|
-
}
|
|
4721
|
-
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
4722
|
-
const importType = isReexport ? 'reexport' : 'import';
|
|
4723
|
-
return {
|
|
4724
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
4725
|
-
id,
|
|
4726
|
-
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.`,
|
|
4727
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
4728
|
-
};
|
|
4729
|
-
}
|
|
4730
|
-
function errUnexpectedNamespaceReexport(id) {
|
|
4731
|
-
return {
|
|
4732
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
4733
|
-
id,
|
|
4734
|
-
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.`,
|
|
4735
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
4736
|
-
};
|
|
4737
|
-
}
|
|
4738
|
-
function errEntryCannotBeExternal(unresolvedId) {
|
|
4739
|
-
return {
|
|
4740
|
-
code: Errors.UNRESOLVED_ENTRY,
|
|
4741
|
-
message: `Entry module cannot be external (${relativeId(unresolvedId)}).`
|
|
4742
|
-
};
|
|
4743
|
-
}
|
|
4744
|
-
function errUnresolvedEntry(unresolvedId) {
|
|
4745
|
-
return {
|
|
4746
|
-
code: Errors.UNRESOLVED_ENTRY,
|
|
4747
|
-
message: `Could not resolve entry module (${relativeId(unresolvedId)}).`
|
|
4748
|
-
};
|
|
4749
|
-
}
|
|
4750
|
-
function errUnresolvedImport(source, importer) {
|
|
4751
|
-
return {
|
|
4752
|
-
code: Errors.UNRESOLVED_IMPORT,
|
|
4753
|
-
message: `Could not resolve '${source}' from ${relativeId(importer)}`
|
|
4754
|
-
};
|
|
4755
|
-
}
|
|
4756
|
-
function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
4757
|
-
return {
|
|
4758
|
-
code: Errors.UNRESOLVED_IMPORT,
|
|
4759
|
-
importer: relativeId(importer),
|
|
4760
|
-
message: `'${source}' is imported by ${relativeId(importer)}, but could not be resolved – treating it as an external dependency`,
|
|
4761
|
-
source,
|
|
4762
|
-
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
4763
|
-
};
|
|
4764
|
-
}
|
|
4765
|
-
function errExternalSyntheticExports(source, importer) {
|
|
4766
|
-
return {
|
|
4767
|
-
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
4768
|
-
importer: relativeId(importer),
|
|
4769
|
-
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
4770
|
-
source
|
|
4771
|
-
};
|
|
4772
|
-
}
|
|
4773
|
-
function errFailedValidation(message) {
|
|
4774
|
-
return {
|
|
4775
|
-
code: Errors.VALIDATION_ERROR,
|
|
4776
|
-
message
|
|
4777
|
-
};
|
|
4778
|
-
}
|
|
4779
|
-
function errAlreadyClosed() {
|
|
4780
|
-
return {
|
|
4781
|
-
code: Errors.ALREADY_CLOSED,
|
|
4782
|
-
message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
|
|
4783
|
-
};
|
|
4784
|
-
}
|
|
4785
|
-
function warnDeprecation(deprecation, activeDeprecation, options) {
|
|
4786
|
-
warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
|
|
4787
|
-
}
|
|
4788
|
-
function warnDeprecationWithOptions(deprecation, activeDeprecation, warn, strictDeprecations) {
|
|
4789
|
-
if (activeDeprecation || strictDeprecations) {
|
|
4790
|
-
const warning = errDeprecation(deprecation);
|
|
4791
|
-
if (strictDeprecations) {
|
|
4792
|
-
return error(warning);
|
|
4982
|
+
function getImportBlock(dependencies, compact, varOrConst, n, _) {
|
|
4983
|
+
let importBlock = '';
|
|
4984
|
+
let definingVariable = false;
|
|
4985
|
+
for (const { id, name, reexports, imports } of dependencies) {
|
|
4986
|
+
if (!reexports && !imports) {
|
|
4987
|
+
if (importBlock) {
|
|
4988
|
+
importBlock += !compact || definingVariable ? `;${n}` : ',';
|
|
4989
|
+
}
|
|
4990
|
+
definingVariable = false;
|
|
4991
|
+
importBlock += `require('${id}')`;
|
|
4992
|
+
}
|
|
4993
|
+
else {
|
|
4994
|
+
importBlock +=
|
|
4995
|
+
compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${varOrConst} `;
|
|
4996
|
+
definingVariable = true;
|
|
4997
|
+
importBlock += `${name}${_}=${_}require('${id}')`;
|
|
4793
4998
|
}
|
|
4794
|
-
warn(warning);
|
|
4795
4999
|
}
|
|
5000
|
+
if (importBlock) {
|
|
5001
|
+
return `${importBlock};${n}${n}`;
|
|
5002
|
+
}
|
|
5003
|
+
return '';
|
|
4796
5004
|
}
|
|
4797
5005
|
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
5006
|
+
function es(magicString, { intro, outro, dependencies, exports, varOrConst }, { compact }) {
|
|
5007
|
+
const _ = compact ? '' : ' ';
|
|
5008
|
+
const n = compact ? '' : '\n';
|
|
5009
|
+
const importBlock = getImportBlock$1(dependencies, _);
|
|
5010
|
+
if (importBlock.length > 0)
|
|
5011
|
+
intro += importBlock.join(n) + n + n;
|
|
5012
|
+
if (intro)
|
|
5013
|
+
magicString.prepend(intro);
|
|
5014
|
+
const exportBlock = getExportBlock$1(exports, _, varOrConst);
|
|
5015
|
+
if (exportBlock.length)
|
|
5016
|
+
magicString.append(n + n + exportBlock.join(n).trim());
|
|
5017
|
+
if (outro)
|
|
5018
|
+
magicString.append(outro);
|
|
5019
|
+
return magicString.trim();
|
|
5020
|
+
}
|
|
5021
|
+
function getImportBlock$1(dependencies, _) {
|
|
5022
|
+
const importBlock = [];
|
|
5023
|
+
for (const { id, reexports, imports, name } of dependencies) {
|
|
5024
|
+
if (!reexports && !imports) {
|
|
5025
|
+
importBlock.push(`import${_}'${id}';`);
|
|
5026
|
+
continue;
|
|
5027
|
+
}
|
|
5028
|
+
if (imports) {
|
|
5029
|
+
let defaultImport = null;
|
|
5030
|
+
let starImport = null;
|
|
5031
|
+
const importedNames = [];
|
|
5032
|
+
for (const specifier of imports) {
|
|
5033
|
+
if (specifier.imported === 'default') {
|
|
5034
|
+
defaultImport = specifier;
|
|
5035
|
+
}
|
|
5036
|
+
else if (specifier.imported === '*') {
|
|
5037
|
+
starImport = specifier;
|
|
5038
|
+
}
|
|
5039
|
+
else {
|
|
5040
|
+
importedNames.push(specifier);
|
|
5041
|
+
}
|
|
4819
5042
|
}
|
|
4820
|
-
if (
|
|
4821
|
-
|
|
5043
|
+
if (starImport) {
|
|
5044
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
|
|
4822
5045
|
}
|
|
4823
|
-
if (
|
|
4824
|
-
|
|
5046
|
+
if (defaultImport && importedNames.length === 0) {
|
|
5047
|
+
importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
|
|
5048
|
+
}
|
|
5049
|
+
else if (importedNames.length > 0) {
|
|
5050
|
+
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
5051
|
+
.map(specifier => {
|
|
5052
|
+
if (specifier.imported === specifier.local) {
|
|
5053
|
+
return specifier.imported;
|
|
5054
|
+
}
|
|
5055
|
+
else {
|
|
5056
|
+
return `${specifier.imported} as ${specifier.local}`;
|
|
5057
|
+
}
|
|
5058
|
+
})
|
|
5059
|
+
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
4825
5060
|
}
|
|
4826
5061
|
}
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
5062
|
+
if (reexports) {
|
|
5063
|
+
let starExport = null;
|
|
5064
|
+
const namespaceReexports = [];
|
|
5065
|
+
const namedReexports = [];
|
|
5066
|
+
for (const specifier of reexports) {
|
|
5067
|
+
if (specifier.reexported === '*') {
|
|
5068
|
+
starExport = specifier;
|
|
5069
|
+
}
|
|
5070
|
+
else if (specifier.imported === '*') {
|
|
5071
|
+
namespaceReexports.push(specifier);
|
|
5072
|
+
}
|
|
5073
|
+
else {
|
|
5074
|
+
namedReexports.push(specifier);
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
if (starExport) {
|
|
5078
|
+
importBlock.push(`export${_}*${_}from${_}'${id}';`);
|
|
5079
|
+
}
|
|
5080
|
+
if (namespaceReexports.length > 0) {
|
|
5081
|
+
if (!imports ||
|
|
5082
|
+
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
5083
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`);
|
|
5084
|
+
}
|
|
5085
|
+
for (const specifier of namespaceReexports) {
|
|
5086
|
+
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
if (namedReexports.length > 0) {
|
|
5090
|
+
importBlock.push(`export${_}{${_}${namedReexports
|
|
5091
|
+
.map(specifier => {
|
|
5092
|
+
if (specifier.imported === specifier.reexported) {
|
|
5093
|
+
return specifier.imported;
|
|
5094
|
+
}
|
|
5095
|
+
else {
|
|
5096
|
+
return `${specifier.imported} as ${specifier.reexported}`;
|
|
5097
|
+
}
|
|
5098
|
+
})
|
|
5099
|
+
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5100
|
+
}
|
|
4840
5101
|
}
|
|
4841
5102
|
}
|
|
4842
|
-
|
|
4843
|
-
super.setRenderNames(baseName, name);
|
|
4844
|
-
}
|
|
5103
|
+
return importBlock;
|
|
4845
5104
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
class ExternalVariable extends Variable {
|
|
4853
|
-
constructor(module, name) {
|
|
4854
|
-
super(name);
|
|
4855
|
-
this.module = module;
|
|
4856
|
-
this.isNamespace = name === '*';
|
|
4857
|
-
this.referenced = false;
|
|
4858
|
-
}
|
|
4859
|
-
addReference(identifier) {
|
|
4860
|
-
this.referenced = true;
|
|
4861
|
-
if (this.name === 'default' || this.name === '*') {
|
|
4862
|
-
this.module.suggestName(identifier.name);
|
|
5105
|
+
function getExportBlock$1(exports, _, varOrConst) {
|
|
5106
|
+
const exportBlock = [];
|
|
5107
|
+
const exportDeclaration = [];
|
|
5108
|
+
for (const specifier of exports) {
|
|
5109
|
+
if (specifier.exported === 'default') {
|
|
5110
|
+
exportBlock.push(`export default ${specifier.local};`);
|
|
4863
5111
|
}
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5112
|
+
else {
|
|
5113
|
+
if (specifier.expression) {
|
|
5114
|
+
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
5115
|
+
}
|
|
5116
|
+
exportDeclaration.push(specifier.exported === specifier.local
|
|
5117
|
+
? specifier.local
|
|
5118
|
+
: `${specifier.local} as ${specifier.exported}`);
|
|
4869
5119
|
}
|
|
4870
5120
|
}
|
|
5121
|
+
if (exportDeclaration.length) {
|
|
5122
|
+
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
5123
|
+
}
|
|
5124
|
+
return exportBlock;
|
|
4871
5125
|
}
|
|
4872
5126
|
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
function isLegal(str) {
|
|
4879
|
-
if (startsWithDigit(str) || blacklisted.has(str)) {
|
|
4880
|
-
return false;
|
|
4881
|
-
}
|
|
4882
|
-
return !illegalCharacters.test(str);
|
|
5127
|
+
function spaces(i) {
|
|
5128
|
+
let result = '';
|
|
5129
|
+
while (i--)
|
|
5130
|
+
result += ' ';
|
|
5131
|
+
return result;
|
|
4883
5132
|
}
|
|
4884
|
-
function
|
|
4885
|
-
|
|
4886
|
-
if (startsWithDigit(str) || blacklisted.has(str))
|
|
4887
|
-
str = `_${str}`;
|
|
4888
|
-
return str || '_';
|
|
5133
|
+
function tabsToSpaces(str) {
|
|
5134
|
+
return str.replace(/^\t+/, match => match.split('\t').join(' '));
|
|
4889
5135
|
}
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
this.mostCommonSuggestion = 0;
|
|
4899
|
-
this.namespaceVariableName = '';
|
|
4900
|
-
this.reexported = false;
|
|
4901
|
-
this.renderPath = undefined;
|
|
4902
|
-
this.renormalizeRenderPath = false;
|
|
4903
|
-
this.used = false;
|
|
4904
|
-
this.variableName = '';
|
|
4905
|
-
this.execIndex = Infinity;
|
|
4906
|
-
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
4907
|
-
this.nameSuggestions = Object.create(null);
|
|
4908
|
-
this.declarations = Object.create(null);
|
|
4909
|
-
this.exportedVariables = new Map();
|
|
4910
|
-
const module = this;
|
|
4911
|
-
this.info = {
|
|
4912
|
-
ast: null,
|
|
4913
|
-
code: null,
|
|
4914
|
-
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
4915
|
-
get dynamicImporters() {
|
|
4916
|
-
return module.dynamicImporters.sort();
|
|
4917
|
-
},
|
|
4918
|
-
hasModuleSideEffects,
|
|
4919
|
-
id,
|
|
4920
|
-
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
4921
|
-
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
4922
|
-
importedIds: EMPTY_ARRAY,
|
|
4923
|
-
get importers() {
|
|
4924
|
-
return module.importers.sort();
|
|
4925
|
-
},
|
|
4926
|
-
isEntry: false,
|
|
4927
|
-
isExternal: true,
|
|
4928
|
-
meta,
|
|
4929
|
-
syntheticNamedExports: false
|
|
4930
|
-
};
|
|
4931
|
-
}
|
|
4932
|
-
getVariableForExportName(name) {
|
|
4933
|
-
let declaration = this.declarations[name];
|
|
4934
|
-
if (declaration)
|
|
4935
|
-
return declaration;
|
|
4936
|
-
this.declarations[name] = declaration = new ExternalVariable(this, name);
|
|
4937
|
-
this.exportedVariables.set(declaration, name);
|
|
4938
|
-
return declaration;
|
|
4939
|
-
}
|
|
4940
|
-
setRenderPath(options, inputBase) {
|
|
4941
|
-
this.renderPath =
|
|
4942
|
-
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
4943
|
-
if (!this.renderPath) {
|
|
4944
|
-
if (!isAbsolute(this.id)) {
|
|
4945
|
-
this.renderPath = this.id;
|
|
4946
|
-
}
|
|
4947
|
-
else {
|
|
4948
|
-
this.renderPath = normalize(relative$1(inputBase, this.id));
|
|
4949
|
-
this.renormalizeRenderPath = true;
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4952
|
-
return this.renderPath;
|
|
5136
|
+
function getCodeFrame(source, line, column) {
|
|
5137
|
+
let lines = source.split('\n');
|
|
5138
|
+
const frameStart = Math.max(0, line - 3);
|
|
5139
|
+
let frameEnd = Math.min(line + 2, lines.length);
|
|
5140
|
+
lines = lines.slice(frameStart, frameEnd);
|
|
5141
|
+
while (!/\S/.test(lines[lines.length - 1])) {
|
|
5142
|
+
lines.pop();
|
|
5143
|
+
frameEnd -= 1;
|
|
4953
5144
|
}
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5145
|
+
const digits = String(frameEnd).length;
|
|
5146
|
+
return lines
|
|
5147
|
+
.map((str, i) => {
|
|
5148
|
+
const isErrorLine = frameStart + i + 1 === line;
|
|
5149
|
+
let lineNum = String(i + frameStart + 1);
|
|
5150
|
+
while (lineNum.length < digits)
|
|
5151
|
+
lineNum = ` ${lineNum}`;
|
|
5152
|
+
if (isErrorLine) {
|
|
5153
|
+
const indicator = spaces(digits + 2 + tabsToSpaces(str.slice(0, column)).length) + '^';
|
|
5154
|
+
return `${lineNum}: ${tabsToSpaces(str)}\n${indicator}`;
|
|
4961
5155
|
}
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
if (name === '*')
|
|
4966
|
-
return false;
|
|
4967
|
-
const declaration = this.declarations[name];
|
|
4968
|
-
return !declaration.included && !this.reexported && !declaration.referenced;
|
|
4969
|
-
});
|
|
4970
|
-
if (unused.length === 0)
|
|
4971
|
-
return;
|
|
4972
|
-
const names = unused.length === 1
|
|
4973
|
-
? `'${unused[0]}' is`
|
|
4974
|
-
: `${unused
|
|
4975
|
-
.slice(0, -1)
|
|
4976
|
-
.map(name => `'${name}'`)
|
|
4977
|
-
.join(', ')} and '${unused.slice(-1)}' are`;
|
|
4978
|
-
this.options.onwarn({
|
|
4979
|
-
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
4980
|
-
message: `${names} imported from external module '${this.id}' but never used`,
|
|
4981
|
-
names: unused,
|
|
4982
|
-
source: this.id
|
|
4983
|
-
});
|
|
4984
|
-
}
|
|
5156
|
+
return `${lineNum}: ${tabsToSpaces(str)}`;
|
|
5157
|
+
})
|
|
5158
|
+
.join('\n');
|
|
4985
5159
|
}
|
|
4986
5160
|
|
|
4987
|
-
function
|
|
4988
|
-
return name.
|
|
5161
|
+
function sanitizeFileName(name) {
|
|
5162
|
+
return name.replace(/[\0?*]/g, '_');
|
|
4989
5163
|
}
|
|
4990
5164
|
|
|
4991
|
-
function
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
}
|
|
4995
|
-
else {
|
|
4996
|
-
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
4997
|
-
}
|
|
5165
|
+
function getAliasName(id) {
|
|
5166
|
+
const base = basename(id);
|
|
5167
|
+
return base.substr(0, base.length - extname(id).length);
|
|
4998
5168
|
}
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
5004
|
-
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
5005
|
-
const defaultInteropHelpersByInteropType = {
|
|
5006
|
-
auto: INTEROP_DEFAULT_VARIABLE,
|
|
5007
|
-
default: null,
|
|
5008
|
-
defaultOnly: null,
|
|
5009
|
-
esModule: null,
|
|
5010
|
-
false: null,
|
|
5011
|
-
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
5012
|
-
};
|
|
5013
|
-
function isDefaultAProperty(interopType, externalLiveBindings) {
|
|
5014
|
-
return (interopType === 'esModule' ||
|
|
5015
|
-
(externalLiveBindings && (interopType === 'auto' || interopType === 'true')));
|
|
5169
|
+
function relativeId(id) {
|
|
5170
|
+
if (!isAbsolute(id))
|
|
5171
|
+
return id;
|
|
5172
|
+
return relative$1(resolve(), id);
|
|
5016
5173
|
}
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
true: INTEROP_NAMESPACE_VARIABLE
|
|
5024
|
-
};
|
|
5025
|
-
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
5026
|
-
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
5027
|
-
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
5174
|
+
function isPlainPathFragment(name) {
|
|
5175
|
+
// not starting with "/", "./", "../"
|
|
5176
|
+
return (name[0] !== '/' &&
|
|
5177
|
+
!(name[0] === '.' && (name[1] === '/' || name[1] === '.')) &&
|
|
5178
|
+
sanitizeFileName(name) === name &&
|
|
5179
|
+
!isAbsolute(name));
|
|
5028
5180
|
}
|
|
5029
|
-
|
|
5030
|
-
|
|
5181
|
+
|
|
5182
|
+
function error(base) {
|
|
5183
|
+
if (!(base instanceof Error))
|
|
5184
|
+
base = Object.assign(new Error(base.message), base);
|
|
5185
|
+
throw base;
|
|
5031
5186
|
}
|
|
5032
|
-
function
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
:
|
|
5187
|
+
function augmentCodeLocation(props, pos, source, id) {
|
|
5188
|
+
if (typeof pos === 'object') {
|
|
5189
|
+
const { line, column } = pos;
|
|
5190
|
+
props.loc = { file: id, line, column };
|
|
5191
|
+
}
|
|
5192
|
+
else {
|
|
5193
|
+
props.pos = pos;
|
|
5194
|
+
const { line, column } = locate(source, pos, { offsetLine: 1 });
|
|
5195
|
+
props.loc = { file: id, line, column };
|
|
5196
|
+
}
|
|
5197
|
+
if (props.frame === undefined) {
|
|
5198
|
+
const { line, column } = props.loc;
|
|
5199
|
+
props.frame = getCodeFrame(source, line, column);
|
|
5200
|
+
}
|
|
5036
5201
|
}
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
[
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
[
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
[
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
[
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5202
|
+
var Errors;
|
|
5203
|
+
(function (Errors) {
|
|
5204
|
+
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
5205
|
+
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
5206
|
+
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
5207
|
+
Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
|
|
5208
|
+
Errors["ASSET_SOURCE_MISSING"] = "ASSET_SOURCE_MISSING";
|
|
5209
|
+
Errors["BAD_LOADER"] = "BAD_LOADER";
|
|
5210
|
+
Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
|
|
5211
|
+
Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
|
|
5212
|
+
Errors["CIRCULAR_REEXPORT"] = "CIRCULAR_REEXPORT";
|
|
5213
|
+
Errors["CYCLIC_CROSS_CHUNK_REEXPORT"] = "CYCLIC_CROSS_CHUNK_REEXPORT";
|
|
5214
|
+
Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
|
|
5215
|
+
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
5216
|
+
Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
|
|
5217
|
+
Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
5218
|
+
Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
5219
|
+
Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
|
|
5220
|
+
Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
|
|
5221
|
+
Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
|
|
5222
|
+
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
5223
|
+
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
5224
|
+
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
5225
|
+
Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
|
|
5226
|
+
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
5227
|
+
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
5228
|
+
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
5229
|
+
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
5230
|
+
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
5231
|
+
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
5232
|
+
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
|
|
5233
|
+
Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
|
|
5234
|
+
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
5235
|
+
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
5236
|
+
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
5237
|
+
})(Errors || (Errors = {}));
|
|
5238
|
+
function errAssetNotFinalisedForFileName(name) {
|
|
5239
|
+
return {
|
|
5240
|
+
code: Errors.ASSET_NOT_FINALISED,
|
|
5241
|
+
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
5242
|
+
};
|
|
5059
5243
|
}
|
|
5060
|
-
function
|
|
5061
|
-
return
|
|
5244
|
+
function errCannotEmitFromOptionsHook() {
|
|
5245
|
+
return {
|
|
5246
|
+
code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
|
|
5247
|
+
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
5248
|
+
};
|
|
5062
5249
|
}
|
|
5063
|
-
function
|
|
5064
|
-
return
|
|
5065
|
-
|
|
5066
|
-
:
|
|
5067
|
-
|
|
5068
|
-
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
5069
|
-
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
5070
|
-
`${i}${t}});${n}` +
|
|
5071
|
-
`${i}}${n}` +
|
|
5072
|
-
`${i}n['default']${_}=${_}e;${n}` +
|
|
5073
|
-
`${i}return ${getFrozen('n', freeze)};${n}`);
|
|
5250
|
+
function errChunkNotGeneratedForFileName(name) {
|
|
5251
|
+
return {
|
|
5252
|
+
code: Errors.CHUNK_NOT_GENERATED,
|
|
5253
|
+
message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
|
|
5254
|
+
};
|
|
5074
5255
|
}
|
|
5075
|
-
function
|
|
5076
|
-
return
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
`${i}${t}${t}${t}return e[k];${n}` +
|
|
5082
|
-
`${i}${t}${t}}${n}` +
|
|
5083
|
-
`${i}${t}});${n}` +
|
|
5084
|
-
`${i}}${n}`);
|
|
5256
|
+
function errCircularReexport(exportName, importedModule) {
|
|
5257
|
+
return {
|
|
5258
|
+
code: Errors.CIRCULAR_REEXPORT,
|
|
5259
|
+
id: importedModule,
|
|
5260
|
+
message: `"${exportName}" cannot be exported from ${relativeId(importedModule)} as it is a reexport that references itself.`
|
|
5261
|
+
};
|
|
5085
5262
|
}
|
|
5086
|
-
function
|
|
5087
|
-
return
|
|
5263
|
+
function errCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
5264
|
+
return {
|
|
5265
|
+
code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
5266
|
+
exporter,
|
|
5267
|
+
importer,
|
|
5268
|
+
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.`,
|
|
5269
|
+
reexporter
|
|
5270
|
+
};
|
|
5088
5271
|
}
|
|
5089
|
-
function
|
|
5090
|
-
return
|
|
5272
|
+
function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
|
|
5273
|
+
return {
|
|
5274
|
+
code: Errors.ASSET_NOT_FOUND,
|
|
5275
|
+
message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
|
|
5276
|
+
};
|
|
5091
5277
|
}
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
if (!namedExportsMode) {
|
|
5098
|
-
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings)};`;
|
|
5099
|
-
}
|
|
5100
|
-
let exportBlock = '';
|
|
5101
|
-
// star exports must always output first for precedence
|
|
5102
|
-
for (const { name, reexports } of dependencies) {
|
|
5103
|
-
if (reexports && namedExportsMode) {
|
|
5104
|
-
for (const specifier of reexports) {
|
|
5105
|
-
if (specifier.reexported === '*') {
|
|
5106
|
-
if (exportBlock)
|
|
5107
|
-
exportBlock += n;
|
|
5108
|
-
if (specifier.needsLiveBinding) {
|
|
5109
|
-
exportBlock +=
|
|
5110
|
-
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
5111
|
-
`${t}if${_}(k${_}!==${_}'default')${_}Object.defineProperty(exports,${_}k,${_}{${n}` +
|
|
5112
|
-
`${t}${t}enumerable:${_}true,${n}` +
|
|
5113
|
-
`${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
5114
|
-
`${t}${t}${t}return ${name}[k];${n}` +
|
|
5115
|
-
`${t}${t}}${n}${t}});${n}});`;
|
|
5116
|
-
}
|
|
5117
|
-
else {
|
|
5118
|
-
exportBlock +=
|
|
5119
|
-
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
5120
|
-
`${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
|
|
5121
|
-
}
|
|
5122
|
-
}
|
|
5123
|
-
}
|
|
5124
|
-
}
|
|
5125
|
-
}
|
|
5126
|
-
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
5127
|
-
if (reexports && namedExportsMode) {
|
|
5128
|
-
for (const specifier of reexports) {
|
|
5129
|
-
if (specifier.reexported !== '*') {
|
|
5130
|
-
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
5131
|
-
if (exportBlock)
|
|
5132
|
-
exportBlock += n;
|
|
5133
|
-
exportBlock +=
|
|
5134
|
-
specifier.imported !== '*' && specifier.needsLiveBinding
|
|
5135
|
-
? `Object.defineProperty(exports,${_}'${specifier.reexported}',${_}{${n}` +
|
|
5136
|
-
`${t}enumerable:${_}true,${n}` +
|
|
5137
|
-
`${t}get:${_}function${_}()${_}{${n}` +
|
|
5138
|
-
`${t}${t}return ${importName};${n}${t}}${n}});`
|
|
5139
|
-
: `exports.${specifier.reexported}${_}=${_}${importName};`;
|
|
5140
|
-
}
|
|
5141
|
-
}
|
|
5142
|
-
}
|
|
5143
|
-
}
|
|
5144
|
-
for (const chunkExport of exports) {
|
|
5145
|
-
const lhs = `exports.${chunkExport.exported}`;
|
|
5146
|
-
const rhs = chunkExport.local;
|
|
5147
|
-
if (lhs !== rhs) {
|
|
5148
|
-
if (exportBlock)
|
|
5149
|
-
exportBlock += n;
|
|
5150
|
-
exportBlock += `${lhs}${_}=${_}${rhs};`;
|
|
5151
|
-
}
|
|
5152
|
-
}
|
|
5153
|
-
if (exportBlock) {
|
|
5154
|
-
return `${n}${n}${exportBlock}`;
|
|
5155
|
-
}
|
|
5156
|
-
return '';
|
|
5278
|
+
function errAssetSourceAlreadySet(name) {
|
|
5279
|
+
return {
|
|
5280
|
+
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
5281
|
+
message: `Unable to set the source for asset "${name}", source already set.`
|
|
5282
|
+
};
|
|
5157
5283
|
}
|
|
5158
|
-
function
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
5164
|
-
if (reexports) {
|
|
5165
|
-
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
5166
|
-
}
|
|
5167
|
-
}
|
|
5168
|
-
}
|
|
5284
|
+
function errNoAssetSourceSet(assetName) {
|
|
5285
|
+
return {
|
|
5286
|
+
code: Errors.ASSET_SOURCE_MISSING,
|
|
5287
|
+
message: `Plugin error creating asset "${assetName}" - no asset source set.`
|
|
5288
|
+
};
|
|
5169
5289
|
}
|
|
5170
|
-
function
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
? defaultVariableName
|
|
5176
|
-
: moduleVariableName;
|
|
5177
|
-
return isDefaultAProperty(moduleInterop, externalLiveBindings)
|
|
5178
|
-
? `${variableName}['default']`
|
|
5179
|
-
: variableName;
|
|
5180
|
-
}
|
|
5181
|
-
return depNamedExportsMode ? `${moduleVariableName}['default']` : moduleVariableName;
|
|
5182
|
-
}
|
|
5183
|
-
if (imported === '*') {
|
|
5184
|
-
return (isChunk
|
|
5185
|
-
? !depNamedExportsMode
|
|
5186
|
-
: namespaceInteropHelpersByInteropType[String(interop(moduleId))])
|
|
5187
|
-
? namespaceVariableName
|
|
5188
|
-
: moduleVariableName;
|
|
5189
|
-
}
|
|
5190
|
-
return `${moduleVariableName}.${imported}`;
|
|
5290
|
+
function errBadLoader(id) {
|
|
5291
|
+
return {
|
|
5292
|
+
code: Errors.BAD_LOADER,
|
|
5293
|
+
message: `Error loading ${relativeId(id)}: plugin load hook should return a string, a { code, map } object, or nothing/null`
|
|
5294
|
+
};
|
|
5191
5295
|
}
|
|
5192
|
-
function
|
|
5193
|
-
return
|
|
5296
|
+
function errDeprecation(deprecation) {
|
|
5297
|
+
return {
|
|
5298
|
+
code: Errors.DEPRECATED_FEATURE,
|
|
5299
|
+
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
5300
|
+
};
|
|
5194
5301
|
}
|
|
5195
|
-
function
|
|
5196
|
-
return
|
|
5302
|
+
function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
|
|
5303
|
+
return {
|
|
5304
|
+
code: Errors.FILE_NOT_FOUND,
|
|
5305
|
+
message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
|
|
5306
|
+
};
|
|
5197
5307
|
}
|
|
5198
|
-
function
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
}
|
|
5204
|
-
if (addNamespaceToStringTag) {
|
|
5205
|
-
if (namespaceMarkers) {
|
|
5206
|
-
namespaceMarkers += n;
|
|
5207
|
-
}
|
|
5208
|
-
namespaceMarkers += getNamespaceToStringExport(_);
|
|
5209
|
-
}
|
|
5210
|
-
}
|
|
5211
|
-
return namespaceMarkers;
|
|
5308
|
+
function errFileNameConflict(fileName) {
|
|
5309
|
+
return {
|
|
5310
|
+
code: Errors.FILE_NAME_CONFLICT,
|
|
5311
|
+
message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
|
|
5312
|
+
};
|
|
5212
5313
|
}
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
5218
|
-
neededInteropHelpers.add(helper);
|
|
5219
|
-
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
5314
|
+
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
5315
|
+
return {
|
|
5316
|
+
code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
5317
|
+
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.`
|
|
5220
5318
|
};
|
|
5221
|
-
for (const { defaultVariableName, imports, id, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
5222
|
-
if (isChunk) {
|
|
5223
|
-
for (const { imported, reexported } of [
|
|
5224
|
-
...(imports || []),
|
|
5225
|
-
...(reexports || [])
|
|
5226
|
-
]) {
|
|
5227
|
-
if (imported === '*' && reexported !== '*') {
|
|
5228
|
-
if (!namedExportsMode) {
|
|
5229
|
-
addInteropStatement(namespaceVariableName, getDefaultOnlyHelper(), name);
|
|
5230
|
-
}
|
|
5231
|
-
break;
|
|
5232
|
-
}
|
|
5233
|
-
}
|
|
5234
|
-
}
|
|
5235
|
-
else {
|
|
5236
|
-
const moduleInterop = String(interop(id));
|
|
5237
|
-
let hasDefault = false;
|
|
5238
|
-
let hasNamespace = false;
|
|
5239
|
-
for (const { imported, reexported } of [
|
|
5240
|
-
...(imports || []),
|
|
5241
|
-
...(reexports || [])
|
|
5242
|
-
]) {
|
|
5243
|
-
let helper;
|
|
5244
|
-
let variableName;
|
|
5245
|
-
if (imported === 'default') {
|
|
5246
|
-
if (!hasDefault) {
|
|
5247
|
-
hasDefault = true;
|
|
5248
|
-
if (defaultVariableName !== namespaceVariableName) {
|
|
5249
|
-
variableName = defaultVariableName;
|
|
5250
|
-
helper = defaultInteropHelpersByInteropType[moduleInterop];
|
|
5251
|
-
}
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5254
|
-
else if (imported === '*' && reexported !== '*') {
|
|
5255
|
-
if (!hasNamespace) {
|
|
5256
|
-
hasNamespace = true;
|
|
5257
|
-
helper = namespaceInteropHelpersByInteropType[moduleInterop];
|
|
5258
|
-
variableName = namespaceVariableName;
|
|
5259
|
-
}
|
|
5260
|
-
}
|
|
5261
|
-
if (helper) {
|
|
5262
|
-
addInteropStatement(variableName, helper, name);
|
|
5263
|
-
}
|
|
5264
|
-
}
|
|
5265
|
-
}
|
|
5266
|
-
}
|
|
5267
|
-
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
5268
5319
|
}
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
return id[0] === '.' ? removeJsExtension(id) : id;
|
|
5320
|
+
function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
|
|
5321
|
+
return {
|
|
5322
|
+
code: Errors.INVALID_CHUNK,
|
|
5323
|
+
message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
5324
|
+
};
|
|
5275
5325
|
}
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
};
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5326
|
+
function errInvalidExportOptionValue(optionValue) {
|
|
5327
|
+
return {
|
|
5328
|
+
code: Errors.INVALID_EXPORT_OPTION,
|
|
5329
|
+
message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`,
|
|
5330
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5331
|
+
};
|
|
5332
|
+
}
|
|
5333
|
+
function errIncompatibleExportOptionValue(optionValue, keys, entryModule) {
|
|
5334
|
+
return {
|
|
5335
|
+
code: 'INVALID_EXPORT_OPTION',
|
|
5336
|
+
message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${keys.join(', ')}`
|
|
5337
|
+
};
|
|
5338
|
+
}
|
|
5339
|
+
function errInternalIdCannotBeExternal(source, importer) {
|
|
5340
|
+
return {
|
|
5341
|
+
code: Errors.INVALID_EXTERNAL_ID,
|
|
5342
|
+
message: `'${source}' is imported as an external by ${relativeId(importer)}, but is already an existing non-external module id.`
|
|
5343
|
+
};
|
|
5344
|
+
}
|
|
5345
|
+
function errInvalidOption(option, explanation) {
|
|
5346
|
+
return {
|
|
5347
|
+
code: Errors.INVALID_OPTION,
|
|
5348
|
+
message: `Invalid value for option "${option}" - ${explanation}.`
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
function errInvalidRollupPhaseForAddWatchFile() {
|
|
5352
|
+
return {
|
|
5353
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5354
|
+
message: `Cannot call addWatchFile after the build has finished.`
|
|
5355
|
+
};
|
|
5356
|
+
}
|
|
5357
|
+
function errInvalidRollupPhaseForChunkEmission() {
|
|
5358
|
+
return {
|
|
5359
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5360
|
+
message: `Cannot emit chunks after module loading has finished.`
|
|
5361
|
+
};
|
|
5362
|
+
}
|
|
5363
|
+
function errMissingExport(exportName, importingModule, importedModule) {
|
|
5364
|
+
return {
|
|
5365
|
+
code: Errors.MISSING_EXPORT,
|
|
5366
|
+
message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule)}`,
|
|
5367
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
5368
|
+
};
|
|
5369
|
+
}
|
|
5370
|
+
function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
|
|
5371
|
+
return {
|
|
5372
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5373
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
|
|
5374
|
+
};
|
|
5375
|
+
}
|
|
5376
|
+
function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
|
|
5377
|
+
return {
|
|
5378
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5379
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
|
|
5380
|
+
};
|
|
5381
|
+
}
|
|
5382
|
+
function errImplicitDependantIsNotIncluded(module) {
|
|
5383
|
+
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
5384
|
+
return {
|
|
5385
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5386
|
+
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${implicitDependencies.length === 1
|
|
5387
|
+
? implicitDependencies[0]
|
|
5388
|
+
: `${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.`
|
|
5389
|
+
};
|
|
5390
|
+
}
|
|
5391
|
+
function errMixedExport(facadeModuleId, name) {
|
|
5392
|
+
return {
|
|
5393
|
+
code: Errors.MIXED_EXPORTS,
|
|
5394
|
+
id: facadeModuleId,
|
|
5395
|
+
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`,
|
|
5396
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5397
|
+
};
|
|
5398
|
+
}
|
|
5399
|
+
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
5400
|
+
return {
|
|
5401
|
+
code: Errors.NAMESPACE_CONFLICT,
|
|
5402
|
+
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports '${name}' from both ${relativeId(reexportingModule.exportsAll[name])} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`,
|
|
5403
|
+
name,
|
|
5404
|
+
reexporter: reexportingModule.id,
|
|
5405
|
+
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
5406
|
+
};
|
|
5407
|
+
}
|
|
5408
|
+
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
5409
|
+
return {
|
|
5410
|
+
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
5411
|
+
message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
|
|
5412
|
+
'a "code". This will be ignored.'
|
|
5413
|
+
};
|
|
5414
|
+
}
|
|
5415
|
+
function errPreferNamedExports(facadeModuleId) {
|
|
5416
|
+
const file = relativeId(facadeModuleId);
|
|
5417
|
+
return {
|
|
5418
|
+
code: Errors.PREFER_NAMED_EXPORTS,
|
|
5419
|
+
id: facadeModuleId,
|
|
5420
|
+
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.`,
|
|
5421
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
5424
|
+
function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
|
|
5425
|
+
return {
|
|
5426
|
+
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
5427
|
+
id,
|
|
5428
|
+
message: `Module "${relativeId(id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}' needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
|
|
5429
|
+
? `an export named "${syntheticNamedExportsOption}"`
|
|
5430
|
+
: 'a default export'} that does not reexport an unresolved named export of the same module.`
|
|
5431
|
+
};
|
|
5432
|
+
}
|
|
5433
|
+
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
5434
|
+
const importType = isReexport ? 'reexport' : 'import';
|
|
5435
|
+
return {
|
|
5436
|
+
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5437
|
+
id,
|
|
5438
|
+
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.`,
|
|
5439
|
+
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5440
|
+
};
|
|
5441
|
+
}
|
|
5442
|
+
function errUnexpectedNamespaceReexport(id) {
|
|
5443
|
+
return {
|
|
5444
|
+
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5445
|
+
id,
|
|
5446
|
+
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.`,
|
|
5447
|
+
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5448
|
+
};
|
|
5315
5449
|
}
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
const n = compact ? '' : '\n';
|
|
5322
|
-
const s = compact ? '' : ';';
|
|
5323
|
-
const _ = compact ? '' : ' ';
|
|
5324
|
-
if (namedExportsMode && hasExports) {
|
|
5325
|
-
args.unshift(`exports`);
|
|
5326
|
-
deps.unshift(`'exports'`);
|
|
5327
|
-
}
|
|
5328
|
-
if (accessedGlobals.has('require')) {
|
|
5329
|
-
args.unshift('require');
|
|
5330
|
-
deps.unshift(`'require'`);
|
|
5331
|
-
}
|
|
5332
|
-
if (accessedGlobals.has('module')) {
|
|
5333
|
-
args.unshift('module');
|
|
5334
|
-
deps.unshift(`'module'`);
|
|
5335
|
-
}
|
|
5336
|
-
const completeAmdId = getCompleteAmdId(amd, id);
|
|
5337
|
-
const params = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
5338
|
-
(deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
5339
|
-
const useStrict = strict ? `${_}'use strict';` : '';
|
|
5340
|
-
magicString.prepend(`${intro}${getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t)}`);
|
|
5341
|
-
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings);
|
|
5342
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5343
|
-
if (namespaceMarkers) {
|
|
5344
|
-
namespaceMarkers = n + n + namespaceMarkers;
|
|
5345
|
-
}
|
|
5346
|
-
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
5347
|
-
return magicString
|
|
5348
|
-
.indent(t)
|
|
5349
|
-
.prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
5350
|
-
.append(`${n}${n}});`);
|
|
5450
|
+
function errEntryCannotBeExternal(unresolvedId) {
|
|
5451
|
+
return {
|
|
5452
|
+
code: Errors.UNRESOLVED_ENTRY,
|
|
5453
|
+
message: `Entry module cannot be external (${relativeId(unresolvedId)}).`
|
|
5454
|
+
};
|
|
5351
5455
|
}
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
5358
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
|
|
5359
|
-
if (namespaceMarkers) {
|
|
5360
|
-
namespaceMarkers += n + n;
|
|
5361
|
-
}
|
|
5362
|
-
const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _);
|
|
5363
|
-
const interopBlock = getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t);
|
|
5364
|
-
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
5365
|
-
const exportBlock = getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
5366
|
-
return magicString.append(`${exportBlock}${outro}`);
|
|
5456
|
+
function errUnresolvedEntry(unresolvedId) {
|
|
5457
|
+
return {
|
|
5458
|
+
code: Errors.UNRESOLVED_ENTRY,
|
|
5459
|
+
message: `Could not resolve entry module (${relativeId(unresolvedId)}).`
|
|
5460
|
+
};
|
|
5367
5461
|
}
|
|
5368
|
-
function
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
if (importBlock) {
|
|
5374
|
-
importBlock += !compact || definingVariable ? `;${n}` : ',';
|
|
5375
|
-
}
|
|
5376
|
-
definingVariable = false;
|
|
5377
|
-
importBlock += `require('${id}')`;
|
|
5378
|
-
}
|
|
5379
|
-
else {
|
|
5380
|
-
importBlock +=
|
|
5381
|
-
compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${varOrConst} `;
|
|
5382
|
-
definingVariable = true;
|
|
5383
|
-
importBlock += `${name}${_}=${_}require('${id}')`;
|
|
5384
|
-
}
|
|
5385
|
-
}
|
|
5386
|
-
if (importBlock) {
|
|
5387
|
-
return `${importBlock};${n}${n}`;
|
|
5388
|
-
}
|
|
5389
|
-
return '';
|
|
5462
|
+
function errUnresolvedImport(source, importer) {
|
|
5463
|
+
return {
|
|
5464
|
+
code: Errors.UNRESOLVED_IMPORT,
|
|
5465
|
+
message: `Could not resolve '${source}' from ${relativeId(importer)}`
|
|
5466
|
+
};
|
|
5390
5467
|
}
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
magicString.prepend(intro);
|
|
5400
|
-
const exportBlock = getExportBlock$1(exports, _, varOrConst);
|
|
5401
|
-
if (exportBlock.length)
|
|
5402
|
-
magicString.append(n + n + exportBlock.join(n).trim());
|
|
5403
|
-
if (outro)
|
|
5404
|
-
magicString.append(outro);
|
|
5405
|
-
return magicString.trim();
|
|
5468
|
+
function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
5469
|
+
return {
|
|
5470
|
+
code: Errors.UNRESOLVED_IMPORT,
|
|
5471
|
+
importer: relativeId(importer),
|
|
5472
|
+
message: `'${source}' is imported by ${relativeId(importer)}, but could not be resolved – treating it as an external dependency`,
|
|
5473
|
+
source,
|
|
5474
|
+
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
5475
|
+
};
|
|
5406
5476
|
}
|
|
5407
|
-
function
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
if (imports) {
|
|
5415
|
-
let defaultImport = null;
|
|
5416
|
-
let starImport = null;
|
|
5417
|
-
const importedNames = [];
|
|
5418
|
-
for (const specifier of imports) {
|
|
5419
|
-
if (specifier.imported === 'default') {
|
|
5420
|
-
defaultImport = specifier;
|
|
5421
|
-
}
|
|
5422
|
-
else if (specifier.imported === '*') {
|
|
5423
|
-
starImport = specifier;
|
|
5424
|
-
}
|
|
5425
|
-
else {
|
|
5426
|
-
importedNames.push(specifier);
|
|
5427
|
-
}
|
|
5428
|
-
}
|
|
5429
|
-
if (starImport) {
|
|
5430
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
|
|
5431
|
-
}
|
|
5432
|
-
if (defaultImport && importedNames.length === 0) {
|
|
5433
|
-
importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
|
|
5434
|
-
}
|
|
5435
|
-
else if (importedNames.length > 0) {
|
|
5436
|
-
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
5437
|
-
.map(specifier => {
|
|
5438
|
-
if (specifier.imported === specifier.local) {
|
|
5439
|
-
return specifier.imported;
|
|
5440
|
-
}
|
|
5441
|
-
else {
|
|
5442
|
-
return `${specifier.imported} as ${specifier.local}`;
|
|
5443
|
-
}
|
|
5444
|
-
})
|
|
5445
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5446
|
-
}
|
|
5447
|
-
}
|
|
5448
|
-
if (reexports) {
|
|
5449
|
-
let starExport = null;
|
|
5450
|
-
const namespaceReexports = [];
|
|
5451
|
-
const namedReexports = [];
|
|
5452
|
-
for (const specifier of reexports) {
|
|
5453
|
-
if (specifier.reexported === '*') {
|
|
5454
|
-
starExport = specifier;
|
|
5455
|
-
}
|
|
5456
|
-
else if (specifier.imported === '*') {
|
|
5457
|
-
namespaceReexports.push(specifier);
|
|
5458
|
-
}
|
|
5459
|
-
else {
|
|
5460
|
-
namedReexports.push(specifier);
|
|
5461
|
-
}
|
|
5462
|
-
}
|
|
5463
|
-
if (starExport) {
|
|
5464
|
-
importBlock.push(`export${_}*${_}from${_}'${id}';`);
|
|
5465
|
-
}
|
|
5466
|
-
if (namespaceReexports.length > 0) {
|
|
5467
|
-
if (!imports ||
|
|
5468
|
-
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
5469
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`);
|
|
5470
|
-
}
|
|
5471
|
-
for (const specifier of namespaceReexports) {
|
|
5472
|
-
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
5473
|
-
}
|
|
5474
|
-
}
|
|
5475
|
-
if (namedReexports.length > 0) {
|
|
5476
|
-
importBlock.push(`export${_}{${_}${namedReexports
|
|
5477
|
-
.map(specifier => {
|
|
5478
|
-
if (specifier.imported === specifier.reexported) {
|
|
5479
|
-
return specifier.imported;
|
|
5480
|
-
}
|
|
5481
|
-
else {
|
|
5482
|
-
return `${specifier.imported} as ${specifier.reexported}`;
|
|
5483
|
-
}
|
|
5484
|
-
})
|
|
5485
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5486
|
-
}
|
|
5487
|
-
}
|
|
5488
|
-
}
|
|
5489
|
-
return importBlock;
|
|
5477
|
+
function errExternalSyntheticExports(source, importer) {
|
|
5478
|
+
return {
|
|
5479
|
+
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
5480
|
+
importer: relativeId(importer),
|
|
5481
|
+
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
5482
|
+
source
|
|
5483
|
+
};
|
|
5490
5484
|
}
|
|
5491
|
-
function
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5485
|
+
function errFailedValidation(message) {
|
|
5486
|
+
return {
|
|
5487
|
+
code: Errors.VALIDATION_ERROR,
|
|
5488
|
+
message
|
|
5489
|
+
};
|
|
5490
|
+
}
|
|
5491
|
+
function errAlreadyClosed() {
|
|
5492
|
+
return {
|
|
5493
|
+
code: Errors.ALREADY_CLOSED,
|
|
5494
|
+
message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
|
|
5495
|
+
};
|
|
5496
|
+
}
|
|
5497
|
+
function warnDeprecation(deprecation, activeDeprecation, options) {
|
|
5498
|
+
warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
|
|
5499
|
+
}
|
|
5500
|
+
function warnDeprecationWithOptions(deprecation, activeDeprecation, warn, strictDeprecations) {
|
|
5501
|
+
if (activeDeprecation || strictDeprecations) {
|
|
5502
|
+
const warning = errDeprecation(deprecation);
|
|
5503
|
+
if (strictDeprecations) {
|
|
5504
|
+
return error(warning);
|
|
5505
5505
|
}
|
|
5506
|
+
warn(warning);
|
|
5506
5507
|
}
|
|
5507
|
-
if (exportDeclaration.length) {
|
|
5508
|
-
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
5509
|
-
}
|
|
5510
|
-
return exportBlock;
|
|
5511
5508
|
}
|
|
5512
5509
|
|
|
5513
5510
|
// Generate strings which dereference dotted properties, but use array notation `['prop-deref']`
|
|
@@ -7123,7 +7120,7 @@ class DoWhileStatement extends NodeBase {
|
|
|
7123
7120
|
this.included = true;
|
|
7124
7121
|
this.test.include(context, includeChildrenRecursively);
|
|
7125
7122
|
const { brokenFlow } = context;
|
|
7126
|
-
this.body.
|
|
7123
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7127
7124
|
context.brokenFlow = brokenFlow;
|
|
7128
7125
|
}
|
|
7129
7126
|
}
|
|
@@ -7197,11 +7194,11 @@ class ForInStatement extends NodeBase {
|
|
|
7197
7194
|
}
|
|
7198
7195
|
include(context, includeChildrenRecursively) {
|
|
7199
7196
|
this.included = true;
|
|
7200
|
-
this.left.
|
|
7197
|
+
this.left.include(context, includeChildrenRecursively || true);
|
|
7201
7198
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7202
7199
|
this.right.include(context, includeChildrenRecursively);
|
|
7203
7200
|
const { brokenFlow } = context;
|
|
7204
|
-
this.body.
|
|
7201
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7205
7202
|
context.brokenFlow = brokenFlow;
|
|
7206
7203
|
}
|
|
7207
7204
|
render(code, options) {
|
|
@@ -7231,11 +7228,11 @@ class ForOfStatement extends NodeBase {
|
|
|
7231
7228
|
}
|
|
7232
7229
|
include(context, includeChildrenRecursively) {
|
|
7233
7230
|
this.included = true;
|
|
7234
|
-
this.left.
|
|
7231
|
+
this.left.include(context, includeChildrenRecursively || true);
|
|
7235
7232
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7236
7233
|
this.right.include(context, includeChildrenRecursively);
|
|
7237
7234
|
const { brokenFlow } = context;
|
|
7238
|
-
this.body.
|
|
7235
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7239
7236
|
context.brokenFlow = brokenFlow;
|
|
7240
7237
|
}
|
|
7241
7238
|
render(code, options) {
|
|
@@ -7271,13 +7268,13 @@ class ForStatement extends NodeBase {
|
|
|
7271
7268
|
include(context, includeChildrenRecursively) {
|
|
7272
7269
|
this.included = true;
|
|
7273
7270
|
if (this.init)
|
|
7274
|
-
this.init.
|
|
7271
|
+
this.init.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7275
7272
|
if (this.test)
|
|
7276
7273
|
this.test.include(context, includeChildrenRecursively);
|
|
7277
7274
|
const { brokenFlow } = context;
|
|
7278
7275
|
if (this.update)
|
|
7279
7276
|
this.update.include(context, includeChildrenRecursively);
|
|
7280
|
-
this.body.
|
|
7277
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
7281
7278
|
context.brokenFlow = brokenFlow;
|
|
7282
7279
|
}
|
|
7283
7280
|
render(code, options) {
|
|
@@ -7418,10 +7415,10 @@ class IfStatement extends NodeBase {
|
|
|
7418
7415
|
this.test.include(context, false);
|
|
7419
7416
|
}
|
|
7420
7417
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
7421
|
-
this.consequent.
|
|
7418
|
+
this.consequent.includeAsSingleStatement(context, false);
|
|
7422
7419
|
}
|
|
7423
7420
|
if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) {
|
|
7424
|
-
this.alternate.
|
|
7421
|
+
this.alternate.includeAsSingleStatement(context, false);
|
|
7425
7422
|
}
|
|
7426
7423
|
}
|
|
7427
7424
|
includeRecursively(includeChildrenRecursively, context) {
|
|
@@ -7436,12 +7433,12 @@ class IfStatement extends NodeBase {
|
|
|
7436
7433
|
const { brokenFlow } = context;
|
|
7437
7434
|
let consequentBrokenFlow = BROKEN_FLOW_NONE;
|
|
7438
7435
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
7439
|
-
this.consequent.
|
|
7436
|
+
this.consequent.includeAsSingleStatement(context, false);
|
|
7440
7437
|
consequentBrokenFlow = context.brokenFlow;
|
|
7441
7438
|
context.brokenFlow = brokenFlow;
|
|
7442
7439
|
}
|
|
7443
7440
|
if (this.alternate !== null && this.alternate.shouldBeIncluded(context)) {
|
|
7444
|
-
this.alternate.
|
|
7441
|
+
this.alternate.includeAsSingleStatement(context, false);
|
|
7445
7442
|
context.brokenFlow =
|
|
7446
7443
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
7447
7444
|
}
|
|
@@ -8957,11 +8954,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
8957
8954
|
declarator.include(context, includeChildrenRecursively);
|
|
8958
8955
|
}
|
|
8959
8956
|
}
|
|
8960
|
-
|
|
8957
|
+
includeAsSingleStatement(context, includeChildrenRecursively) {
|
|
8961
8958
|
this.included = true;
|
|
8962
8959
|
for (const declarator of this.declarations) {
|
|
8963
|
-
declarator.
|
|
8964
|
-
|
|
8960
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
|
|
8961
|
+
declarator.include(context, includeChildrenRecursively);
|
|
8962
|
+
declarator.id.include(context, includeChildrenRecursively);
|
|
8963
|
+
}
|
|
8965
8964
|
}
|
|
8966
8965
|
}
|
|
8967
8966
|
initialise() {
|
|
@@ -8983,11 +8982,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
8983
8982
|
this.renderReplacedDeclarations(code, options, nodeRenderOptions);
|
|
8984
8983
|
}
|
|
8985
8984
|
}
|
|
8986
|
-
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
8985
|
+
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement) {
|
|
8987
8986
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
8988
8987
|
code.remove(this.end - 1, this.end);
|
|
8989
8988
|
}
|
|
8990
|
-
|
|
8989
|
+
if (!isNoStatement) {
|
|
8990
|
+
separatorString += ';';
|
|
8991
|
+
}
|
|
8991
8992
|
if (lastSeparatorPos !== null) {
|
|
8992
8993
|
if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
|
|
8993
8994
|
(code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
|
|
@@ -9012,7 +9013,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9012
9013
|
code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
|
|
9013
9014
|
}
|
|
9014
9015
|
}
|
|
9015
|
-
renderReplacedDeclarations(code, options, { start = this.start, end = this.end }) {
|
|
9016
|
+
renderReplacedDeclarations(code, options, { start = this.start, end = this.end, isNoStatement }) {
|
|
9016
9017
|
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
|
|
9017
9018
|
let actualContentEnd, renderedContentEnd;
|
|
9018
9019
|
renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
|
|
@@ -9083,7 +9084,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9083
9084
|
separatorString = nextSeparatorString;
|
|
9084
9085
|
}
|
|
9085
9086
|
if (hasRenderedContent) {
|
|
9086
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options);
|
|
9087
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement);
|
|
9087
9088
|
}
|
|
9088
9089
|
else {
|
|
9089
9090
|
code.remove(start, end);
|
|
@@ -9110,10 +9111,6 @@ class VariableDeclarator extends NodeBase {
|
|
|
9110
9111
|
this.init.include(context, includeChildrenRecursively);
|
|
9111
9112
|
}
|
|
9112
9113
|
}
|
|
9113
|
-
includeAllDeclaredVariables(context, includeChildrenRecursively) {
|
|
9114
|
-
this.included = true;
|
|
9115
|
-
this.id.include(context, includeChildrenRecursively);
|
|
9116
|
-
}
|
|
9117
9114
|
render(code, options) {
|
|
9118
9115
|
const renderId = this.id.included;
|
|
9119
9116
|
if (renderId) {
|
|
@@ -9147,7 +9144,7 @@ class WhileStatement extends NodeBase {
|
|
|
9147
9144
|
this.included = true;
|
|
9148
9145
|
this.test.include(context, includeChildrenRecursively);
|
|
9149
9146
|
const { brokenFlow } = context;
|
|
9150
|
-
this.body.
|
|
9147
|
+
this.body.includeAsSingleStatement(context, includeChildrenRecursively);
|
|
9151
9148
|
context.brokenFlow = brokenFlow;
|
|
9152
9149
|
}
|
|
9153
9150
|
}
|
|
@@ -9774,7 +9771,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
9774
9771
|
if (!currentVariable || referencedVariables.has(currentVariable)) {
|
|
9775
9772
|
break;
|
|
9776
9773
|
}
|
|
9777
|
-
referencedVariables.add(
|
|
9774
|
+
referencedVariables.add(currentVariable);
|
|
9778
9775
|
sideEffectModules.add(importingModule);
|
|
9779
9776
|
const originalSideEffects = importingModule.sideEffectDependenciesByVariable.get(currentVariable);
|
|
9780
9777
|
if (originalSideEffects) {
|
|
@@ -10476,14 +10473,16 @@ class Module {
|
|
|
10476
10473
|
variable.include();
|
|
10477
10474
|
this.graph.needsTreeshakingPass = true;
|
|
10478
10475
|
const variableModule = variable.module;
|
|
10479
|
-
if (variableModule && variableModule
|
|
10476
|
+
if (variableModule && variableModule instanceof Module) {
|
|
10480
10477
|
if (!variableModule.isExecuted) {
|
|
10481
10478
|
markModuleAndImpureDependenciesAsExecuted(variableModule);
|
|
10482
10479
|
}
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10480
|
+
if (variableModule !== this) {
|
|
10481
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
10482
|
+
for (const module of sideEffectModules) {
|
|
10483
|
+
if (!module.isExecuted) {
|
|
10484
|
+
markModuleAndImpureDependenciesAsExecuted(module);
|
|
10485
|
+
}
|
|
10487
10486
|
}
|
|
10488
10487
|
}
|
|
10489
10488
|
}
|
|
@@ -18057,7 +18056,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, skip,
|
|
|
18057
18056
|
// absolute path is created. Absolute importees therefore shortcircuit the
|
|
18058
18057
|
// resolve call and require no special handing on our part.
|
|
18059
18058
|
// See https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
18060
|
-
return addJsExtensionIfNecessary(
|
|
18059
|
+
return addJsExtensionIfNecessary(importer ? resolve(dirname(importer), source) : resolve(source), preserveSymlinks);
|
|
18061
18060
|
}
|
|
18062
18061
|
function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
18063
18062
|
let found = findFile(file, preserveSymlinks);
|