rollup 2.36.1 → 2.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/LICENSE.md +1 -28
- package/dist/bin/rollup +6 -5
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +1438 -1403
- package/dist/es/shared/watch.js +10 -6
- package/dist/loadConfigFile.js +5 -5
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.js +3 -3
- package/dist/shared/index.js +9 -5
- package/dist/shared/loadConfigFile.js +4 -4
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +1397 -1362
- package/dist/shared/watch-cli.js +12 -12
- package/dist/shared/watch.js +8 -8
- package/package.json +14 -18
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.38.0
|
|
4
|
+
Fri, 22 Jan 2021 16:26:00 GMT - commit 889fa5267ad93cc706fdbff2024e9c4d4f273749
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -13,7 +13,7 @@ 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.
|
|
16
|
+
var version = "2.38.0";
|
|
17
17
|
|
|
18
18
|
var charToInteger = {};
|
|
19
19
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1518,11 +1518,11 @@ function findFirstOccurrenceOutsideComment(code, searchString, start = 0) {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
|
-
const
|
|
1521
|
+
const NON_WHITESPACE = /\S/g;
|
|
1522
1522
|
function findNonWhiteSpace(code, index) {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
return index;
|
|
1523
|
+
NON_WHITESPACE.lastIndex = index;
|
|
1524
|
+
const result = NON_WHITESPACE.exec(code);
|
|
1525
|
+
return result.index;
|
|
1526
1526
|
}
|
|
1527
1527
|
// This assumes "code" only contains white-space and comments
|
|
1528
1528
|
// Returns position of line-comment if applicable
|
|
@@ -2183,6 +2183,34 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
2183
2183
|
: new members[memberName].returns();
|
|
2184
2184
|
}
|
|
2185
2185
|
|
|
2186
|
+
const BROKEN_FLOW_NONE = 0;
|
|
2187
|
+
const BROKEN_FLOW_BREAK_CONTINUE = 1;
|
|
2188
|
+
const BROKEN_FLOW_ERROR_RETURN_LABEL = 2;
|
|
2189
|
+
function createInclusionContext() {
|
|
2190
|
+
return {
|
|
2191
|
+
brokenFlow: BROKEN_FLOW_NONE,
|
|
2192
|
+
includedCallArguments: new Set(),
|
|
2193
|
+
includedLabels: new Set()
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
function createHasEffectsContext() {
|
|
2197
|
+
return {
|
|
2198
|
+
accessed: new PathTracker(),
|
|
2199
|
+
assigned: new PathTracker(),
|
|
2200
|
+
brokenFlow: BROKEN_FLOW_NONE,
|
|
2201
|
+
called: new DiscriminatedPathTracker(),
|
|
2202
|
+
ignore: {
|
|
2203
|
+
breaks: false,
|
|
2204
|
+
continues: false,
|
|
2205
|
+
labels: new Set(),
|
|
2206
|
+
returnAwaitYield: false
|
|
2207
|
+
},
|
|
2208
|
+
includedLabels: new Set(),
|
|
2209
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2210
|
+
replacedVariableInits: new Map()
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2186
2214
|
class Variable {
|
|
2187
2215
|
constructor(name) {
|
|
2188
2216
|
this.alwaysRendered = false;
|
|
@@ -2244,205 +2272,6 @@ class Variable {
|
|
|
2244
2272
|
}
|
|
2245
2273
|
}
|
|
2246
2274
|
|
|
2247
|
-
class ExternalVariable extends Variable {
|
|
2248
|
-
constructor(module, name) {
|
|
2249
|
-
super(name);
|
|
2250
|
-
this.module = module;
|
|
2251
|
-
this.isNamespace = name === '*';
|
|
2252
|
-
this.referenced = false;
|
|
2253
|
-
}
|
|
2254
|
-
addReference(identifier) {
|
|
2255
|
-
this.referenced = true;
|
|
2256
|
-
if (this.name === 'default' || this.name === '*') {
|
|
2257
|
-
this.module.suggestName(identifier.name);
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
include() {
|
|
2261
|
-
if (!this.included) {
|
|
2262
|
-
this.included = true;
|
|
2263
|
-
this.module.used = true;
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
const BLANK = Object.freeze(Object.create(null));
|
|
2269
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
2270
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
2271
|
-
|
|
2272
|
-
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(' ');
|
|
2273
|
-
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(' ');
|
|
2274
|
-
const blacklisted = new Set(reservedWords.concat(builtins));
|
|
2275
|
-
const illegalCharacters = /[^$_a-zA-Z0-9]/g;
|
|
2276
|
-
const startsWithDigit = (str) => /\d/.test(str[0]);
|
|
2277
|
-
function isLegal(str) {
|
|
2278
|
-
if (startsWithDigit(str) || blacklisted.has(str)) {
|
|
2279
|
-
return false;
|
|
2280
|
-
}
|
|
2281
|
-
return !illegalCharacters.test(str);
|
|
2282
|
-
}
|
|
2283
|
-
function makeLegal(str) {
|
|
2284
|
-
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
|
|
2285
|
-
if (startsWithDigit(str) || blacklisted.has(str))
|
|
2286
|
-
str = `_${str}`;
|
|
2287
|
-
return str || '_';
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
|
2291
|
-
const relativePath = /^\.?\.\//;
|
|
2292
|
-
function isAbsolute(path) {
|
|
2293
|
-
return absolutePath.test(path);
|
|
2294
|
-
}
|
|
2295
|
-
function isRelative(path) {
|
|
2296
|
-
return relativePath.test(path);
|
|
2297
|
-
}
|
|
2298
|
-
function normalize(path) {
|
|
2299
|
-
if (path.indexOf('\\') == -1)
|
|
2300
|
-
return path;
|
|
2301
|
-
return path.replace(/\\/g, '/');
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
class ExternalModule {
|
|
2305
|
-
constructor(options, id, hasModuleSideEffects, meta) {
|
|
2306
|
-
this.options = options;
|
|
2307
|
-
this.id = id;
|
|
2308
|
-
this.defaultVariableName = '';
|
|
2309
|
-
this.dynamicImporters = [];
|
|
2310
|
-
this.importers = [];
|
|
2311
|
-
this.mostCommonSuggestion = 0;
|
|
2312
|
-
this.namespaceVariableName = '';
|
|
2313
|
-
this.reexported = false;
|
|
2314
|
-
this.renderPath = undefined;
|
|
2315
|
-
this.renormalizeRenderPath = false;
|
|
2316
|
-
this.used = false;
|
|
2317
|
-
this.variableName = '';
|
|
2318
|
-
this.execIndex = Infinity;
|
|
2319
|
-
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2320
|
-
this.nameSuggestions = Object.create(null);
|
|
2321
|
-
this.declarations = Object.create(null);
|
|
2322
|
-
this.exportedVariables = new Map();
|
|
2323
|
-
const module = this;
|
|
2324
|
-
this.info = {
|
|
2325
|
-
ast: null,
|
|
2326
|
-
code: null,
|
|
2327
|
-
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
2328
|
-
get dynamicImporters() {
|
|
2329
|
-
return module.dynamicImporters.sort();
|
|
2330
|
-
},
|
|
2331
|
-
hasModuleSideEffects,
|
|
2332
|
-
id,
|
|
2333
|
-
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
|
|
2334
|
-
implicitlyLoadedBefore: EMPTY_ARRAY,
|
|
2335
|
-
importedIds: EMPTY_ARRAY,
|
|
2336
|
-
get importers() {
|
|
2337
|
-
return module.importers.sort();
|
|
2338
|
-
},
|
|
2339
|
-
isEntry: false,
|
|
2340
|
-
isExternal: true,
|
|
2341
|
-
meta,
|
|
2342
|
-
syntheticNamedExports: false
|
|
2343
|
-
};
|
|
2344
|
-
}
|
|
2345
|
-
getVariableForExportName(name) {
|
|
2346
|
-
let declaration = this.declarations[name];
|
|
2347
|
-
if (declaration)
|
|
2348
|
-
return declaration;
|
|
2349
|
-
this.declarations[name] = declaration = new ExternalVariable(this, name);
|
|
2350
|
-
this.exportedVariables.set(declaration, name);
|
|
2351
|
-
return declaration;
|
|
2352
|
-
}
|
|
2353
|
-
setRenderPath(options, inputBase) {
|
|
2354
|
-
this.renderPath =
|
|
2355
|
-
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
|
|
2356
|
-
if (!this.renderPath) {
|
|
2357
|
-
if (!isAbsolute(this.id)) {
|
|
2358
|
-
this.renderPath = this.id;
|
|
2359
|
-
}
|
|
2360
|
-
else {
|
|
2361
|
-
this.renderPath = normalize(relative$1(inputBase, this.id));
|
|
2362
|
-
this.renormalizeRenderPath = true;
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
return this.renderPath;
|
|
2366
|
-
}
|
|
2367
|
-
suggestName(name) {
|
|
2368
|
-
if (!this.nameSuggestions[name])
|
|
2369
|
-
this.nameSuggestions[name] = 0;
|
|
2370
|
-
this.nameSuggestions[name] += 1;
|
|
2371
|
-
if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
|
|
2372
|
-
this.mostCommonSuggestion = this.nameSuggestions[name];
|
|
2373
|
-
this.suggestedVariableName = name;
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
warnUnusedImports() {
|
|
2377
|
-
const unused = Object.keys(this.declarations).filter(name => {
|
|
2378
|
-
if (name === '*')
|
|
2379
|
-
return false;
|
|
2380
|
-
const declaration = this.declarations[name];
|
|
2381
|
-
return !declaration.included && !this.reexported && !declaration.referenced;
|
|
2382
|
-
});
|
|
2383
|
-
if (unused.length === 0)
|
|
2384
|
-
return;
|
|
2385
|
-
const names = unused.length === 1
|
|
2386
|
-
? `'${unused[0]}' is`
|
|
2387
|
-
: `${unused
|
|
2388
|
-
.slice(0, -1)
|
|
2389
|
-
.map(name => `'${name}'`)
|
|
2390
|
-
.join(', ')} and '${unused.slice(-1)}' are`;
|
|
2391
|
-
this.options.onwarn({
|
|
2392
|
-
code: 'UNUSED_EXTERNAL_IMPORT',
|
|
2393
|
-
message: `${names} imported from external module '${this.id}' but never used`,
|
|
2394
|
-
names: unused,
|
|
2395
|
-
source: this.id
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
function markModuleAndImpureDependenciesAsExecuted(baseModule) {
|
|
2401
|
-
baseModule.isExecuted = true;
|
|
2402
|
-
const modules = [baseModule];
|
|
2403
|
-
const visitedModules = new Set();
|
|
2404
|
-
for (const module of modules) {
|
|
2405
|
-
for (const dependency of [...module.dependencies, ...module.implicitlyLoadedBefore]) {
|
|
2406
|
-
if (!(dependency instanceof ExternalModule) &&
|
|
2407
|
-
!dependency.isExecuted &&
|
|
2408
|
-
(dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
|
|
2409
|
-
!visitedModules.has(dependency.id)) {
|
|
2410
|
-
dependency.isExecuted = true;
|
|
2411
|
-
visitedModules.add(dependency.id);
|
|
2412
|
-
modules.push(dependency);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
const BROKEN_FLOW_NONE = 0;
|
|
2419
|
-
const BROKEN_FLOW_BREAK_CONTINUE = 1;
|
|
2420
|
-
const BROKEN_FLOW_ERROR_RETURN_LABEL = 2;
|
|
2421
|
-
function createInclusionContext() {
|
|
2422
|
-
return {
|
|
2423
|
-
brokenFlow: BROKEN_FLOW_NONE,
|
|
2424
|
-
includedCallArguments: new Set(),
|
|
2425
|
-
includedLabels: new Set()
|
|
2426
|
-
};
|
|
2427
|
-
}
|
|
2428
|
-
function createHasEffectsContext() {
|
|
2429
|
-
return {
|
|
2430
|
-
accessed: new PathTracker(),
|
|
2431
|
-
assigned: new PathTracker(),
|
|
2432
|
-
brokenFlow: BROKEN_FLOW_NONE,
|
|
2433
|
-
called: new DiscriminatedPathTracker(),
|
|
2434
|
-
ignore: {
|
|
2435
|
-
breaks: false,
|
|
2436
|
-
continues: false,
|
|
2437
|
-
labels: new Set(),
|
|
2438
|
-
returnAwaitYield: false
|
|
2439
|
-
},
|
|
2440
|
-
includedLabels: new Set(),
|
|
2441
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
2442
|
-
replacedVariableInits: new Map()
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
2275
|
// To avoid infinite recursions
|
|
2447
2276
|
const MAX_PATH_DEPTH = 7;
|
|
2448
2277
|
class LocalVariable extends Variable {
|
|
@@ -2565,9 +2394,6 @@ class LocalVariable extends Variable {
|
|
|
2565
2394
|
include() {
|
|
2566
2395
|
if (!this.included) {
|
|
2567
2396
|
this.included = true;
|
|
2568
|
-
if (!this.module.isExecuted) {
|
|
2569
|
-
markModuleAndImpureDependenciesAsExecuted(this.module);
|
|
2570
|
-
}
|
|
2571
2397
|
for (const declaration of this.declarations) {
|
|
2572
2398
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
2573
2399
|
if (!declaration.included)
|
|
@@ -2772,6 +2598,7 @@ class NodeBase {
|
|
|
2772
2598
|
this.context.magicString.addSourcemapLocation(this.start);
|
|
2773
2599
|
this.context.magicString.addSourcemapLocation(this.end);
|
|
2774
2600
|
}
|
|
2601
|
+
addExportedVariables(_variables, _exportNamesByVariable) { }
|
|
2775
2602
|
/**
|
|
2776
2603
|
* Override this to bind assignments to variables and do any initialisations that
|
|
2777
2604
|
* require the scopes to be populated with variables.
|
|
@@ -2798,9 +2625,6 @@ class NodeBase {
|
|
|
2798
2625
|
createScope(parentScope) {
|
|
2799
2626
|
this.scope = parentScope;
|
|
2800
2627
|
}
|
|
2801
|
-
declare(_kind, _init) {
|
|
2802
|
-
return [];
|
|
2803
|
-
}
|
|
2804
2628
|
deoptimizePath(_path) { }
|
|
2805
2629
|
getLiteralValueAtPath(_path, _recursionTracker, _origin) {
|
|
2806
2630
|
return UnknownValue;
|
|
@@ -2850,14 +2674,14 @@ class NodeBase {
|
|
|
2850
2674
|
}
|
|
2851
2675
|
}
|
|
2852
2676
|
}
|
|
2677
|
+
includeAllDeclaredVariables(context, includeChildrenRecursively) {
|
|
2678
|
+
this.include(context, includeChildrenRecursively);
|
|
2679
|
+
}
|
|
2853
2680
|
includeCallArguments(context, args) {
|
|
2854
2681
|
for (const arg of args) {
|
|
2855
2682
|
arg.include(context, false);
|
|
2856
2683
|
}
|
|
2857
2684
|
}
|
|
2858
|
-
includeWithAllDeclaredVariables(includeChildrenRecursively, context) {
|
|
2859
|
-
this.include(context, includeChildrenRecursively);
|
|
2860
|
-
}
|
|
2861
2685
|
/**
|
|
2862
2686
|
* Override to perform special initialisation steps after the scope is initialised
|
|
2863
2687
|
*/
|
|
@@ -2910,9 +2734,6 @@ class NodeBase {
|
|
|
2910
2734
|
shouldBeIncluded(context) {
|
|
2911
2735
|
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
2912
2736
|
}
|
|
2913
|
-
toString() {
|
|
2914
|
-
return this.context.code.slice(this.start, this.end);
|
|
2915
|
-
}
|
|
2916
2737
|
}
|
|
2917
2738
|
|
|
2918
2739
|
class ClassNode extends NodeBase {
|
|
@@ -3161,6 +2982,10 @@ function isReference(node, parent) {
|
|
|
3161
2982
|
return false;
|
|
3162
2983
|
}
|
|
3163
2984
|
|
|
2985
|
+
const BLANK = Object.freeze(Object.create(null));
|
|
2986
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
2987
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
2988
|
+
|
|
3164
2989
|
const ValueProperties = Symbol('Value Properties');
|
|
3165
2990
|
const PURE = { pure: true };
|
|
3166
2991
|
const IMPURE = { pure: false };
|
|
@@ -4128,7 +3953,7 @@ class Identifier$1 extends NodeBase {
|
|
|
4128
3953
|
if (!this.included) {
|
|
4129
3954
|
this.included = true;
|
|
4130
3955
|
if (this.variable !== null) {
|
|
4131
|
-
this.context.
|
|
3956
|
+
this.context.includeVariableInModule(this.variable);
|
|
4132
3957
|
}
|
|
4133
3958
|
}
|
|
4134
3959
|
}
|
|
@@ -4320,7 +4145,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
4320
4145
|
include(context, includeChildrenRecursively) {
|
|
4321
4146
|
super.include(context, includeChildrenRecursively);
|
|
4322
4147
|
if (includeChildrenRecursively) {
|
|
4323
|
-
this.context.
|
|
4148
|
+
this.context.includeVariableInModule(this.variable);
|
|
4324
4149
|
}
|
|
4325
4150
|
}
|
|
4326
4151
|
initialise() {
|
|
@@ -4403,9 +4228,8 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
4403
4228
|
constructor(name, exportDefaultDeclaration, context) {
|
|
4404
4229
|
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context);
|
|
4405
4230
|
this.hasId = false;
|
|
4406
|
-
// Not initialised during construction
|
|
4407
4231
|
this.originalId = null;
|
|
4408
|
-
this.
|
|
4232
|
+
this.originalVariable = null;
|
|
4409
4233
|
const declaration = exportDefaultDeclaration.declaration;
|
|
4410
4234
|
if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
|
|
4411
4235
|
declaration.id) {
|
|
@@ -4433,6 +4257,14 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
4433
4257
|
return original.getBaseVariableName();
|
|
4434
4258
|
}
|
|
4435
4259
|
}
|
|
4260
|
+
getDirectOriginalVariable() {
|
|
4261
|
+
return this.originalId &&
|
|
4262
|
+
(this.hasId ||
|
|
4263
|
+
!(this.originalId.variable.isReassigned ||
|
|
4264
|
+
this.originalId.variable instanceof UndefinedVariable))
|
|
4265
|
+
? this.originalId.variable
|
|
4266
|
+
: null;
|
|
4267
|
+
}
|
|
4436
4268
|
getName() {
|
|
4437
4269
|
const original = this.getOriginalVariable();
|
|
4438
4270
|
if (original === this) {
|
|
@@ -4443,34 +4275,17 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
4443
4275
|
}
|
|
4444
4276
|
}
|
|
4445
4277
|
getOriginalVariable() {
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
const assignedOriginal = this.originalId.variable;
|
|
4458
|
-
if (assignedOriginal instanceof ExportDefaultVariable) {
|
|
4459
|
-
const { modules, original } = assignedOriginal.getOriginalVariableAndDeclarationModules();
|
|
4460
|
-
this.originalVariableAndDeclarationModules = {
|
|
4461
|
-
modules: modules.concat(this.module),
|
|
4462
|
-
original
|
|
4463
|
-
};
|
|
4464
|
-
}
|
|
4465
|
-
else {
|
|
4466
|
-
this.originalVariableAndDeclarationModules = {
|
|
4467
|
-
modules: [this.module],
|
|
4468
|
-
original: assignedOriginal
|
|
4469
|
-
};
|
|
4470
|
-
}
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4473
|
-
return this.originalVariableAndDeclarationModules;
|
|
4278
|
+
if (this.originalVariable)
|
|
4279
|
+
return this.originalVariable;
|
|
4280
|
+
let original = this;
|
|
4281
|
+
let currentVariable;
|
|
4282
|
+
const checkedVariables = new Set();
|
|
4283
|
+
do {
|
|
4284
|
+
checkedVariables.add(original);
|
|
4285
|
+
currentVariable = original;
|
|
4286
|
+
original = currentVariable.getDirectOriginalVariable();
|
|
4287
|
+
} while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
|
|
4288
|
+
return (this.originalVariable = original || currentVariable);
|
|
4474
4289
|
}
|
|
4475
4290
|
}
|
|
4476
4291
|
|
|
@@ -4583,918 +4398,1116 @@ class NamespaceVariable extends Variable {
|
|
|
4583
4398
|
}
|
|
4584
4399
|
NamespaceVariable.prototype.isNamespace = true;
|
|
4585
4400
|
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
getBaseVariableName() {
|
|
4604
|
-
return this.syntheticNamespace.getBaseVariableName();
|
|
4605
|
-
}
|
|
4606
|
-
getName() {
|
|
4607
|
-
const name = this.name;
|
|
4608
|
-
return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`;
|
|
4401
|
+
function spaces(i) {
|
|
4402
|
+
let result = '';
|
|
4403
|
+
while (i--)
|
|
4404
|
+
result += ' ';
|
|
4405
|
+
return result;
|
|
4406
|
+
}
|
|
4407
|
+
function tabsToSpaces(str) {
|
|
4408
|
+
return str.replace(/^\t+/, match => match.split('\t').join(' '));
|
|
4409
|
+
}
|
|
4410
|
+
function getCodeFrame(source, line, column) {
|
|
4411
|
+
let lines = source.split('\n');
|
|
4412
|
+
const frameStart = Math.max(0, line - 3);
|
|
4413
|
+
let frameEnd = Math.min(line + 2, lines.length);
|
|
4414
|
+
lines = lines.slice(frameStart, frameEnd);
|
|
4415
|
+
while (!/\S/.test(lines[lines.length - 1])) {
|
|
4416
|
+
lines.pop();
|
|
4417
|
+
frameEnd -= 1;
|
|
4609
4418
|
}
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4419
|
+
const digits = String(frameEnd).length;
|
|
4420
|
+
return lines
|
|
4421
|
+
.map((str, i) => {
|
|
4422
|
+
const isErrorLine = frameStart + i + 1 === line;
|
|
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}`;
|
|
4614
4429
|
}
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
}
|
|
4430
|
+
return `${lineNum}: ${tabsToSpaces(str)}`;
|
|
4431
|
+
})
|
|
4432
|
+
.join('\n');
|
|
4619
4433
|
}
|
|
4620
|
-
const getPropertyAccess = (name) => {
|
|
4621
|
-
return !RESERVED_NAMES[name] && /^(?!\d)[\w$]+$/.test(name)
|
|
4622
|
-
? `.${name}`
|
|
4623
|
-
: `[${JSON.stringify(name)}]`;
|
|
4624
|
-
};
|
|
4625
4434
|
|
|
4626
|
-
|
|
4627
|
-
|
|
4435
|
+
const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
|
4436
|
+
const relativePath = /^\.?\.\//;
|
|
4437
|
+
function isAbsolute(path) {
|
|
4438
|
+
return absolutePath.test(path);
|
|
4439
|
+
}
|
|
4440
|
+
function isRelative(path) {
|
|
4441
|
+
return relativePath.test(path);
|
|
4442
|
+
}
|
|
4443
|
+
function normalize(path) {
|
|
4444
|
+
if (path.indexOf('\\') == -1)
|
|
4445
|
+
return path;
|
|
4446
|
+
return path.replace(/\\/g, '/');
|
|
4628
4447
|
}
|
|
4629
4448
|
|
|
4630
|
-
function
|
|
4631
|
-
|
|
4632
|
-
return options.id || '';
|
|
4633
|
-
}
|
|
4634
|
-
else {
|
|
4635
|
-
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
4636
|
-
}
|
|
4449
|
+
function sanitizeFileName(name) {
|
|
4450
|
+
return name.replace(/[\0?*]/g, '_');
|
|
4637
4451
|
}
|
|
4638
4452
|
|
|
4639
|
-
|
|
4640
|
-
const
|
|
4641
|
-
|
|
4642
|
-
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
4643
|
-
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
4644
|
-
const defaultInteropHelpersByInteropType = {
|
|
4645
|
-
auto: INTEROP_DEFAULT_VARIABLE,
|
|
4646
|
-
default: null,
|
|
4647
|
-
defaultOnly: null,
|
|
4648
|
-
esModule: null,
|
|
4649
|
-
false: null,
|
|
4650
|
-
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
4651
|
-
};
|
|
4652
|
-
function isDefaultAProperty(interopType, externalLiveBindings) {
|
|
4653
|
-
return (interopType === 'esModule' ||
|
|
4654
|
-
(externalLiveBindings && (interopType === 'auto' || interopType === 'true')));
|
|
4453
|
+
function getAliasName(id) {
|
|
4454
|
+
const base = basename(id);
|
|
4455
|
+
return base.substr(0, base.length - extname(id).length);
|
|
4655
4456
|
}
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
esModule: null,
|
|
4661
|
-
false: null,
|
|
4662
|
-
true: INTEROP_NAMESPACE_VARIABLE
|
|
4663
|
-
};
|
|
4664
|
-
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
4665
|
-
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
4666
|
-
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
4457
|
+
function relativeId(id) {
|
|
4458
|
+
if (typeof process === 'undefined' || !isAbsolute(id))
|
|
4459
|
+
return id;
|
|
4460
|
+
return relative$1(process.cwd(), id);
|
|
4667
4461
|
}
|
|
4668
|
-
function
|
|
4669
|
-
|
|
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));
|
|
4670
4468
|
}
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4469
|
+
|
|
4470
|
+
function error(base) {
|
|
4471
|
+
if (!(base instanceof Error))
|
|
4472
|
+
base = Object.assign(new Error(base.message), base);
|
|
4473
|
+
throw base;
|
|
4675
4474
|
}
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
4691
|
-
`}${n}${n}`,
|
|
4692
|
-
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
4693
|
-
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
4694
|
-
`}${n}${n}`
|
|
4695
|
-
};
|
|
4696
|
-
function getDefaultLiveBinding(_) {
|
|
4697
|
-
return `e${_}:${_}{${_}'default':${_}e${_}}`;
|
|
4475
|
+
function augmentCodeLocation(props, pos, source, id) {
|
|
4476
|
+
if (typeof pos === 'object') {
|
|
4477
|
+
const { line, column } = pos;
|
|
4478
|
+
props.loc = { file: id, line, column };
|
|
4479
|
+
}
|
|
4480
|
+
else {
|
|
4481
|
+
props.pos = pos;
|
|
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);
|
|
4488
|
+
}
|
|
4698
4489
|
}
|
|
4699
|
-
|
|
4700
|
-
|
|
4490
|
+
var Errors;
|
|
4491
|
+
(function (Errors) {
|
|
4492
|
+
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
4493
|
+
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
4494
|
+
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
4495
|
+
Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
|
|
4496
|
+
Errors["ASSET_SOURCE_MISSING"] = "ASSET_SOURCE_MISSING";
|
|
4497
|
+
Errors["BAD_LOADER"] = "BAD_LOADER";
|
|
4498
|
+
Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
|
|
4499
|
+
Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
|
|
4500
|
+
Errors["CIRCULAR_REEXPORT"] = "CIRCULAR_REEXPORT";
|
|
4501
|
+
Errors["CYCLIC_CROSS_CHUNK_REEXPORT"] = "CYCLIC_CROSS_CHUNK_REEXPORT";
|
|
4502
|
+
Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
|
|
4503
|
+
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
4504
|
+
Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
|
|
4505
|
+
Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
4506
|
+
Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
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
|
+
};
|
|
4701
4531
|
}
|
|
4702
|
-
function
|
|
4703
|
-
return
|
|
4704
|
-
|
|
4705
|
-
:
|
|
4706
|
-
|
|
4707
|
-
`${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` +
|
|
4708
|
-
(liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) +
|
|
4709
|
-
`${i}${t}});${n}` +
|
|
4710
|
-
`${i}}${n}` +
|
|
4711
|
-
`${i}n['default']${_}=${_}e;${n}` +
|
|
4712
|
-
`${i}return ${getFrozen('n', freeze)};${n}`);
|
|
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
|
+
};
|
|
4713
4537
|
}
|
|
4714
|
-
function
|
|
4715
|
-
return
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
`${i}${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4720
|
-
`${i}${t}${t}${t}return e[k];${n}` +
|
|
4721
|
-
`${i}${t}${t}}${n}` +
|
|
4722
|
-
`${i}${t}});${n}` +
|
|
4723
|
-
`${i}}${n}`);
|
|
4538
|
+
function errChunkNotGeneratedForFileName(name) {
|
|
4539
|
+
return {
|
|
4540
|
+
code: Errors.CHUNK_NOT_GENERATED,
|
|
4541
|
+
message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
|
|
4542
|
+
};
|
|
4724
4543
|
}
|
|
4725
|
-
function
|
|
4726
|
-
return
|
|
4544
|
+
function errCircularReexport(exportName, importedModule) {
|
|
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
|
+
};
|
|
4727
4550
|
}
|
|
4728
|
-
function
|
|
4729
|
-
return
|
|
4551
|
+
function errCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
4552
|
+
return {
|
|
4553
|
+
code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
4554
|
+
exporter,
|
|
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
|
+
};
|
|
4730
4559
|
}
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
if (!namedExportsMode) {
|
|
4737
|
-
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings)};`;
|
|
4738
|
-
}
|
|
4739
|
-
let exportBlock = '';
|
|
4740
|
-
// star exports must always output first for precedence
|
|
4741
|
-
for (const { name, reexports } of dependencies) {
|
|
4742
|
-
if (reexports && namedExportsMode) {
|
|
4743
|
-
for (const specifier of reexports) {
|
|
4744
|
-
if (specifier.reexported === '*') {
|
|
4745
|
-
if (exportBlock)
|
|
4746
|
-
exportBlock += n;
|
|
4747
|
-
if (specifier.needsLiveBinding) {
|
|
4748
|
-
exportBlock +=
|
|
4749
|
-
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4750
|
-
`${t}if${_}(k${_}!==${_}'default')${_}Object.defineProperty(exports,${_}k,${_}{${n}` +
|
|
4751
|
-
`${t}${t}enumerable:${_}true,${n}` +
|
|
4752
|
-
`${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
4753
|
-
`${t}${t}${t}return ${name}[k];${n}` +
|
|
4754
|
-
`${t}${t}}${n}${t}});${n}});`;
|
|
4755
|
-
}
|
|
4756
|
-
else {
|
|
4757
|
-
exportBlock +=
|
|
4758
|
-
`Object.keys(${name}).forEach(function${_}(k)${_}{${n}` +
|
|
4759
|
-
`${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
|
|
4760
|
-
}
|
|
4761
|
-
}
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4766
|
-
if (reexports && namedExportsMode) {
|
|
4767
|
-
for (const specifier of reexports) {
|
|
4768
|
-
if (specifier.reexported !== '*') {
|
|
4769
|
-
const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4770
|
-
if (exportBlock)
|
|
4771
|
-
exportBlock += n;
|
|
4772
|
-
exportBlock +=
|
|
4773
|
-
specifier.imported !== '*' && specifier.needsLiveBinding
|
|
4774
|
-
? `Object.defineProperty(exports,${_}'${specifier.reexported}',${_}{${n}` +
|
|
4775
|
-
`${t}enumerable:${_}true,${n}` +
|
|
4776
|
-
`${t}get:${_}function${_}()${_}{${n}` +
|
|
4777
|
-
`${t}${t}return ${importName};${n}${t}}${n}});`
|
|
4778
|
-
: `exports.${specifier.reexported}${_}=${_}${importName};`;
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
}
|
|
4782
|
-
}
|
|
4783
|
-
for (const chunkExport of exports) {
|
|
4784
|
-
const lhs = `exports.${chunkExport.exported}`;
|
|
4785
|
-
const rhs = chunkExport.local;
|
|
4786
|
-
if (lhs !== rhs) {
|
|
4787
|
-
if (exportBlock)
|
|
4788
|
-
exportBlock += n;
|
|
4789
|
-
exportBlock += `${lhs}${_}=${_}${rhs};`;
|
|
4790
|
-
}
|
|
4791
|
-
}
|
|
4792
|
-
if (exportBlock) {
|
|
4793
|
-
return `${n}${n}${exportBlock}`;
|
|
4794
|
-
}
|
|
4795
|
-
return '';
|
|
4560
|
+
function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
|
|
4561
|
+
return {
|
|
4562
|
+
code: Errors.ASSET_NOT_FOUND,
|
|
4563
|
+
message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
|
|
4564
|
+
};
|
|
4796
4565
|
}
|
|
4797
|
-
function
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
for (const { defaultVariableName, id, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4803
|
-
if (reexports) {
|
|
4804
|
-
return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, id, externalLiveBindings);
|
|
4805
|
-
}
|
|
4806
|
-
}
|
|
4807
|
-
}
|
|
4566
|
+
function errAssetSourceAlreadySet(name) {
|
|
4567
|
+
return {
|
|
4568
|
+
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
4569
|
+
message: `Unable to set the source for asset "${name}", source already set.`
|
|
4570
|
+
};
|
|
4808
4571
|
}
|
|
4809
|
-
function
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
? defaultVariableName
|
|
4815
|
-
: moduleVariableName;
|
|
4816
|
-
return isDefaultAProperty(moduleInterop, externalLiveBindings)
|
|
4817
|
-
? `${variableName}['default']`
|
|
4818
|
-
: variableName;
|
|
4819
|
-
}
|
|
4820
|
-
return depNamedExportsMode ? `${moduleVariableName}['default']` : moduleVariableName;
|
|
4821
|
-
}
|
|
4822
|
-
if (imported === '*') {
|
|
4823
|
-
return (isChunk
|
|
4824
|
-
? !depNamedExportsMode
|
|
4825
|
-
: namespaceInteropHelpersByInteropType[String(interop(moduleId))])
|
|
4826
|
-
? namespaceVariableName
|
|
4827
|
-
: moduleVariableName;
|
|
4828
|
-
}
|
|
4829
|
-
return `${moduleVariableName}.${imported}`;
|
|
4572
|
+
function errNoAssetSourceSet(assetName) {
|
|
4573
|
+
return {
|
|
4574
|
+
code: Errors.ASSET_SOURCE_MISSING,
|
|
4575
|
+
message: `Plugin error creating asset "${assetName}" - no asset source set.`
|
|
4576
|
+
};
|
|
4830
4577
|
}
|
|
4831
|
-
function
|
|
4832
|
-
return
|
|
4578
|
+
function errBadLoader(id) {
|
|
4579
|
+
return {
|
|
4580
|
+
code: Errors.BAD_LOADER,
|
|
4581
|
+
message: `Error loading ${relativeId(id)}: plugin load hook should return a string, a { code, map } object, or nothing/null`
|
|
4582
|
+
};
|
|
4833
4583
|
}
|
|
4834
|
-
function
|
|
4835
|
-
return
|
|
4584
|
+
function errDeprecation(deprecation) {
|
|
4585
|
+
return {
|
|
4586
|
+
code: Errors.DEPRECATED_FEATURE,
|
|
4587
|
+
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
4588
|
+
};
|
|
4836
4589
|
}
|
|
4837
|
-
function
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
}
|
|
4843
|
-
if (addNamespaceToStringTag) {
|
|
4844
|
-
if (namespaceMarkers) {
|
|
4845
|
-
namespaceMarkers += n;
|
|
4846
|
-
}
|
|
4847
|
-
namespaceMarkers += getNamespaceToStringExport(_);
|
|
4848
|
-
}
|
|
4849
|
-
}
|
|
4850
|
-
return namespaceMarkers;
|
|
4590
|
+
function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
|
|
4591
|
+
return {
|
|
4592
|
+
code: Errors.FILE_NOT_FOUND,
|
|
4593
|
+
message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
|
|
4594
|
+
};
|
|
4851
4595
|
}
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
4857
|
-
neededInteropHelpers.add(helper);
|
|
4858
|
-
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
4596
|
+
function errFileNameConflict(fileName) {
|
|
4597
|
+
return {
|
|
4598
|
+
code: Errors.FILE_NAME_CONFLICT,
|
|
4599
|
+
message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
|
|
4859
4600
|
};
|
|
4860
|
-
for (const { defaultVariableName, imports, id, isChunk, name, namedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
4861
|
-
if (isChunk) {
|
|
4862
|
-
for (const { imported, reexported } of [
|
|
4863
|
-
...(imports || []),
|
|
4864
|
-
...(reexports || [])
|
|
4865
|
-
]) {
|
|
4866
|
-
if (imported === '*' && reexported !== '*') {
|
|
4867
|
-
if (!namedExportsMode) {
|
|
4868
|
-
addInteropStatement(namespaceVariableName, getDefaultOnlyHelper(), name);
|
|
4869
|
-
}
|
|
4870
|
-
break;
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
}
|
|
4874
|
-
else {
|
|
4875
|
-
const moduleInterop = String(interop(id));
|
|
4876
|
-
let hasDefault = false;
|
|
4877
|
-
let hasNamespace = false;
|
|
4878
|
-
for (const { imported, reexported } of [
|
|
4879
|
-
...(imports || []),
|
|
4880
|
-
...(reexports || [])
|
|
4881
|
-
]) {
|
|
4882
|
-
let helper;
|
|
4883
|
-
let variableName;
|
|
4884
|
-
if (imported === 'default') {
|
|
4885
|
-
if (!hasDefault) {
|
|
4886
|
-
hasDefault = true;
|
|
4887
|
-
if (defaultVariableName !== namespaceVariableName) {
|
|
4888
|
-
variableName = defaultVariableName;
|
|
4889
|
-
helper = defaultInteropHelpersByInteropType[moduleInterop];
|
|
4890
|
-
}
|
|
4891
|
-
}
|
|
4892
|
-
}
|
|
4893
|
-
else if (imported === '*' && reexported !== '*') {
|
|
4894
|
-
if (!hasNamespace) {
|
|
4895
|
-
hasNamespace = true;
|
|
4896
|
-
helper = namespaceInteropHelpersByInteropType[moduleInterop];
|
|
4897
|
-
variableName = namespaceVariableName;
|
|
4898
|
-
}
|
|
4899
|
-
}
|
|
4900
|
-
if (helper) {
|
|
4901
|
-
addInteropStatement(variableName, helper, name);
|
|
4902
|
-
}
|
|
4903
|
-
}
|
|
4904
|
-
}
|
|
4905
|
-
}
|
|
4906
|
-
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4907
4601
|
}
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
return id[0] === '.' ? removeJsExtension(id) : id;
|
|
4602
|
+
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
4603
|
+
return {
|
|
4604
|
+
code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
4605
|
+
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.`
|
|
4606
|
+
};
|
|
4914
4607
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
constants: true,
|
|
4921
|
-
domain: true,
|
|
4922
|
-
events: true,
|
|
4923
|
-
http: true,
|
|
4924
|
-
https: true,
|
|
4925
|
-
os: true,
|
|
4926
|
-
path: true,
|
|
4927
|
-
process: true,
|
|
4928
|
-
punycode: true,
|
|
4929
|
-
querystring: true,
|
|
4930
|
-
stream: true,
|
|
4931
|
-
string_decoder: true,
|
|
4932
|
-
timers: true,
|
|
4933
|
-
tty: true,
|
|
4934
|
-
url: true,
|
|
4935
|
-
util: true,
|
|
4936
|
-
vm: true,
|
|
4937
|
-
zlib: true
|
|
4938
|
-
};
|
|
4939
|
-
function warnOnBuiltins(warn, dependencies) {
|
|
4940
|
-
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins$1);
|
|
4941
|
-
if (!externalBuiltins.length)
|
|
4942
|
-
return;
|
|
4943
|
-
const detail = externalBuiltins.length === 1
|
|
4944
|
-
? `module ('${externalBuiltins[0]}')`
|
|
4945
|
-
: `modules (${externalBuiltins
|
|
4946
|
-
.slice(0, -1)
|
|
4947
|
-
.map(name => `'${name}'`)
|
|
4948
|
-
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
4949
|
-
warn({
|
|
4950
|
-
code: 'MISSING_NODE_BUILTINS',
|
|
4951
|
-
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`,
|
|
4952
|
-
modules: externalBuiltins
|
|
4953
|
-
});
|
|
4608
|
+
function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
|
|
4609
|
+
return {
|
|
4610
|
+
code: Errors.INVALID_CHUNK,
|
|
4611
|
+
message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
4612
|
+
};
|
|
4954
4613
|
}
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
}
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4614
|
+
function errInvalidExportOptionValue(optionValue) {
|
|
4615
|
+
return {
|
|
4616
|
+
code: Errors.INVALID_EXPORT_OPTION,
|
|
4617
|
+
message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`,
|
|
4618
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
4619
|
+
};
|
|
4620
|
+
}
|
|
4621
|
+
function errIncompatibleExportOptionValue(optionValue, keys, entryModule) {
|
|
4622
|
+
return {
|
|
4623
|
+
code: 'INVALID_EXPORT_OPTION',
|
|
4624
|
+
message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${keys.join(', ')}`
|
|
4625
|
+
};
|
|
4626
|
+
}
|
|
4627
|
+
function errInternalIdCannotBeExternal(source, importer) {
|
|
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
|
+
};
|
|
4632
|
+
}
|
|
4633
|
+
function errInvalidOption(option, explanation) {
|
|
4634
|
+
return {
|
|
4635
|
+
code: Errors.INVALID_OPTION,
|
|
4636
|
+
message: `Invalid value for option "${option}" - ${explanation}.`
|
|
4637
|
+
};
|
|
4638
|
+
}
|
|
4639
|
+
function errInvalidRollupPhaseForAddWatchFile() {
|
|
4640
|
+
return {
|
|
4641
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
4642
|
+
message: `Cannot call addWatchFile after the build has finished.`
|
|
4643
|
+
};
|
|
4644
|
+
}
|
|
4645
|
+
function errInvalidRollupPhaseForChunkEmission() {
|
|
4646
|
+
return {
|
|
4647
|
+
code: Errors.INVALID_ROLLUP_PHASE,
|
|
4648
|
+
message: `Cannot emit chunks after module loading has finished.`
|
|
4649
|
+
};
|
|
4650
|
+
}
|
|
4651
|
+
function errMissingExport(exportName, importingModule, importedModule) {
|
|
4652
|
+
return {
|
|
4653
|
+
code: Errors.MISSING_EXPORT,
|
|
4654
|
+
message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule)}`,
|
|
4655
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
4656
|
+
};
|
|
4657
|
+
}
|
|
4658
|
+
function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
|
|
4659
|
+
return {
|
|
4660
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4661
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
|
|
4662
|
+
};
|
|
4663
|
+
}
|
|
4664
|
+
function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
|
|
4665
|
+
return {
|
|
4666
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4667
|
+
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
function errImplicitDependantIsNotIncluded(module) {
|
|
4671
|
+
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
4672
|
+
return {
|
|
4673
|
+
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
4674
|
+
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${implicitDependencies.length === 1
|
|
4675
|
+
? implicitDependencies[0]
|
|
4676
|
+
: `${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.`
|
|
4677
|
+
};
|
|
4678
|
+
}
|
|
4679
|
+
function errMixedExport(facadeModuleId, name) {
|
|
4680
|
+
return {
|
|
4681
|
+
code: Errors.MIXED_EXPORTS,
|
|
4682
|
+
id: facadeModuleId,
|
|
4683
|
+
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`,
|
|
4684
|
+
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
4685
|
+
};
|
|
4686
|
+
}
|
|
4687
|
+
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
4688
|
+
return {
|
|
4689
|
+
code: Errors.NAMESPACE_CONFLICT,
|
|
4690
|
+
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports '${name}' from both ${relativeId(reexportingModule.exportsAll[name])} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`,
|
|
4691
|
+
name,
|
|
4692
|
+
reexporter: reexportingModule.id,
|
|
4693
|
+
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
4694
|
+
};
|
|
4695
|
+
}
|
|
4696
|
+
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
4697
|
+
return {
|
|
4698
|
+
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
4699
|
+
message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
|
|
4700
|
+
'a "code". This will be ignored.'
|
|
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);
|
|
4793
|
+
}
|
|
4794
|
+
warn(warning);
|
|
4984
4795
|
}
|
|
4985
|
-
magicString.append(`${exportBlock}${namespaceMarkers}${outro}`);
|
|
4986
|
-
return magicString
|
|
4987
|
-
.indent(t)
|
|
4988
|
-
.prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`)
|
|
4989
|
-
.append(`${n}${n}});`);
|
|
4990
4796
|
}
|
|
4991
4797
|
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
namespaceMarkers += n + n;
|
|
4798
|
+
class SyntheticNamedExportVariable extends Variable {
|
|
4799
|
+
constructor(context, name, syntheticNamespace) {
|
|
4800
|
+
super(name);
|
|
4801
|
+
this.baseVariable = null;
|
|
4802
|
+
this.context = context;
|
|
4803
|
+
this.module = context.module;
|
|
4804
|
+
this.syntheticNamespace = syntheticNamespace;
|
|
5000
4805
|
}
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
4806
|
+
getBaseVariable() {
|
|
4807
|
+
if (this.baseVariable)
|
|
4808
|
+
return this.baseVariable;
|
|
4809
|
+
let baseVariable = this.syntheticNamespace;
|
|
4810
|
+
const checkedVariables = new Set();
|
|
4811
|
+
while (baseVariable instanceof ExportDefaultVariable ||
|
|
4812
|
+
baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4813
|
+
checkedVariables.add(baseVariable);
|
|
4814
|
+
if (baseVariable instanceof ExportDefaultVariable) {
|
|
4815
|
+
const original = baseVariable.getOriginalVariable();
|
|
4816
|
+
if (original === baseVariable)
|
|
4817
|
+
break;
|
|
4818
|
+
baseVariable = original;
|
|
4819
|
+
}
|
|
4820
|
+
if (baseVariable instanceof SyntheticNamedExportVariable) {
|
|
4821
|
+
baseVariable = baseVariable.syntheticNamespace;
|
|
4822
|
+
}
|
|
4823
|
+
if (checkedVariables.has(baseVariable)) {
|
|
4824
|
+
return error(errSyntheticNamedExportsNeedNamespaceExport(this.module.id, this.module.info.syntheticNamedExports));
|
|
5014
4825
|
}
|
|
5015
|
-
definingVariable = false;
|
|
5016
|
-
importBlock += `require('${id}')`;
|
|
5017
4826
|
}
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
4827
|
+
return (this.baseVariable = baseVariable);
|
|
4828
|
+
}
|
|
4829
|
+
getBaseVariableName() {
|
|
4830
|
+
return this.syntheticNamespace.getBaseVariableName();
|
|
4831
|
+
}
|
|
4832
|
+
getName() {
|
|
4833
|
+
const name = this.name;
|
|
4834
|
+
return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`;
|
|
4835
|
+
}
|
|
4836
|
+
include() {
|
|
4837
|
+
if (!this.included) {
|
|
4838
|
+
this.included = true;
|
|
4839
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
5023
4840
|
}
|
|
5024
4841
|
}
|
|
5025
|
-
|
|
5026
|
-
|
|
4842
|
+
setRenderNames(baseName, name) {
|
|
4843
|
+
super.setRenderNames(baseName, name);
|
|
5027
4844
|
}
|
|
5028
|
-
return '';
|
|
5029
4845
|
}
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
const importBlock = [];
|
|
5048
|
-
for (const { id, reexports, imports, name } of dependencies) {
|
|
5049
|
-
if (!reexports && !imports) {
|
|
5050
|
-
importBlock.push(`import${_}'${id}';`);
|
|
5051
|
-
continue;
|
|
4846
|
+
const getPropertyAccess = (name) => {
|
|
4847
|
+
return !RESERVED_NAMES[name] && /^(?!\d)[\w$]+$/.test(name)
|
|
4848
|
+
? `.${name}`
|
|
4849
|
+
: `[${JSON.stringify(name)}]`;
|
|
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);
|
|
5052
4863
|
}
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
if (specifier.imported === 'default') {
|
|
5059
|
-
defaultImport = specifier;
|
|
5060
|
-
}
|
|
5061
|
-
else if (specifier.imported === '*') {
|
|
5062
|
-
starImport = specifier;
|
|
5063
|
-
}
|
|
5064
|
-
else {
|
|
5065
|
-
importedNames.push(specifier);
|
|
5066
|
-
}
|
|
5067
|
-
}
|
|
5068
|
-
if (starImport) {
|
|
5069
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
|
|
5070
|
-
}
|
|
5071
|
-
if (defaultImport && importedNames.length === 0) {
|
|
5072
|
-
importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
|
|
5073
|
-
}
|
|
5074
|
-
else if (importedNames.length > 0) {
|
|
5075
|
-
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
5076
|
-
.map(specifier => {
|
|
5077
|
-
if (specifier.imported === specifier.local) {
|
|
5078
|
-
return specifier.imported;
|
|
5079
|
-
}
|
|
5080
|
-
else {
|
|
5081
|
-
return `${specifier.imported} as ${specifier.local}`;
|
|
5082
|
-
}
|
|
5083
|
-
})
|
|
5084
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
5085
|
-
}
|
|
4864
|
+
}
|
|
4865
|
+
include() {
|
|
4866
|
+
if (!this.included) {
|
|
4867
|
+
this.included = true;
|
|
4868
|
+
this.module.used = true;
|
|
5086
4869
|
}
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
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(' ');
|
|
4874
|
+
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(' ');
|
|
4875
|
+
const blacklisted = new Set(reservedWords.concat(builtins));
|
|
4876
|
+
const illegalCharacters = /[^$_a-zA-Z0-9]/g;
|
|
4877
|
+
const startsWithDigit = (str) => /\d/.test(str[0]);
|
|
4878
|
+
function isLegal(str) {
|
|
4879
|
+
if (startsWithDigit(str) || blacklisted.has(str)) {
|
|
4880
|
+
return false;
|
|
4881
|
+
}
|
|
4882
|
+
return !illegalCharacters.test(str);
|
|
4883
|
+
}
|
|
4884
|
+
function makeLegal(str) {
|
|
4885
|
+
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
|
|
4886
|
+
if (startsWithDigit(str) || blacklisted.has(str))
|
|
4887
|
+
str = `_${str}`;
|
|
4888
|
+
return str || '_';
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4891
|
+
class ExternalModule {
|
|
4892
|
+
constructor(options, id, hasModuleSideEffects, meta) {
|
|
4893
|
+
this.options = options;
|
|
4894
|
+
this.id = id;
|
|
4895
|
+
this.defaultVariableName = '';
|
|
4896
|
+
this.dynamicImporters = [];
|
|
4897
|
+
this.importers = [];
|
|
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;
|
|
5113
4946
|
}
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
if (specifier.imported === specifier.reexported) {
|
|
5118
|
-
return specifier.imported;
|
|
5119
|
-
}
|
|
5120
|
-
else {
|
|
5121
|
-
return `${specifier.imported} as ${specifier.reexported}`;
|
|
5122
|
-
}
|
|
5123
|
-
})
|
|
5124
|
-
.join(`,${_}`)}${_}}${_}from${_}'${id}';`);
|
|
4947
|
+
else {
|
|
4948
|
+
this.renderPath = normalize(relative$1(inputBase, this.id));
|
|
4949
|
+
this.renormalizeRenderPath = true;
|
|
5125
4950
|
}
|
|
5126
4951
|
}
|
|
4952
|
+
return this.renderPath;
|
|
5127
4953
|
}
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
exportBlock.push(`export default ${specifier.local};`);
|
|
5136
|
-
}
|
|
5137
|
-
else {
|
|
5138
|
-
if (specifier.expression) {
|
|
5139
|
-
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
5140
|
-
}
|
|
5141
|
-
exportDeclaration.push(specifier.exported === specifier.local
|
|
5142
|
-
? specifier.local
|
|
5143
|
-
: `${specifier.local} as ${specifier.exported}`);
|
|
4954
|
+
suggestName(name) {
|
|
4955
|
+
if (!this.nameSuggestions[name])
|
|
4956
|
+
this.nameSuggestions[name] = 0;
|
|
4957
|
+
this.nameSuggestions[name] += 1;
|
|
4958
|
+
if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
|
|
4959
|
+
this.mostCommonSuggestion = this.nameSuggestions[name];
|
|
4960
|
+
this.suggestedVariableName = name;
|
|
5144
4961
|
}
|
|
5145
4962
|
}
|
|
5146
|
-
|
|
5147
|
-
|
|
4963
|
+
warnUnusedImports() {
|
|
4964
|
+
const unused = Object.keys(this.declarations).filter(name => {
|
|
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
|
+
});
|
|
5148
4984
|
}
|
|
5149
|
-
return exportBlock;
|
|
5150
4985
|
}
|
|
5151
4986
|
|
|
5152
|
-
function
|
|
5153
|
-
|
|
5154
|
-
while (i--)
|
|
5155
|
-
result += ' ';
|
|
5156
|
-
return result;
|
|
4987
|
+
function removeJsExtension(name) {
|
|
4988
|
+
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
5157
4989
|
}
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
5167
|
-
lines.pop();
|
|
5168
|
-
frameEnd -= 1;
|
|
5169
|
-
}
|
|
5170
|
-
const digits = String(frameEnd).length;
|
|
5171
|
-
return lines
|
|
5172
|
-
.map((str, i) => {
|
|
5173
|
-
const isErrorLine = frameStart + i + 1 === line;
|
|
5174
|
-
let lineNum = String(i + frameStart + 1);
|
|
5175
|
-
while (lineNum.length < digits)
|
|
5176
|
-
lineNum = ` ${lineNum}`;
|
|
5177
|
-
if (isErrorLine) {
|
|
5178
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(str.slice(0, column)).length) + '^';
|
|
5179
|
-
return `${lineNum}: ${tabsToSpaces(str)}\n${indicator}`;
|
|
5180
|
-
}
|
|
5181
|
-
return `${lineNum}: ${tabsToSpaces(str)}`;
|
|
5182
|
-
})
|
|
5183
|
-
.join('\n');
|
|
4990
|
+
|
|
4991
|
+
function getCompleteAmdId(options, chunkId) {
|
|
4992
|
+
if (!options.autoId) {
|
|
4993
|
+
return options.id || '';
|
|
4994
|
+
}
|
|
4995
|
+
else {
|
|
4996
|
+
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
4997
|
+
}
|
|
5184
4998
|
}
|
|
5185
4999
|
|
|
5186
|
-
|
|
5187
|
-
|
|
5000
|
+
const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
|
|
5001
|
+
const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
|
|
5002
|
+
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
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')));
|
|
5188
5016
|
}
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5017
|
+
const namespaceInteropHelpersByInteropType = {
|
|
5018
|
+
auto: INTEROP_NAMESPACE_VARIABLE,
|
|
5019
|
+
default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
|
|
5020
|
+
defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
|
|
5021
|
+
esModule: null,
|
|
5022
|
+
false: null,
|
|
5023
|
+
true: INTEROP_NAMESPACE_VARIABLE
|
|
5024
|
+
};
|
|
5025
|
+
function canDefaultBeTakenFromNamespace(interopType, externalLiveBindings) {
|
|
5026
|
+
return (isDefaultAProperty(interopType, externalLiveBindings) &&
|
|
5027
|
+
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE);
|
|
5193
5028
|
}
|
|
5194
|
-
function
|
|
5195
|
-
|
|
5196
|
-
return id;
|
|
5197
|
-
return relative$1(process.cwd(), id);
|
|
5029
|
+
function getDefaultOnlyHelper() {
|
|
5030
|
+
return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE;
|
|
5198
5031
|
}
|
|
5199
|
-
function
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5032
|
+
function getHelpersBlock(usedHelpers, accessedGlobals, _, n, s, t, liveBindings, freeze, namespaceToStringTag) {
|
|
5033
|
+
return HELPER_NAMES.map(variable => usedHelpers.has(variable) || accessedGlobals.has(variable)
|
|
5034
|
+
? HELPER_GENERATORS[variable](_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers)
|
|
5035
|
+
: '').join('');
|
|
5036
|
+
}
|
|
5037
|
+
const HELPER_GENERATORS = {
|
|
5038
|
+
[INTEROP_DEFAULT_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
5039
|
+
`e${_}&&${_}e.__esModule${_}?${_}` +
|
|
5040
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
5041
|
+
[INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` +
|
|
5042
|
+
`e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
|
|
5043
|
+
`${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`,
|
|
5044
|
+
[INTEROP_NAMESPACE_VARIABLE]: (_, n, s, t, liveBindings, freeze, namespaceToStringTag, usedHelpers) => `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` +
|
|
5045
|
+
(usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)
|
|
5046
|
+
? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}`
|
|
5047
|
+
: `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` +
|
|
5048
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) +
|
|
5049
|
+
`}${n}${n}`,
|
|
5050
|
+
[INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` +
|
|
5051
|
+
createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) +
|
|
5052
|
+
`}${n}${n}`,
|
|
5053
|
+
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: (_, n, _s, t, _liveBindings, freeze, namespaceToStringTag) => `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` +
|
|
5054
|
+
`${t}return ${getFrozen(`{__proto__: null,${namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : ''}${_}'default':${_}e}`, freeze)};${n}` +
|
|
5055
|
+
`}${n}${n}`
|
|
5056
|
+
};
|
|
5057
|
+
function getDefaultLiveBinding(_) {
|
|
5058
|
+
return `e${_}:${_}{${_}'default':${_}e${_}}`;
|
|
5059
|
+
}
|
|
5060
|
+
function getDefaultStatic(_) {
|
|
5061
|
+
return `e['default']${_}:${_}e`;
|
|
5062
|
+
}
|
|
5063
|
+
function createNamespaceObject(_, n, t, i, liveBindings, freeze, namespaceToStringTag) {
|
|
5064
|
+
return (`${i}var n${_}=${_}${namespaceToStringTag
|
|
5065
|
+
? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
|
|
5066
|
+
: 'Object.create(null)'};${n}` +
|
|
5067
|
+
`${i}if${_}(e)${_}{${n}` +
|
|
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}`);
|
|
5074
|
+
}
|
|
5075
|
+
function copyPropertyLiveBinding(_, n, t, i) {
|
|
5076
|
+
return (`${i}if${_}(k${_}!==${_}'default')${_}{${n}` +
|
|
5077
|
+
`${i}${t}var d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` +
|
|
5078
|
+
`${i}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
|
|
5079
|
+
`${i}${t}${t}enumerable:${_}true,${n}` +
|
|
5080
|
+
`${i}${t}${t}get:${_}function${_}()${_}{${n}` +
|
|
5081
|
+
`${i}${t}${t}${t}return e[k];${n}` +
|
|
5082
|
+
`${i}${t}${t}}${n}` +
|
|
5083
|
+
`${i}${t}});${n}` +
|
|
5084
|
+
`${i}}${n}`);
|
|
5205
5085
|
}
|
|
5086
|
+
function copyPropertyStatic(_, n, _t, i) {
|
|
5087
|
+
return `${i}n[k]${_}=${_}e[k];${n}`;
|
|
5088
|
+
}
|
|
5089
|
+
function getFrozen(fragment, freeze) {
|
|
5090
|
+
return freeze ? `Object.freeze(${fragment})` : fragment;
|
|
5091
|
+
}
|
|
5092
|
+
const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
|
|
5206
5093
|
|
|
5207
|
-
function
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5094
|
+
function getExportBlock(exports, dependencies, namedExportsMode, interop, compact, t, externalLiveBindings, mechanism = 'return ') {
|
|
5095
|
+
const _ = compact ? '' : ' ';
|
|
5096
|
+
const n = compact ? '' : '\n';
|
|
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 '';
|
|
5211
5157
|
}
|
|
5212
|
-
function
|
|
5213
|
-
if (
|
|
5214
|
-
|
|
5215
|
-
props.loc = { file: id, line, column };
|
|
5158
|
+
function getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings) {
|
|
5159
|
+
if (exports.length > 0) {
|
|
5160
|
+
return exports[0].local;
|
|
5216
5161
|
}
|
|
5217
5162
|
else {
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
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
|
+
}
|
|
5221
5168
|
}
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5169
|
+
}
|
|
5170
|
+
function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings) {
|
|
5171
|
+
if (imported === 'default') {
|
|
5172
|
+
if (!isChunk) {
|
|
5173
|
+
const moduleInterop = String(interop(moduleId));
|
|
5174
|
+
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
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;
|
|
5225
5189
|
}
|
|
5190
|
+
return `${moduleVariableName}.${imported}`;
|
|
5226
5191
|
}
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
|
|
5230
|
-
Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
|
|
5231
|
-
Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
|
|
5232
|
-
Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
|
|
5233
|
-
Errors["ASSET_SOURCE_MISSING"] = "ASSET_SOURCE_MISSING";
|
|
5234
|
-
Errors["BAD_LOADER"] = "BAD_LOADER";
|
|
5235
|
-
Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
|
|
5236
|
-
Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
|
|
5237
|
-
Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
|
|
5238
|
-
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
5239
|
-
Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
|
|
5240
|
-
Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
5241
|
-
Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
5242
|
-
Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
|
|
5243
|
-
Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
|
|
5244
|
-
Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
|
|
5245
|
-
Errors["INVALID_OPTION"] = "INVALID_OPTION";
|
|
5246
|
-
Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
|
|
5247
|
-
Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
|
|
5248
|
-
Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
|
|
5249
|
-
Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
|
|
5250
|
-
Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
|
|
5251
|
-
Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
|
|
5252
|
-
Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
5253
|
-
Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
|
|
5254
|
-
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
|
|
5255
|
-
Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
|
|
5256
|
-
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
5257
|
-
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
5258
|
-
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
5259
|
-
})(Errors || (Errors = {}));
|
|
5260
|
-
function errAssetNotFinalisedForFileName(name) {
|
|
5261
|
-
return {
|
|
5262
|
-
code: Errors.ASSET_NOT_FINALISED,
|
|
5263
|
-
message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
|
|
5264
|
-
};
|
|
5265
|
-
}
|
|
5266
|
-
function errCannotEmitFromOptionsHook() {
|
|
5267
|
-
return {
|
|
5268
|
-
code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
|
|
5269
|
-
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
5270
|
-
};
|
|
5271
|
-
}
|
|
5272
|
-
function errChunkNotGeneratedForFileName(name) {
|
|
5273
|
-
return {
|
|
5274
|
-
code: Errors.CHUNK_NOT_GENERATED,
|
|
5275
|
-
message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
|
|
5276
|
-
};
|
|
5277
|
-
}
|
|
5278
|
-
function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
|
|
5279
|
-
return {
|
|
5280
|
-
code: Errors.ASSET_NOT_FOUND,
|
|
5281
|
-
message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
|
|
5282
|
-
};
|
|
5283
|
-
}
|
|
5284
|
-
function errAssetSourceAlreadySet(name) {
|
|
5285
|
-
return {
|
|
5286
|
-
code: Errors.ASSET_SOURCE_ALREADY_SET,
|
|
5287
|
-
message: `Unable to set the source for asset "${name}", source already set.`
|
|
5288
|
-
};
|
|
5289
|
-
}
|
|
5290
|
-
function errNoAssetSourceSet(assetName) {
|
|
5291
|
-
return {
|
|
5292
|
-
code: Errors.ASSET_SOURCE_MISSING,
|
|
5293
|
-
message: `Plugin error creating asset "${assetName}" - no asset source set.`
|
|
5294
|
-
};
|
|
5295
|
-
}
|
|
5296
|
-
function errBadLoader(id) {
|
|
5297
|
-
return {
|
|
5298
|
-
code: Errors.BAD_LOADER,
|
|
5299
|
-
message: `Error loading ${relativeId(id)}: plugin load hook should return a string, a { code, map } object, or nothing/null`
|
|
5300
|
-
};
|
|
5301
|
-
}
|
|
5302
|
-
function errDeprecation(deprecation) {
|
|
5303
|
-
return {
|
|
5304
|
-
code: Errors.DEPRECATED_FEATURE,
|
|
5305
|
-
...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
|
|
5306
|
-
};
|
|
5307
|
-
}
|
|
5308
|
-
function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
|
|
5309
|
-
return {
|
|
5310
|
-
code: Errors.FILE_NOT_FOUND,
|
|
5311
|
-
message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
|
|
5312
|
-
};
|
|
5313
|
-
}
|
|
5314
|
-
function errFileNameConflict(fileName) {
|
|
5315
|
-
return {
|
|
5316
|
-
code: Errors.FILE_NAME_CONFLICT,
|
|
5317
|
-
message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
|
|
5318
|
-
};
|
|
5319
|
-
}
|
|
5320
|
-
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
5321
|
-
return {
|
|
5322
|
-
code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
5323
|
-
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.`
|
|
5324
|
-
};
|
|
5325
|
-
}
|
|
5326
|
-
function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
|
|
5327
|
-
return {
|
|
5328
|
-
code: Errors.INVALID_CHUNK,
|
|
5329
|
-
message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
5330
|
-
};
|
|
5331
|
-
}
|
|
5332
|
-
function errInvalidExportOptionValue(optionValue) {
|
|
5333
|
-
return {
|
|
5334
|
-
code: Errors.INVALID_EXPORT_OPTION,
|
|
5335
|
-
message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`,
|
|
5336
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5337
|
-
};
|
|
5338
|
-
}
|
|
5339
|
-
function errIncompatibleExportOptionValue(optionValue, keys, entryModule) {
|
|
5340
|
-
return {
|
|
5341
|
-
code: 'INVALID_EXPORT_OPTION',
|
|
5342
|
-
message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${keys.join(', ')}`
|
|
5343
|
-
};
|
|
5344
|
-
}
|
|
5345
|
-
function errInternalIdCannotBeExternal(source, importer) {
|
|
5346
|
-
return {
|
|
5347
|
-
code: Errors.INVALID_EXTERNAL_ID,
|
|
5348
|
-
message: `'${source}' is imported as an external by ${relativeId(importer)}, but is already an existing non-external module id.`
|
|
5349
|
-
};
|
|
5350
|
-
}
|
|
5351
|
-
function errInvalidOption(option, explanation) {
|
|
5352
|
-
return {
|
|
5353
|
-
code: Errors.INVALID_OPTION,
|
|
5354
|
-
message: `Invalid value for option "${option}" - ${explanation}.`
|
|
5355
|
-
};
|
|
5356
|
-
}
|
|
5357
|
-
function errInvalidRollupPhaseForAddWatchFile() {
|
|
5358
|
-
return {
|
|
5359
|
-
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5360
|
-
message: `Cannot call addWatchFile after the build has finished.`
|
|
5361
|
-
};
|
|
5362
|
-
}
|
|
5363
|
-
function errInvalidRollupPhaseForChunkEmission() {
|
|
5364
|
-
return {
|
|
5365
|
-
code: Errors.INVALID_ROLLUP_PHASE,
|
|
5366
|
-
message: `Cannot emit chunks after module loading has finished.`
|
|
5367
|
-
};
|
|
5368
|
-
}
|
|
5369
|
-
function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
|
|
5370
|
-
return {
|
|
5371
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5372
|
-
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
|
|
5373
|
-
};
|
|
5374
|
-
}
|
|
5375
|
-
function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
|
|
5376
|
-
return {
|
|
5377
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5378
|
-
message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
|
|
5379
|
-
};
|
|
5380
|
-
}
|
|
5381
|
-
function errImplicitDependantIsNotIncluded(module) {
|
|
5382
|
-
const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
|
|
5383
|
-
return {
|
|
5384
|
-
code: Errors.MISSING_IMPLICIT_DEPENDANT,
|
|
5385
|
-
message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${implicitDependencies.length === 1
|
|
5386
|
-
? implicitDependencies[0]
|
|
5387
|
-
: `${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.`
|
|
5388
|
-
};
|
|
5389
|
-
}
|
|
5390
|
-
function errMixedExport(facadeModuleId, name) {
|
|
5391
|
-
return {
|
|
5392
|
-
code: Errors.MIXED_EXPORTS,
|
|
5393
|
-
id: facadeModuleId,
|
|
5394
|
-
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`,
|
|
5395
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5396
|
-
};
|
|
5397
|
-
}
|
|
5398
|
-
function errNamespaceConflict(name, reexportingModule, additionalExportAllModule) {
|
|
5399
|
-
return {
|
|
5400
|
-
code: Errors.NAMESPACE_CONFLICT,
|
|
5401
|
-
message: `Conflicting namespaces: ${relativeId(reexportingModule.id)} re-exports '${name}' from both ${relativeId(reexportingModule.exportsAll[name])} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`,
|
|
5402
|
-
name,
|
|
5403
|
-
reexporter: reexportingModule.id,
|
|
5404
|
-
sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]]
|
|
5405
|
-
};
|
|
5406
|
-
}
|
|
5407
|
-
function errNoTransformMapOrAstWithoutCode(pluginName) {
|
|
5408
|
-
return {
|
|
5409
|
-
code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
|
|
5410
|
-
message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
|
|
5411
|
-
'a "code". This will be ignored.'
|
|
5412
|
-
};
|
|
5413
|
-
}
|
|
5414
|
-
function errPreferNamedExports(facadeModuleId) {
|
|
5415
|
-
const file = relativeId(facadeModuleId);
|
|
5416
|
-
return {
|
|
5417
|
-
code: Errors.PREFER_NAMED_EXPORTS,
|
|
5418
|
-
id: facadeModuleId,
|
|
5419
|
-
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.`,
|
|
5420
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
5421
|
-
};
|
|
5422
|
-
}
|
|
5423
|
-
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
5424
|
-
const importType = isReexport ? 'reexport' : 'import';
|
|
5425
|
-
return {
|
|
5426
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5427
|
-
id,
|
|
5428
|
-
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.`,
|
|
5429
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5430
|
-
};
|
|
5192
|
+
function getEsModuleExport(_) {
|
|
5193
|
+
return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
|
|
5431
5194
|
}
|
|
5432
|
-
function
|
|
5433
|
-
return {
|
|
5434
|
-
code: Errors.UNEXPECTED_NAMED_IMPORT,
|
|
5435
|
-
id,
|
|
5436
|
-
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.`,
|
|
5437
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
5438
|
-
};
|
|
5195
|
+
function getNamespaceToStringExport(_) {
|
|
5196
|
+
return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
|
|
5439
5197
|
}
|
|
5440
|
-
function
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5198
|
+
function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
|
|
5199
|
+
let namespaceMarkers = '';
|
|
5200
|
+
if (hasNamedExports) {
|
|
5201
|
+
if (addEsModule) {
|
|
5202
|
+
namespaceMarkers += getEsModuleExport(_);
|
|
5203
|
+
}
|
|
5204
|
+
if (addNamespaceToStringTag) {
|
|
5205
|
+
if (namespaceMarkers) {
|
|
5206
|
+
namespaceMarkers += n;
|
|
5207
|
+
}
|
|
5208
|
+
namespaceMarkers += getNamespaceToStringExport(_);
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5211
|
+
return namespaceMarkers;
|
|
5445
5212
|
}
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5213
|
+
|
|
5214
|
+
function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, _, n, s, t) {
|
|
5215
|
+
const neededInteropHelpers = new Set();
|
|
5216
|
+
const interopStatements = [];
|
|
5217
|
+
const addInteropStatement = (helperVariableName, helper, dependencyVariableName) => {
|
|
5218
|
+
neededInteropHelpers.add(helper);
|
|
5219
|
+
interopStatements.push(`${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});`);
|
|
5450
5220
|
};
|
|
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}` : ''}`;
|
|
5451
5268
|
}
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5269
|
+
|
|
5270
|
+
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
5271
|
+
// The assumption is that this makes sense for all relative ids:
|
|
5272
|
+
// https://requirejs.org/docs/api.html#jsfiles
|
|
5273
|
+
function removeExtensionFromRelativeAmdId(id) {
|
|
5274
|
+
return id[0] === '.' ? removeJsExtension(id) : id;
|
|
5457
5275
|
}
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5276
|
+
|
|
5277
|
+
const builtins$1 = {
|
|
5278
|
+
assert: true,
|
|
5279
|
+
buffer: true,
|
|
5280
|
+
console: true,
|
|
5281
|
+
constants: true,
|
|
5282
|
+
domain: true,
|
|
5283
|
+
events: true,
|
|
5284
|
+
http: true,
|
|
5285
|
+
https: true,
|
|
5286
|
+
os: true,
|
|
5287
|
+
path: true,
|
|
5288
|
+
process: true,
|
|
5289
|
+
punycode: true,
|
|
5290
|
+
querystring: true,
|
|
5291
|
+
stream: true,
|
|
5292
|
+
string_decoder: true,
|
|
5293
|
+
timers: true,
|
|
5294
|
+
tty: true,
|
|
5295
|
+
url: true,
|
|
5296
|
+
util: true,
|
|
5297
|
+
vm: true,
|
|
5298
|
+
zlib: true
|
|
5299
|
+
};
|
|
5300
|
+
function warnOnBuiltins(warn, dependencies) {
|
|
5301
|
+
const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins$1);
|
|
5302
|
+
if (!externalBuiltins.length)
|
|
5303
|
+
return;
|
|
5304
|
+
const detail = externalBuiltins.length === 1
|
|
5305
|
+
? `module ('${externalBuiltins[0]}')`
|
|
5306
|
+
: `modules (${externalBuiltins
|
|
5307
|
+
.slice(0, -1)
|
|
5308
|
+
.map(name => `'${name}'`)
|
|
5309
|
+
.join(', ')} and '${externalBuiltins.slice(-1)}')`;
|
|
5310
|
+
warn({
|
|
5311
|
+
code: 'MISSING_NODE_BUILTINS',
|
|
5312
|
+
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`,
|
|
5313
|
+
modules: externalBuiltins
|
|
5314
|
+
});
|
|
5466
5315
|
}
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5316
|
+
|
|
5317
|
+
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 }) {
|
|
5318
|
+
warnOnBuiltins(warn, dependencies);
|
|
5319
|
+
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
5320
|
+
const args = dependencies.map(m => m.name);
|
|
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}});`);
|
|
5474
5351
|
}
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5352
|
+
|
|
5353
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
5354
|
+
const n = compact ? '' : '\n';
|
|
5355
|
+
const s = compact ? '' : ';';
|
|
5356
|
+
const _ = compact ? '' : ' ';
|
|
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}`);
|
|
5480
5367
|
}
|
|
5481
|
-
function
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5368
|
+
function getImportBlock(dependencies, compact, varOrConst, n, _) {
|
|
5369
|
+
let importBlock = '';
|
|
5370
|
+
let definingVariable = false;
|
|
5371
|
+
for (const { id, name, reexports, imports } of dependencies) {
|
|
5372
|
+
if (!reexports && !imports) {
|
|
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 '';
|
|
5486
5390
|
}
|
|
5487
|
-
|
|
5488
|
-
|
|
5391
|
+
|
|
5392
|
+
function es(magicString, { intro, outro, dependencies, exports, varOrConst }, { compact }) {
|
|
5393
|
+
const _ = compact ? '' : ' ';
|
|
5394
|
+
const n = compact ? '' : '\n';
|
|
5395
|
+
const importBlock = getImportBlock$1(dependencies, _);
|
|
5396
|
+
if (importBlock.length > 0)
|
|
5397
|
+
intro += importBlock.join(n) + n + n;
|
|
5398
|
+
if (intro)
|
|
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();
|
|
5489
5406
|
}
|
|
5490
|
-
function
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
if (
|
|
5494
|
-
|
|
5407
|
+
function getImportBlock$1(dependencies, _) {
|
|
5408
|
+
const importBlock = [];
|
|
5409
|
+
for (const { id, reexports, imports, name } of dependencies) {
|
|
5410
|
+
if (!reexports && !imports) {
|
|
5411
|
+
importBlock.push(`import${_}'${id}';`);
|
|
5412
|
+
continue;
|
|
5495
5413
|
}
|
|
5496
|
-
|
|
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;
|
|
5490
|
+
}
|
|
5491
|
+
function getExportBlock$1(exports, _, varOrConst) {
|
|
5492
|
+
const exportBlock = [];
|
|
5493
|
+
const exportDeclaration = [];
|
|
5494
|
+
for (const specifier of exports) {
|
|
5495
|
+
if (specifier.exported === 'default') {
|
|
5496
|
+
exportBlock.push(`export default ${specifier.local};`);
|
|
5497
|
+
}
|
|
5498
|
+
else {
|
|
5499
|
+
if (specifier.expression) {
|
|
5500
|
+
exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
5501
|
+
}
|
|
5502
|
+
exportDeclaration.push(specifier.exported === specifier.local
|
|
5503
|
+
? specifier.local
|
|
5504
|
+
: `${specifier.local} as ${specifier.exported}`);
|
|
5505
|
+
}
|
|
5506
|
+
}
|
|
5507
|
+
if (exportDeclaration.length) {
|
|
5508
|
+
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
5497
5509
|
}
|
|
5510
|
+
return exportBlock;
|
|
5498
5511
|
}
|
|
5499
5512
|
|
|
5500
5513
|
// Generate strings which dereference dotted properties, but use array notation `['prop-deref']`
|
|
@@ -6165,7 +6178,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
6165
6178
|
this.right.render(code, options, {
|
|
6166
6179
|
renderedParentType: renderedParentType || this.parent.type
|
|
6167
6180
|
});
|
|
6168
|
-
code.
|
|
6181
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', this.left.end);
|
|
6182
|
+
code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
6169
6183
|
}
|
|
6170
6184
|
if (options.format === 'system') {
|
|
6171
6185
|
const exportNames = this.left.variable && options.exportNamesByVariable.get(this.left.variable);
|
|
@@ -6409,7 +6423,6 @@ class MemberExpression extends NodeBase {
|
|
|
6409
6423
|
this.replacement = null;
|
|
6410
6424
|
this.wasPathDeoptimizedWhileOptimized = false;
|
|
6411
6425
|
}
|
|
6412
|
-
addExportedVariables() { }
|
|
6413
6426
|
bind() {
|
|
6414
6427
|
if (this.bound)
|
|
6415
6428
|
return;
|
|
@@ -6516,7 +6529,7 @@ class MemberExpression extends NodeBase {
|
|
|
6516
6529
|
if (!this.included) {
|
|
6517
6530
|
this.included = true;
|
|
6518
6531
|
if (this.variable !== null) {
|
|
6519
|
-
this.context.
|
|
6532
|
+
this.context.includeVariableInModule(this.variable);
|
|
6520
6533
|
}
|
|
6521
6534
|
}
|
|
6522
6535
|
this.object.include(context, includeChildrenRecursively);
|
|
@@ -6556,7 +6569,7 @@ class MemberExpression extends NodeBase {
|
|
|
6556
6569
|
const variable = this.scope.findVariable(this.object.name);
|
|
6557
6570
|
if (variable.isNamespace) {
|
|
6558
6571
|
if (this.variable) {
|
|
6559
|
-
this.context.
|
|
6572
|
+
this.context.includeVariableInModule(this.variable);
|
|
6560
6573
|
}
|
|
6561
6574
|
this.context.warn({
|
|
6562
6575
|
code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
|
|
@@ -7184,7 +7197,7 @@ class ForInStatement extends NodeBase {
|
|
|
7184
7197
|
}
|
|
7185
7198
|
include(context, includeChildrenRecursively) {
|
|
7186
7199
|
this.included = true;
|
|
7187
|
-
this.left.
|
|
7200
|
+
this.left.includeAllDeclaredVariables(context, includeChildrenRecursively);
|
|
7188
7201
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7189
7202
|
this.right.include(context, includeChildrenRecursively);
|
|
7190
7203
|
const { brokenFlow } = context;
|
|
@@ -7218,7 +7231,7 @@ class ForOfStatement extends NodeBase {
|
|
|
7218
7231
|
}
|
|
7219
7232
|
include(context, includeChildrenRecursively) {
|
|
7220
7233
|
this.included = true;
|
|
7221
|
-
this.left.
|
|
7234
|
+
this.left.includeAllDeclaredVariables(context, includeChildrenRecursively);
|
|
7222
7235
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
7223
7236
|
this.right.include(context, includeChildrenRecursively);
|
|
7224
7237
|
const { brokenFlow } = context;
|
|
@@ -8913,7 +8926,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
8913
8926
|
}
|
|
8914
8927
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
8915
8928
|
for (const declarator of declarations) {
|
|
8916
|
-
if (!declarator.included)
|
|
8929
|
+
if (!declarator.id.included)
|
|
8917
8930
|
return false;
|
|
8918
8931
|
if (declarator.id.type === Identifier) {
|
|
8919
8932
|
if (exportNamesByVariable.has(declarator.id.variable))
|
|
@@ -8944,10 +8957,11 @@ class VariableDeclaration extends NodeBase {
|
|
|
8944
8957
|
declarator.include(context, includeChildrenRecursively);
|
|
8945
8958
|
}
|
|
8946
8959
|
}
|
|
8947
|
-
|
|
8960
|
+
includeAllDeclaredVariables(context, includeChildrenRecursively) {
|
|
8948
8961
|
this.included = true;
|
|
8949
8962
|
for (const declarator of this.declarations) {
|
|
8950
|
-
declarator.
|
|
8963
|
+
declarator.id.included = true;
|
|
8964
|
+
declarator.includeAllDeclaredVariables(context, includeChildrenRecursively);
|
|
8951
8965
|
}
|
|
8952
8966
|
}
|
|
8953
8967
|
initialise() {
|
|
@@ -8969,13 +8983,11 @@ class VariableDeclaration extends NodeBase {
|
|
|
8969
8983
|
this.renderReplacedDeclarations(code, options, nodeRenderOptions);
|
|
8970
8984
|
}
|
|
8971
8985
|
}
|
|
8972
|
-
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd,
|
|
8986
|
+
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
8973
8987
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
8974
8988
|
code.remove(this.end - 1, this.end);
|
|
8975
8989
|
}
|
|
8976
|
-
|
|
8977
|
-
separatorString += ';';
|
|
8978
|
-
}
|
|
8990
|
+
separatorString += ';';
|
|
8979
8991
|
if (lastSeparatorPos !== null) {
|
|
8980
8992
|
if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
|
|
8981
8993
|
(code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
|
|
@@ -9000,15 +9012,10 @@ class VariableDeclaration extends NodeBase {
|
|
|
9000
9012
|
code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
|
|
9001
9013
|
}
|
|
9002
9014
|
}
|
|
9003
|
-
renderReplacedDeclarations(code, options, { start = this.start, end = this.end
|
|
9015
|
+
renderReplacedDeclarations(code, options, { start = this.start, end = this.end }) {
|
|
9004
9016
|
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
|
|
9005
9017
|
let actualContentEnd, renderedContentEnd;
|
|
9006
|
-
|
|
9007
|
-
renderedContentEnd = this.start + this.kind.length;
|
|
9008
|
-
}
|
|
9009
|
-
else {
|
|
9010
|
-
renderedContentEnd = separatedNodes[0].start;
|
|
9011
|
-
}
|
|
9018
|
+
renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
|
|
9012
9019
|
let lastSeparatorPos = renderedContentEnd - 1;
|
|
9013
9020
|
code.remove(this.start, lastSeparatorPos);
|
|
9014
9021
|
let isInDeclaration = false;
|
|
@@ -9025,8 +9032,9 @@ class VariableDeclaration extends NodeBase {
|
|
|
9025
9032
|
}
|
|
9026
9033
|
leadingString = '';
|
|
9027
9034
|
nextSeparatorString = '';
|
|
9028
|
-
if (node.id
|
|
9029
|
-
|
|
9035
|
+
if (!node.id.included ||
|
|
9036
|
+
(node.id instanceof Identifier$1 &&
|
|
9037
|
+
isReassignedExportsMember(node.id.variable, options.exportNamesByVariable))) {
|
|
9030
9038
|
if (hasRenderedContent) {
|
|
9031
9039
|
separatorString += ';';
|
|
9032
9040
|
}
|
|
@@ -9075,7 +9083,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9075
9083
|
separatorString = nextSeparatorString;
|
|
9076
9084
|
}
|
|
9077
9085
|
if (hasRenderedContent) {
|
|
9078
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd,
|
|
9086
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options);
|
|
9079
9087
|
}
|
|
9080
9088
|
else {
|
|
9081
9089
|
code.remove(start, end);
|
|
@@ -9090,6 +9098,35 @@ class VariableDeclarator extends NodeBase {
|
|
|
9090
9098
|
deoptimizePath(path) {
|
|
9091
9099
|
this.id.deoptimizePath(path);
|
|
9092
9100
|
}
|
|
9101
|
+
hasEffects(context) {
|
|
9102
|
+
return this.id.hasEffects(context) || (this.init !== null && this.init.hasEffects(context));
|
|
9103
|
+
}
|
|
9104
|
+
include(context, includeChildrenRecursively) {
|
|
9105
|
+
this.included = true;
|
|
9106
|
+
if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
|
|
9107
|
+
this.id.include(context, includeChildrenRecursively);
|
|
9108
|
+
}
|
|
9109
|
+
if (this.init) {
|
|
9110
|
+
this.init.include(context, includeChildrenRecursively);
|
|
9111
|
+
}
|
|
9112
|
+
}
|
|
9113
|
+
includeAllDeclaredVariables(context, includeChildrenRecursively) {
|
|
9114
|
+
this.included = true;
|
|
9115
|
+
this.id.include(context, includeChildrenRecursively);
|
|
9116
|
+
}
|
|
9117
|
+
render(code, options) {
|
|
9118
|
+
const renderId = this.id.included;
|
|
9119
|
+
if (renderId) {
|
|
9120
|
+
this.id.render(code, options);
|
|
9121
|
+
}
|
|
9122
|
+
else {
|
|
9123
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', this.id.end);
|
|
9124
|
+
code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
9125
|
+
}
|
|
9126
|
+
if (this.init) {
|
|
9127
|
+
this.init.render(code, options, renderId ? BLANK : { renderedParentType: ExpressionStatement });
|
|
9128
|
+
}
|
|
9129
|
+
}
|
|
9093
9130
|
}
|
|
9094
9131
|
|
|
9095
9132
|
class WhileStatement extends NodeBase {
|
|
@@ -9665,6 +9702,24 @@ function initialiseTimers(inputOptions) {
|
|
|
9665
9702
|
}
|
|
9666
9703
|
}
|
|
9667
9704
|
|
|
9705
|
+
function markModuleAndImpureDependenciesAsExecuted(baseModule) {
|
|
9706
|
+
baseModule.isExecuted = true;
|
|
9707
|
+
const modules = [baseModule];
|
|
9708
|
+
const visitedModules = new Set();
|
|
9709
|
+
for (const module of modules) {
|
|
9710
|
+
for (const dependency of [...module.dependencies, ...module.implicitlyLoadedBefore]) {
|
|
9711
|
+
if (!(dependency instanceof ExternalModule) &&
|
|
9712
|
+
!dependency.isExecuted &&
|
|
9713
|
+
(dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
|
|
9714
|
+
!visitedModules.has(dependency.id)) {
|
|
9715
|
+
dependency.isExecuted = true;
|
|
9716
|
+
visitedModules.add(dependency.id);
|
|
9717
|
+
modules.push(dependency);
|
|
9718
|
+
}
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
|
|
9668
9723
|
function tryParse(module, Parser, acornOptions) {
|
|
9669
9724
|
try {
|
|
9670
9725
|
return Parser.parse(module.info.code, {
|
|
@@ -9687,39 +9742,60 @@ function tryParse(module, Parser, acornOptions) {
|
|
|
9687
9742
|
}, err.pos);
|
|
9688
9743
|
}
|
|
9689
9744
|
}
|
|
9690
|
-
function handleMissingExport(exportName, importingModule, importedModule, importerStart) {
|
|
9691
|
-
return importingModule.error({
|
|
9692
|
-
code: 'MISSING_EXPORT',
|
|
9693
|
-
message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule.id)}`,
|
|
9694
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
9695
|
-
}, importerStart);
|
|
9696
|
-
}
|
|
9697
9745
|
const MISSING_EXPORT_SHIM_DESCRIPTION = {
|
|
9698
9746
|
identifier: null,
|
|
9699
9747
|
localName: MISSING_EXPORT_SHIM_VARIABLE
|
|
9700
9748
|
};
|
|
9701
|
-
function getVariableForExportNameRecursive(target, name, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9749
|
+
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9702
9750
|
const searchedModules = searchedNamesAndModules.get(name);
|
|
9703
9751
|
if (searchedModules) {
|
|
9704
9752
|
if (searchedModules.has(target)) {
|
|
9705
|
-
return null;
|
|
9753
|
+
return isExportAllSearch ? null : error(errCircularReexport(name, target.id));
|
|
9706
9754
|
}
|
|
9707
9755
|
searchedModules.add(target);
|
|
9708
9756
|
}
|
|
9709
9757
|
else {
|
|
9710
9758
|
searchedNamesAndModules.set(name, new Set([target]));
|
|
9711
9759
|
}
|
|
9712
|
-
return target.getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules);
|
|
9760
|
+
return target.getVariableForExportName(name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules);
|
|
9761
|
+
}
|
|
9762
|
+
function getAndExtendSideEffectModules(variable, module) {
|
|
9763
|
+
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, () => new Set());
|
|
9764
|
+
let currentVariable = variable;
|
|
9765
|
+
const referencedVariables = new Set([currentVariable]);
|
|
9766
|
+
while (true) {
|
|
9767
|
+
const importingModule = currentVariable.module;
|
|
9768
|
+
currentVariable =
|
|
9769
|
+
currentVariable instanceof ExportDefaultVariable
|
|
9770
|
+
? currentVariable.getDirectOriginalVariable()
|
|
9771
|
+
: currentVariable instanceof SyntheticNamedExportVariable
|
|
9772
|
+
? currentVariable.syntheticNamespace
|
|
9773
|
+
: null;
|
|
9774
|
+
if (!currentVariable || referencedVariables.has(currentVariable)) {
|
|
9775
|
+
break;
|
|
9776
|
+
}
|
|
9777
|
+
referencedVariables.add(variable);
|
|
9778
|
+
sideEffectModules.add(importingModule);
|
|
9779
|
+
const originalSideEffects = importingModule.sideEffectDependenciesByVariable.get(currentVariable);
|
|
9780
|
+
if (originalSideEffects) {
|
|
9781
|
+
for (const module of originalSideEffects) {
|
|
9782
|
+
sideEffectModules.add(module);
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9785
|
+
}
|
|
9786
|
+
return sideEffectModules;
|
|
9713
9787
|
}
|
|
9714
9788
|
class Module {
|
|
9715
9789
|
constructor(graph, id, options, isEntry, hasModuleSideEffects, syntheticNamedExports, meta) {
|
|
9716
9790
|
this.graph = graph;
|
|
9717
9791
|
this.id = id;
|
|
9718
9792
|
this.options = options;
|
|
9793
|
+
this.alternativeReexportModules = new Map();
|
|
9719
9794
|
this.ast = null;
|
|
9720
9795
|
this.chunkFileNames = new Set();
|
|
9721
9796
|
this.chunkName = null;
|
|
9722
9797
|
this.comments = [];
|
|
9798
|
+
this.cycles = new Set();
|
|
9723
9799
|
this.dependencies = new Set();
|
|
9724
9800
|
this.dynamicDependencies = new Set();
|
|
9725
9801
|
this.dynamicImporters = [];
|
|
@@ -9739,6 +9815,7 @@ class Module {
|
|
|
9739
9815
|
this.isUserDefinedEntryPoint = false;
|
|
9740
9816
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
9741
9817
|
this.reexportDescriptions = Object.create(null);
|
|
9818
|
+
this.sideEffectDependenciesByVariable = new Map();
|
|
9742
9819
|
this.sources = new Set();
|
|
9743
9820
|
this.userChunkNames = new Set();
|
|
9744
9821
|
this.usesTopLevelAwait = false;
|
|
@@ -9828,9 +9905,9 @@ class Module {
|
|
|
9828
9905
|
if (this.relevantDependencies)
|
|
9829
9906
|
return this.relevantDependencies;
|
|
9830
9907
|
const relevantDependencies = new Set();
|
|
9831
|
-
const
|
|
9832
|
-
const
|
|
9833
|
-
let dependencyVariables = this.imports;
|
|
9908
|
+
const necessaryDependencies = new Set();
|
|
9909
|
+
const alwaysCheckedDependencies = new Set();
|
|
9910
|
+
let dependencyVariables = this.imports.keys();
|
|
9834
9911
|
if (this.info.isEntry ||
|
|
9835
9912
|
this.includedDynamicImporters.length > 0 ||
|
|
9836
9913
|
this.namespace.included ||
|
|
@@ -9841,41 +9918,31 @@ class Module {
|
|
|
9841
9918
|
}
|
|
9842
9919
|
}
|
|
9843
9920
|
for (let variable of dependencyVariables) {
|
|
9921
|
+
const sideEffectDependencies = this.sideEffectDependenciesByVariable.get(variable);
|
|
9922
|
+
if (sideEffectDependencies) {
|
|
9923
|
+
for (const module of sideEffectDependencies) {
|
|
9924
|
+
alwaysCheckedDependencies.add(module);
|
|
9925
|
+
}
|
|
9926
|
+
}
|
|
9844
9927
|
if (variable instanceof SyntheticNamedExportVariable) {
|
|
9845
9928
|
variable = variable.getBaseVariable();
|
|
9846
9929
|
}
|
|
9847
9930
|
else if (variable instanceof ExportDefaultVariable) {
|
|
9848
|
-
|
|
9849
|
-
variable = original;
|
|
9850
|
-
for (const module of modules) {
|
|
9851
|
-
additionalSideEffectModules.add(module);
|
|
9852
|
-
possibleDependencies.add(module);
|
|
9853
|
-
}
|
|
9931
|
+
variable = variable.getOriginalVariable();
|
|
9854
9932
|
}
|
|
9855
|
-
|
|
9933
|
+
necessaryDependencies.add(variable.module);
|
|
9856
9934
|
}
|
|
9857
9935
|
if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') {
|
|
9858
|
-
|
|
9859
|
-
if (!(dependency.info.hasModuleSideEffects ||
|
|
9860
|
-
additionalSideEffectModules.has(dependency)) ||
|
|
9861
|
-
relevantDependencies.has(dependency)) {
|
|
9862
|
-
continue;
|
|
9863
|
-
}
|
|
9864
|
-
if (dependency instanceof ExternalModule || dependency.hasEffects()) {
|
|
9865
|
-
relevantDependencies.add(dependency);
|
|
9866
|
-
}
|
|
9867
|
-
else {
|
|
9868
|
-
for (const transitiveDependency of dependency.dependencies) {
|
|
9869
|
-
possibleDependencies.add(transitiveDependency);
|
|
9870
|
-
}
|
|
9871
|
-
}
|
|
9872
|
-
}
|
|
9936
|
+
this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
|
|
9873
9937
|
}
|
|
9874
9938
|
else {
|
|
9875
9939
|
for (const dependency of this.dependencies) {
|
|
9876
9940
|
relevantDependencies.add(dependency);
|
|
9877
9941
|
}
|
|
9878
9942
|
}
|
|
9943
|
+
for (const dependency of necessaryDependencies) {
|
|
9944
|
+
relevantDependencies.add(dependency);
|
|
9945
|
+
}
|
|
9879
9946
|
return (this.relevantDependencies = relevantDependencies);
|
|
9880
9947
|
}
|
|
9881
9948
|
getExportNamesByVariable() {
|
|
@@ -9948,20 +10015,14 @@ class Module {
|
|
|
9948
10015
|
: 'default');
|
|
9949
10016
|
}
|
|
9950
10017
|
if (!this.syntheticNamespace) {
|
|
9951
|
-
return error(
|
|
9952
|
-
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
9953
|
-
id: this.id,
|
|
9954
|
-
message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.info.syntheticNamedExports)}' needs ${typeof this.info.syntheticNamedExports === 'string' &&
|
|
9955
|
-
this.info.syntheticNamedExports !== 'default'
|
|
9956
|
-
? `an export named "${this.info.syntheticNamedExports}"`
|
|
9957
|
-
: 'a default export'}.`
|
|
9958
|
-
});
|
|
10018
|
+
return error(errSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
|
|
9959
10019
|
}
|
|
9960
10020
|
return this.syntheticNamespace;
|
|
9961
10021
|
}
|
|
9962
|
-
getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules) {
|
|
10022
|
+
getVariableForExportName(name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules) {
|
|
9963
10023
|
if (name[0] === '*') {
|
|
9964
10024
|
if (name.length === 1) {
|
|
10025
|
+
// export * from './other'
|
|
9965
10026
|
return this.namespace;
|
|
9966
10027
|
}
|
|
9967
10028
|
else {
|
|
@@ -9973,11 +10034,14 @@ class Module {
|
|
|
9973
10034
|
// export { foo } from './other'
|
|
9974
10035
|
const reexportDeclaration = this.reexportDescriptions[name];
|
|
9975
10036
|
if (reexportDeclaration) {
|
|
9976
|
-
const
|
|
9977
|
-
if (!
|
|
9978
|
-
return
|
|
10037
|
+
const variable = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
|
|
10038
|
+
if (!variable) {
|
|
10039
|
+
return this.error(errMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
|
|
9979
10040
|
}
|
|
9980
|
-
|
|
10041
|
+
if (importerForSideEffects) {
|
|
10042
|
+
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
10043
|
+
}
|
|
10044
|
+
return variable;
|
|
9981
10045
|
}
|
|
9982
10046
|
const exportDeclaration = this.exports[name];
|
|
9983
10047
|
if (exportDeclaration) {
|
|
@@ -9985,28 +10049,43 @@ class Module {
|
|
|
9985
10049
|
return this.exportShimVariable;
|
|
9986
10050
|
}
|
|
9987
10051
|
const name = exportDeclaration.localName;
|
|
9988
|
-
|
|
10052
|
+
const variable = this.traceVariable(name, importerForSideEffects);
|
|
10053
|
+
if (importerForSideEffects) {
|
|
10054
|
+
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, () => new Set()).add(this);
|
|
10055
|
+
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
10056
|
+
}
|
|
10057
|
+
return variable;
|
|
9989
10058
|
}
|
|
9990
10059
|
if (name !== 'default') {
|
|
10060
|
+
let foundSyntheticDeclaration = null;
|
|
9991
10061
|
for (const module of this.exportAllModules) {
|
|
9992
|
-
const declaration = getVariableForExportNameRecursive(module, name, true, searchedNamesAndModules);
|
|
9993
|
-
if (declaration)
|
|
9994
|
-
|
|
10062
|
+
const declaration = getVariableForExportNameRecursive(module, name, importerForSideEffects, true, searchedNamesAndModules);
|
|
10063
|
+
if (declaration) {
|
|
10064
|
+
if (!(declaration instanceof SyntheticNamedExportVariable)) {
|
|
10065
|
+
return declaration;
|
|
10066
|
+
}
|
|
10067
|
+
if (!foundSyntheticDeclaration) {
|
|
10068
|
+
foundSyntheticDeclaration = declaration;
|
|
10069
|
+
}
|
|
10070
|
+
}
|
|
10071
|
+
}
|
|
10072
|
+
if (foundSyntheticDeclaration) {
|
|
10073
|
+
return foundSyntheticDeclaration;
|
|
10074
|
+
}
|
|
10075
|
+
}
|
|
10076
|
+
if (this.info.syntheticNamedExports) {
|
|
10077
|
+
let syntheticExport = this.syntheticExports.get(name);
|
|
10078
|
+
if (!syntheticExport) {
|
|
10079
|
+
const syntheticNamespace = this.getSyntheticNamespace();
|
|
10080
|
+
syntheticExport = new SyntheticNamedExportVariable(this.astContext, name, syntheticNamespace);
|
|
10081
|
+
this.syntheticExports.set(name, syntheticExport);
|
|
10082
|
+
return syntheticExport;
|
|
9995
10083
|
}
|
|
10084
|
+
return syntheticExport;
|
|
9996
10085
|
}
|
|
9997
10086
|
// we don't want to create shims when we are just
|
|
9998
10087
|
// probing export * modules for exports
|
|
9999
10088
|
if (!isExportAllSearch) {
|
|
10000
|
-
if (this.info.syntheticNamedExports) {
|
|
10001
|
-
let syntheticExport = this.syntheticExports.get(name);
|
|
10002
|
-
if (!syntheticExport) {
|
|
10003
|
-
const syntheticNamespace = this.getSyntheticNamespace();
|
|
10004
|
-
syntheticExport = new SyntheticNamedExportVariable(this.astContext, name, syntheticNamespace);
|
|
10005
|
-
this.syntheticExports.set(name, syntheticExport);
|
|
10006
|
-
return syntheticExport;
|
|
10007
|
-
}
|
|
10008
|
-
return syntheticExport;
|
|
10009
|
-
}
|
|
10010
10089
|
if (this.options.shimMissingExports) {
|
|
10011
10090
|
this.shimMissingExport(name);
|
|
10012
10091
|
return this.exportShimVariable;
|
|
@@ -10033,8 +10112,7 @@ class Module {
|
|
|
10033
10112
|
const variable = this.getVariableForExportName(exportName);
|
|
10034
10113
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
10035
10114
|
if (!variable.included) {
|
|
10036
|
-
|
|
10037
|
-
this.graph.needsTreeshakingPass = true;
|
|
10115
|
+
this.includeVariable(variable);
|
|
10038
10116
|
}
|
|
10039
10117
|
}
|
|
10040
10118
|
}
|
|
@@ -10042,8 +10120,7 @@ class Module {
|
|
|
10042
10120
|
const variable = this.getVariableForExportName(name);
|
|
10043
10121
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
10044
10122
|
if (!variable.included) {
|
|
10045
|
-
|
|
10046
|
-
this.graph.needsTreeshakingPass = true;
|
|
10123
|
+
this.includeVariable(variable);
|
|
10047
10124
|
}
|
|
10048
10125
|
if (variable instanceof ExternalVariable) {
|
|
10049
10126
|
variable.module.reexported = true;
|
|
@@ -10063,7 +10140,7 @@ class Module {
|
|
|
10063
10140
|
this.addModulesToImportDescriptions(this.importDescriptions);
|
|
10064
10141
|
this.addModulesToImportDescriptions(this.reexportDescriptions);
|
|
10065
10142
|
for (const name in this.exports) {
|
|
10066
|
-
if (name !== 'default') {
|
|
10143
|
+
if (name !== 'default' && name !== this.info.syntheticNamedExports) {
|
|
10067
10144
|
this.exportsAll[name] = this.id;
|
|
10068
10145
|
}
|
|
10069
10146
|
}
|
|
@@ -10143,7 +10220,7 @@ class Module {
|
|
|
10143
10220
|
importDescriptions: this.importDescriptions,
|
|
10144
10221
|
includeAllExports: () => this.includeAllExports(true),
|
|
10145
10222
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
10146
|
-
|
|
10223
|
+
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
10147
10224
|
magicString: this.magicString,
|
|
10148
10225
|
module: this,
|
|
10149
10226
|
moduleContext: this.context,
|
|
@@ -10179,7 +10256,7 @@ class Module {
|
|
|
10179
10256
|
transformFiles: this.transformFiles
|
|
10180
10257
|
};
|
|
10181
10258
|
}
|
|
10182
|
-
traceVariable(name) {
|
|
10259
|
+
traceVariable(name, importerForSideEffects) {
|
|
10183
10260
|
const localVariable = this.scope.variables.get(name);
|
|
10184
10261
|
if (localVariable) {
|
|
10185
10262
|
return localVariable;
|
|
@@ -10190,9 +10267,9 @@ class Module {
|
|
|
10190
10267
|
if (otherModule instanceof Module && importDeclaration.name === '*') {
|
|
10191
10268
|
return otherModule.namespace;
|
|
10192
10269
|
}
|
|
10193
|
-
const declaration = otherModule.getVariableForExportName(importDeclaration.name);
|
|
10270
|
+
const declaration = otherModule.getVariableForExportName(importDeclaration.name, importerForSideEffects || this);
|
|
10194
10271
|
if (!declaration) {
|
|
10195
|
-
return
|
|
10272
|
+
return this.error(errMissingExport(importDeclaration.name, this.id, otherModule.id), importDeclaration.start);
|
|
10196
10273
|
}
|
|
10197
10274
|
return declaration;
|
|
10198
10275
|
}
|
|
@@ -10344,6 +10421,31 @@ class Module {
|
|
|
10344
10421
|
specifier.module = this.graph.modulesById.get(id);
|
|
10345
10422
|
}
|
|
10346
10423
|
}
|
|
10424
|
+
addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies) {
|
|
10425
|
+
const handledDependencies = new Set();
|
|
10426
|
+
const addSideEffectDependencies = (possibleDependencies) => {
|
|
10427
|
+
for (const dependency of possibleDependencies) {
|
|
10428
|
+
if (handledDependencies.has(dependency)) {
|
|
10429
|
+
continue;
|
|
10430
|
+
}
|
|
10431
|
+
handledDependencies.add(dependency);
|
|
10432
|
+
if (necessaryDependencies.has(dependency)) {
|
|
10433
|
+
relevantDependencies.add(dependency);
|
|
10434
|
+
continue;
|
|
10435
|
+
}
|
|
10436
|
+
if (!(dependency.info.hasModuleSideEffects || alwaysCheckedDependencies.has(dependency))) {
|
|
10437
|
+
continue;
|
|
10438
|
+
}
|
|
10439
|
+
if (dependency instanceof ExternalModule || dependency.hasEffects()) {
|
|
10440
|
+
relevantDependencies.add(dependency);
|
|
10441
|
+
continue;
|
|
10442
|
+
}
|
|
10443
|
+
addSideEffectDependencies(dependency.dependencies);
|
|
10444
|
+
}
|
|
10445
|
+
};
|
|
10446
|
+
addSideEffectDependencies(this.dependencies);
|
|
10447
|
+
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
10448
|
+
}
|
|
10347
10449
|
includeAndGetAdditionalMergedNamespaces() {
|
|
10348
10450
|
const mergedNamespaces = [];
|
|
10349
10451
|
for (const module of this.exportAllModules) {
|
|
@@ -10370,11 +10472,26 @@ class Module {
|
|
|
10370
10472
|
}
|
|
10371
10473
|
}
|
|
10372
10474
|
includeVariable(variable) {
|
|
10373
|
-
const variableModule = variable.module;
|
|
10374
10475
|
if (!variable.included) {
|
|
10375
10476
|
variable.include();
|
|
10376
10477
|
this.graph.needsTreeshakingPass = true;
|
|
10478
|
+
const variableModule = variable.module;
|
|
10479
|
+
if (variableModule && variableModule !== this && variableModule instanceof Module) {
|
|
10480
|
+
if (!variableModule.isExecuted) {
|
|
10481
|
+
markModuleAndImpureDependenciesAsExecuted(variableModule);
|
|
10482
|
+
}
|
|
10483
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
10484
|
+
for (const module of sideEffectModules) {
|
|
10485
|
+
if (!module.isExecuted) {
|
|
10486
|
+
markModuleAndImpureDependenciesAsExecuted(module);
|
|
10487
|
+
}
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10377
10490
|
}
|
|
10491
|
+
}
|
|
10492
|
+
includeVariableInModule(variable) {
|
|
10493
|
+
this.includeVariable(variable);
|
|
10494
|
+
const variableModule = variable.module;
|
|
10378
10495
|
if (variableModule && variableModule !== this) {
|
|
10379
10496
|
this.imports.add(variable);
|
|
10380
10497
|
}
|
|
@@ -10389,6 +10506,23 @@ class Module {
|
|
|
10389
10506
|
this.exports[name] = MISSING_EXPORT_SHIM_DESCRIPTION;
|
|
10390
10507
|
}
|
|
10391
10508
|
}
|
|
10509
|
+
// if there is a cyclic import in the reexport chain, we should not
|
|
10510
|
+
// import from the original module but from the cyclic module to not
|
|
10511
|
+
// mess up execution order.
|
|
10512
|
+
function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
10513
|
+
if (variable.module instanceof Module && variable.module !== reexporter) {
|
|
10514
|
+
const exporterCycles = variable.module.cycles;
|
|
10515
|
+
if (exporterCycles.size > 0) {
|
|
10516
|
+
const importerCycles = reexporter.cycles;
|
|
10517
|
+
for (const cycleSymbol of importerCycles) {
|
|
10518
|
+
if (exporterCycles.has(cycleSymbol)) {
|
|
10519
|
+
importer.alternativeReexportModules.set(variable, reexporter);
|
|
10520
|
+
break;
|
|
10521
|
+
}
|
|
10522
|
+
}
|
|
10523
|
+
}
|
|
10524
|
+
}
|
|
10525
|
+
}
|
|
10392
10526
|
|
|
10393
10527
|
class Source {
|
|
10394
10528
|
constructor(filename, content) {
|
|
@@ -10675,68 +10809,6 @@ function escapeId(id) {
|
|
|
10675
10809
|
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
|
10676
10810
|
}
|
|
10677
10811
|
|
|
10678
|
-
const compareExecIndex = (unitA, unitB) => unitA.execIndex > unitB.execIndex ? 1 : -1;
|
|
10679
|
-
function sortByExecutionOrder(units) {
|
|
10680
|
-
units.sort(compareExecIndex);
|
|
10681
|
-
}
|
|
10682
|
-
function analyseModuleExecution(entryModules) {
|
|
10683
|
-
let nextExecIndex = 0;
|
|
10684
|
-
const cyclePaths = [];
|
|
10685
|
-
const analysedModules = new Set();
|
|
10686
|
-
const dynamicImports = new Set();
|
|
10687
|
-
const parents = new Map();
|
|
10688
|
-
const orderedModules = [];
|
|
10689
|
-
const analyseModule = (module) => {
|
|
10690
|
-
if (module instanceof Module) {
|
|
10691
|
-
for (const dependency of module.dependencies) {
|
|
10692
|
-
if (parents.has(dependency)) {
|
|
10693
|
-
if (!analysedModules.has(dependency)) {
|
|
10694
|
-
cyclePaths.push(getCyclePath(dependency, module, parents));
|
|
10695
|
-
}
|
|
10696
|
-
continue;
|
|
10697
|
-
}
|
|
10698
|
-
parents.set(dependency, module);
|
|
10699
|
-
analyseModule(dependency);
|
|
10700
|
-
}
|
|
10701
|
-
for (const dependency of module.implicitlyLoadedBefore) {
|
|
10702
|
-
dynamicImports.add(dependency);
|
|
10703
|
-
}
|
|
10704
|
-
for (const { resolution } of module.dynamicImports) {
|
|
10705
|
-
if (resolution instanceof Module) {
|
|
10706
|
-
dynamicImports.add(resolution);
|
|
10707
|
-
}
|
|
10708
|
-
}
|
|
10709
|
-
orderedModules.push(module);
|
|
10710
|
-
}
|
|
10711
|
-
module.execIndex = nextExecIndex++;
|
|
10712
|
-
analysedModules.add(module);
|
|
10713
|
-
};
|
|
10714
|
-
for (const curEntry of entryModules) {
|
|
10715
|
-
if (!parents.has(curEntry)) {
|
|
10716
|
-
parents.set(curEntry, null);
|
|
10717
|
-
analyseModule(curEntry);
|
|
10718
|
-
}
|
|
10719
|
-
}
|
|
10720
|
-
for (const curEntry of dynamicImports) {
|
|
10721
|
-
if (!parents.has(curEntry)) {
|
|
10722
|
-
parents.set(curEntry, null);
|
|
10723
|
-
analyseModule(curEntry);
|
|
10724
|
-
}
|
|
10725
|
-
}
|
|
10726
|
-
return { orderedModules, cyclePaths };
|
|
10727
|
-
}
|
|
10728
|
-
function getCyclePath(module, parent, parents) {
|
|
10729
|
-
const path = [relativeId(module.id)];
|
|
10730
|
-
let nextModule = parent;
|
|
10731
|
-
while (nextModule !== module) {
|
|
10732
|
-
path.push(relativeId(nextModule.id));
|
|
10733
|
-
nextModule = parents.get(nextModule);
|
|
10734
|
-
}
|
|
10735
|
-
path.push(path[0]);
|
|
10736
|
-
path.reverse();
|
|
10737
|
-
return path;
|
|
10738
|
-
}
|
|
10739
|
-
|
|
10740
10812
|
function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
|
|
10741
10813
|
let nameIndex = 0;
|
|
10742
10814
|
for (const variable of exports) {
|
|
@@ -10828,6 +10900,44 @@ function getIndentString(modules, options) {
|
|
|
10828
10900
|
return '\t';
|
|
10829
10901
|
}
|
|
10830
10902
|
|
|
10903
|
+
function getStaticDependencies(chunk, orderedModules, chunkByModule) {
|
|
10904
|
+
const staticDependencyBlocks = [];
|
|
10905
|
+
const handledDependencies = new Set();
|
|
10906
|
+
for (let modulePos = orderedModules.length - 1; modulePos >= 0; modulePos--) {
|
|
10907
|
+
const module = orderedModules[modulePos];
|
|
10908
|
+
if (!handledDependencies.has(module)) {
|
|
10909
|
+
const staticDependencies = [];
|
|
10910
|
+
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule);
|
|
10911
|
+
staticDependencyBlocks.unshift(staticDependencies);
|
|
10912
|
+
}
|
|
10913
|
+
}
|
|
10914
|
+
const dependencies = new Set();
|
|
10915
|
+
for (const block of staticDependencyBlocks) {
|
|
10916
|
+
for (const dependency of block) {
|
|
10917
|
+
dependencies.add(dependency);
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
return dependencies;
|
|
10921
|
+
}
|
|
10922
|
+
function addStaticDependencies(module, staticDependencies, handledModules, chunk, chunkByModule) {
|
|
10923
|
+
const dependencies = module.getDependenciesToBeIncluded();
|
|
10924
|
+
for (const dependency of dependencies) {
|
|
10925
|
+
if (dependency instanceof ExternalModule) {
|
|
10926
|
+
staticDependencies.push(dependency);
|
|
10927
|
+
continue;
|
|
10928
|
+
}
|
|
10929
|
+
const dependencyChunk = chunkByModule.get(dependency);
|
|
10930
|
+
if (dependencyChunk !== chunk) {
|
|
10931
|
+
staticDependencies.push(dependencyChunk);
|
|
10932
|
+
continue;
|
|
10933
|
+
}
|
|
10934
|
+
if (!handledModules.has(dependency)) {
|
|
10935
|
+
handledModules.add(dependency);
|
|
10936
|
+
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule);
|
|
10937
|
+
}
|
|
10938
|
+
}
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10831
10941
|
function decodedSourcemap(map) {
|
|
10832
10942
|
if (!map)
|
|
10833
10943
|
return null;
|
|
@@ -11083,7 +11193,6 @@ class Chunk$1 {
|
|
|
11083
11193
|
this.facadeChunkByModule.set(module, this);
|
|
11084
11194
|
if (module.preserveSignature) {
|
|
11085
11195
|
this.strictFacade = needsStrictFacade;
|
|
11086
|
-
this.ensureReexportsAreAvailableForModule(module);
|
|
11087
11196
|
}
|
|
11088
11197
|
this.assignFacadeName(requiredFacades.shift(), module);
|
|
11089
11198
|
}
|
|
@@ -11221,8 +11330,8 @@ class Chunk$1 {
|
|
|
11221
11330
|
return this.exportNamesByVariable.get(variable)[0];
|
|
11222
11331
|
}
|
|
11223
11332
|
link() {
|
|
11333
|
+
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule);
|
|
11224
11334
|
for (const module of this.orderedModules) {
|
|
11225
|
-
this.addDependenciesToChunk(module.getDependenciesToBeIncluded(), this.dependencies);
|
|
11226
11335
|
this.addDependenciesToChunk(module.dynamicDependencies, this.dynamicDependencies);
|
|
11227
11336
|
this.addDependenciesToChunk(module.implicitlyLoadedBefore, this.implicitlyLoadedBefore);
|
|
11228
11337
|
this.setUpChunkImportsAndExportsForModule(module);
|
|
@@ -11255,9 +11364,6 @@ class Chunk$1 {
|
|
|
11255
11364
|
this.inlineChunkDependencies(dep);
|
|
11256
11365
|
}
|
|
11257
11366
|
}
|
|
11258
|
-
const sortedDependencies = [...this.dependencies];
|
|
11259
|
-
sortByExecutionOrder(sortedDependencies);
|
|
11260
|
-
this.dependencies = new Set(sortedDependencies);
|
|
11261
11367
|
this.prepareDynamicImportsAndImportMetas();
|
|
11262
11368
|
this.setIdentifierRenderResolutions(options);
|
|
11263
11369
|
let hoistedSource = '';
|
|
@@ -11449,6 +11555,23 @@ class Chunk$1 {
|
|
|
11449
11555
|
this.name = sanitizeFileName(name || facadedModule.chunkName || getAliasName(facadedModule.id));
|
|
11450
11556
|
}
|
|
11451
11557
|
}
|
|
11558
|
+
checkCircularDependencyImport(variable, importingModule) {
|
|
11559
|
+
const variableModule = variable.module;
|
|
11560
|
+
if (variableModule instanceof Module) {
|
|
11561
|
+
const exportChunk = this.chunkByModule.get(variableModule);
|
|
11562
|
+
let alternativeReexportModule;
|
|
11563
|
+
do {
|
|
11564
|
+
alternativeReexportModule = importingModule.alternativeReexportModules.get(variable);
|
|
11565
|
+
if (alternativeReexportModule) {
|
|
11566
|
+
const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
|
|
11567
|
+
if (exportingChunk && exportingChunk !== exportChunk) {
|
|
11568
|
+
this.inputOptions.onwarn(errCyclicCrossChunkReexport(variableModule.getExportNamesByVariable().get(variable)[0], variableModule.id, alternativeReexportModule.id, importingModule.id));
|
|
11569
|
+
}
|
|
11570
|
+
importingModule = alternativeReexportModule;
|
|
11571
|
+
}
|
|
11572
|
+
} while (alternativeReexportModule);
|
|
11573
|
+
}
|
|
11574
|
+
}
|
|
11452
11575
|
computeContentHashWithDependencies(addons, options, existingNames) {
|
|
11453
11576
|
const hash = createHash();
|
|
11454
11577
|
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':'));
|
|
@@ -11478,6 +11601,7 @@ class Chunk$1 {
|
|
|
11478
11601
|
? exportedVariable.getBaseVariable()
|
|
11479
11602
|
: exportedVariable;
|
|
11480
11603
|
if (!(importedVariable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
|
|
11604
|
+
this.checkCircularDependencyImport(importedVariable, module);
|
|
11481
11605
|
const exportingModule = importedVariable.module;
|
|
11482
11606
|
if (exportingModule instanceof Module) {
|
|
11483
11607
|
const chunk = this.chunkByModule.get(exportingModule);
|
|
@@ -11873,6 +11997,7 @@ class Chunk$1 {
|
|
|
11873
11997
|
if (!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules) &&
|
|
11874
11998
|
variable.module instanceof Module) {
|
|
11875
11999
|
chunk.exports.add(variable);
|
|
12000
|
+
this.checkCircularDependencyImport(variable, module);
|
|
11876
12001
|
}
|
|
11877
12002
|
}
|
|
11878
12003
|
}
|
|
@@ -12076,6 +12201,71 @@ function commondir(files) {
|
|
|
12076
12201
|
return commonSegments.length > 1 ? commonSegments.join('/') : '/';
|
|
12077
12202
|
}
|
|
12078
12203
|
|
|
12204
|
+
const compareExecIndex = (unitA, unitB) => unitA.execIndex > unitB.execIndex ? 1 : -1;
|
|
12205
|
+
function sortByExecutionOrder(units) {
|
|
12206
|
+
units.sort(compareExecIndex);
|
|
12207
|
+
}
|
|
12208
|
+
function analyseModuleExecution(entryModules) {
|
|
12209
|
+
let nextExecIndex = 0;
|
|
12210
|
+
const cyclePaths = [];
|
|
12211
|
+
const analysedModules = new Set();
|
|
12212
|
+
const dynamicImports = new Set();
|
|
12213
|
+
const parents = new Map();
|
|
12214
|
+
const orderedModules = [];
|
|
12215
|
+
const analyseModule = (module) => {
|
|
12216
|
+
if (module instanceof Module) {
|
|
12217
|
+
for (const dependency of module.dependencies) {
|
|
12218
|
+
if (parents.has(dependency)) {
|
|
12219
|
+
if (!analysedModules.has(dependency)) {
|
|
12220
|
+
cyclePaths.push(getCyclePath(dependency, module, parents));
|
|
12221
|
+
}
|
|
12222
|
+
continue;
|
|
12223
|
+
}
|
|
12224
|
+
parents.set(dependency, module);
|
|
12225
|
+
analyseModule(dependency);
|
|
12226
|
+
}
|
|
12227
|
+
for (const dependency of module.implicitlyLoadedBefore) {
|
|
12228
|
+
dynamicImports.add(dependency);
|
|
12229
|
+
}
|
|
12230
|
+
for (const { resolution } of module.dynamicImports) {
|
|
12231
|
+
if (resolution instanceof Module) {
|
|
12232
|
+
dynamicImports.add(resolution);
|
|
12233
|
+
}
|
|
12234
|
+
}
|
|
12235
|
+
orderedModules.push(module);
|
|
12236
|
+
}
|
|
12237
|
+
module.execIndex = nextExecIndex++;
|
|
12238
|
+
analysedModules.add(module);
|
|
12239
|
+
};
|
|
12240
|
+
for (const curEntry of entryModules) {
|
|
12241
|
+
if (!parents.has(curEntry)) {
|
|
12242
|
+
parents.set(curEntry, null);
|
|
12243
|
+
analyseModule(curEntry);
|
|
12244
|
+
}
|
|
12245
|
+
}
|
|
12246
|
+
for (const curEntry of dynamicImports) {
|
|
12247
|
+
if (!parents.has(curEntry)) {
|
|
12248
|
+
parents.set(curEntry, null);
|
|
12249
|
+
analyseModule(curEntry);
|
|
12250
|
+
}
|
|
12251
|
+
}
|
|
12252
|
+
return { orderedModules, cyclePaths };
|
|
12253
|
+
}
|
|
12254
|
+
function getCyclePath(module, parent, parents) {
|
|
12255
|
+
const cycleSymbol = Symbol(module.id);
|
|
12256
|
+
const path = [relativeId(module.id)];
|
|
12257
|
+
let nextModule = parent;
|
|
12258
|
+
module.cycles.add(cycleSymbol);
|
|
12259
|
+
while (nextModule !== module) {
|
|
12260
|
+
nextModule.cycles.add(cycleSymbol);
|
|
12261
|
+
path.push(relativeId(nextModule.id));
|
|
12262
|
+
nextModule = parents.get(nextModule);
|
|
12263
|
+
}
|
|
12264
|
+
path.push(path[0]);
|
|
12265
|
+
path.reverse();
|
|
12266
|
+
return path;
|
|
12267
|
+
}
|
|
12268
|
+
|
|
12079
12269
|
var BuildPhase;
|
|
12080
12270
|
(function (BuildPhase) {
|
|
12081
12271
|
BuildPhase[BuildPhase["LOAD_AND_PARSE"] = 0] = "LOAD_AND_PARSE";
|
|
@@ -19212,160 +19402,6 @@ var acornClassFields = function(Parser) {
|
|
|
19212
19402
|
}
|
|
19213
19403
|
};
|
|
19214
19404
|
|
|
19215
|
-
function withoutAcornBigInt(acorn, Parser) {
|
|
19216
|
-
return class extends Parser {
|
|
19217
|
-
readInt(radix, len) {
|
|
19218
|
-
// Hack: len is only != null for unicode escape sequences,
|
|
19219
|
-
// where numeric separators are not allowed
|
|
19220
|
-
if (len != null) return super.readInt(radix, len)
|
|
19221
|
-
|
|
19222
|
-
let start = this.pos, total = 0, acceptUnderscore = false;
|
|
19223
|
-
for (;;) {
|
|
19224
|
-
let code = this.input.charCodeAt(this.pos), val;
|
|
19225
|
-
if (code >= 97) val = code - 97 + 10; // a
|
|
19226
|
-
else if (code == 95) {
|
|
19227
|
-
if (!acceptUnderscore) this.raise(this.pos, "Invalid numeric separator");
|
|
19228
|
-
++this.pos;
|
|
19229
|
-
acceptUnderscore = false;
|
|
19230
|
-
continue
|
|
19231
|
-
} else if (code >= 65) val = code - 65 + 10; // A
|
|
19232
|
-
else if (code >= 48 && code <= 57) val = code - 48; // 0-9
|
|
19233
|
-
else val = Infinity;
|
|
19234
|
-
if (val >= radix) break
|
|
19235
|
-
++this.pos;
|
|
19236
|
-
total = total * radix + val;
|
|
19237
|
-
acceptUnderscore = true;
|
|
19238
|
-
}
|
|
19239
|
-
if (this.pos === start) return null
|
|
19240
|
-
if (!acceptUnderscore) this.raise(this.pos - 1, "Invalid numeric separator");
|
|
19241
|
-
|
|
19242
|
-
return total
|
|
19243
|
-
}
|
|
19244
|
-
|
|
19245
|
-
readNumber(startsWithDot) {
|
|
19246
|
-
const token = super.readNumber(startsWithDot);
|
|
19247
|
-
let octal = this.end - this.start >= 2 && this.input.charCodeAt(this.start) === 48;
|
|
19248
|
-
const stripped = this.getNumberInput(this.start, this.end);
|
|
19249
|
-
if (stripped.length < this.end - this.start) {
|
|
19250
|
-
if (octal) this.raise(this.start, "Invalid number");
|
|
19251
|
-
this.value = parseFloat(stripped);
|
|
19252
|
-
}
|
|
19253
|
-
return token
|
|
19254
|
-
}
|
|
19255
|
-
|
|
19256
|
-
// This is used by acorn-bigint
|
|
19257
|
-
getNumberInput(start, end) {
|
|
19258
|
-
return this.input.slice(start, end).replace(/_/g, "")
|
|
19259
|
-
}
|
|
19260
|
-
}
|
|
19261
|
-
}
|
|
19262
|
-
|
|
19263
|
-
function withAcornBigInt(acorn, Parser) {
|
|
19264
|
-
return class extends Parser {
|
|
19265
|
-
readInt(radix, len) {
|
|
19266
|
-
// Hack: len is only != null for unicode escape sequences,
|
|
19267
|
-
// where numeric separators are not allowed
|
|
19268
|
-
if (len != null) return super.readInt(radix, len)
|
|
19269
|
-
|
|
19270
|
-
let start = this.pos, total = 0, acceptUnderscore = false;
|
|
19271
|
-
for (;;) {
|
|
19272
|
-
let code = this.input.charCodeAt(this.pos), val;
|
|
19273
|
-
if (code >= 97) val = code - 97 + 10; // a
|
|
19274
|
-
else if (code == 95) {
|
|
19275
|
-
if (!acceptUnderscore) this.raise(this.pos, "Invalid numeric separator");
|
|
19276
|
-
++this.pos;
|
|
19277
|
-
acceptUnderscore = false;
|
|
19278
|
-
continue
|
|
19279
|
-
} else if (code >= 65) val = code - 65 + 10; // A
|
|
19280
|
-
else if (code >= 48 && code <= 57) val = code - 48; // 0-9
|
|
19281
|
-
else val = Infinity;
|
|
19282
|
-
if (val >= radix) break
|
|
19283
|
-
++this.pos;
|
|
19284
|
-
total = total * radix + val;
|
|
19285
|
-
acceptUnderscore = true;
|
|
19286
|
-
}
|
|
19287
|
-
if (this.pos === start) return null
|
|
19288
|
-
if (!acceptUnderscore) this.raise(this.pos - 1, "Invalid numeric separator");
|
|
19289
|
-
|
|
19290
|
-
return total
|
|
19291
|
-
}
|
|
19292
|
-
|
|
19293
|
-
readNumber(startsWithDot) {
|
|
19294
|
-
let start = this.pos;
|
|
19295
|
-
if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
|
|
19296
|
-
let octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
19297
|
-
let octalLike = false;
|
|
19298
|
-
if (octal && this.strict) this.raise(start, "Invalid number");
|
|
19299
|
-
let next = this.input.charCodeAt(this.pos);
|
|
19300
|
-
if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
|
|
19301
|
-
let str = this.getNumberInput(start, this.pos);
|
|
19302
|
-
// eslint-disable-next-line node/no-unsupported-features/es-builtins
|
|
19303
|
-
let val = typeof BigInt !== "undefined" ? BigInt(str) : null;
|
|
19304
|
-
++this.pos;
|
|
19305
|
-
if (acorn.isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
|
19306
|
-
return this.finishToken(acorn.tokTypes.num, val)
|
|
19307
|
-
}
|
|
19308
|
-
if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
|
|
19309
|
-
octal = false;
|
|
19310
|
-
octalLike = true;
|
|
19311
|
-
}
|
|
19312
|
-
if (next === 46 && !octal) { // '.'
|
|
19313
|
-
++this.pos;
|
|
19314
|
-
this.readInt(10);
|
|
19315
|
-
next = this.input.charCodeAt(this.pos);
|
|
19316
|
-
}
|
|
19317
|
-
if ((next === 69 || next === 101) && !octal) { // 'eE'
|
|
19318
|
-
next = this.input.charCodeAt(++this.pos);
|
|
19319
|
-
if (next === 43 || next === 45) ++this.pos; // '+-'
|
|
19320
|
-
if (this.readInt(10) === null) this.raise(start, "Invalid number");
|
|
19321
|
-
}
|
|
19322
|
-
if (acorn.isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
|
19323
|
-
let str = this.getNumberInput(start, this.pos);
|
|
19324
|
-
if ((octal || octalLike) && str.length < this.pos - start) {
|
|
19325
|
-
this.raise(start, "Invalid number");
|
|
19326
|
-
}
|
|
19327
|
-
|
|
19328
|
-
let val = octal ? parseInt(str, 8) : parseFloat(str);
|
|
19329
|
-
return this.finishToken(acorn.tokTypes.num, val)
|
|
19330
|
-
}
|
|
19331
|
-
|
|
19332
|
-
parseLiteral(value) {
|
|
19333
|
-
const ret = super.parseLiteral(value);
|
|
19334
|
-
if (ret.bigint) ret.bigint = ret.bigint.replace(/_/g, "");
|
|
19335
|
-
return ret
|
|
19336
|
-
}
|
|
19337
|
-
|
|
19338
|
-
readRadixNumber(radix) {
|
|
19339
|
-
let start = this.pos;
|
|
19340
|
-
this.pos += 2; // 0x
|
|
19341
|
-
let val = this.readInt(radix);
|
|
19342
|
-
if (val == null) { this.raise(this.start + 2, `Expected number in radix ${radix}`); }
|
|
19343
|
-
if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
|
|
19344
|
-
let str = this.getNumberInput(start, this.pos);
|
|
19345
|
-
// eslint-disable-next-line node/no-unsupported-features/es-builtins
|
|
19346
|
-
val = typeof BigInt !== "undefined" ? BigInt(str) : null;
|
|
19347
|
-
++this.pos;
|
|
19348
|
-
} else if (acorn.isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
|
|
19349
|
-
return this.finishToken(acorn.tokTypes.num, val)
|
|
19350
|
-
}
|
|
19351
|
-
|
|
19352
|
-
// This is used by acorn-bigint, which theoretically could be used with acorn@6.2 || acorn@7
|
|
19353
|
-
getNumberInput(start, end) {
|
|
19354
|
-
return this.input.slice(start, end).replace(/_/g, "")
|
|
19355
|
-
}
|
|
19356
|
-
}
|
|
19357
|
-
}
|
|
19358
|
-
|
|
19359
|
-
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
19360
|
-
function numericSeparator(Parser) {
|
|
19361
|
-
const acorn = Parser.acorn || require$$0;
|
|
19362
|
-
const withAcornBigIntSupport = (acorn.version.startsWith("6.") && !(acorn.version.startsWith("6.0.") || acorn.version.startsWith("6.1."))) || acorn.version.startsWith("7.");
|
|
19363
|
-
|
|
19364
|
-
return withAcornBigIntSupport ? withAcornBigInt(acorn, Parser) : withoutAcornBigInt(acorn, Parser)
|
|
19365
|
-
}
|
|
19366
|
-
|
|
19367
|
-
var acornNumericSeparator = numericSeparator;
|
|
19368
|
-
|
|
19369
19405
|
var acornStaticClassFeatures = function(Parser) {
|
|
19370
19406
|
const ExtendedParser = acornPrivateClassElements(Parser);
|
|
19371
19407
|
|
|
@@ -19522,7 +19558,6 @@ const getAcorn$1 = (config) => ({
|
|
|
19522
19558
|
const getAcornInjectPlugins = (config) => [
|
|
19523
19559
|
acornClassFields,
|
|
19524
19560
|
acornStaticClassFeatures,
|
|
19525
|
-
acornNumericSeparator,
|
|
19526
19561
|
...ensureArray(config.acornInjectPlugins)
|
|
19527
19562
|
];
|
|
19528
19563
|
const getCache = (config) => {
|