rollup 3.0.0-3 → 3.0.0-6
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 +6748 -0
- package/LICENSE.md +0 -29
- package/README.md +2 -2
- package/dist/bin/rollup +21 -27
- package/dist/es/rollup.js +8 -7
- package/dist/es/shared/rollup.js +408 -285
- package/dist/es/shared/watch.js +27 -19
- package/dist/loadConfigFile.js +11 -11
- package/dist/rollup.d.ts +101 -111
- package/dist/rollup.js +9 -8
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +63 -166
- package/dist/shared/mergeOptions.js +3 -3
- package/dist/shared/rollup.js +481 -335
- package/dist/shared/watch-cli.js +13 -10
- package/dist/shared/watch.js +29 -21
- package/package.json +18 -19
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.0.0-
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.0.0-5
|
|
4
|
+
Tue, 06 Sep 2022 05:29:28 GMT - commit 1d085668121abe6be83c28c212a02c181c16d2b8
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
+
const node_path = require('node:path');
|
|
12
13
|
const require$$0 = require('path');
|
|
13
|
-
const process$1 = require('process');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
14
|
+
const process$1 = require('node:process');
|
|
15
|
+
const node_perf_hooks = require('node:perf_hooks');
|
|
16
|
+
const node_crypto = require('node:crypto');
|
|
17
|
+
const node_fs = require('node:fs');
|
|
18
|
+
const node_events = require('node:events');
|
|
18
19
|
|
|
19
20
|
function _interopNamespaceDefault(e) {
|
|
20
21
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -27,7 +28,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
28
|
return n;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
var version$1 = "3.0.0-
|
|
31
|
+
var version$1 = "3.0.0-5";
|
|
31
32
|
|
|
32
33
|
function ensureArray$1(items) {
|
|
33
34
|
if (Array.isArray(items)) {
|
|
@@ -162,13 +163,13 @@ function normalize(path) {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
function getAliasName(id) {
|
|
165
|
-
const base =
|
|
166
|
-
return base.substring(0, base.length -
|
|
166
|
+
const base = node_path.basename(id);
|
|
167
|
+
return base.substring(0, base.length - node_path.extname(id).length);
|
|
167
168
|
}
|
|
168
169
|
function relativeId(id) {
|
|
169
170
|
if (!isAbsolute(id))
|
|
170
171
|
return id;
|
|
171
|
-
return relative(
|
|
172
|
+
return relative(node_path.resolve(), id);
|
|
172
173
|
}
|
|
173
174
|
function isPathFragment(name) {
|
|
174
175
|
// starting with "/", "./", "../", "C:/"
|
|
@@ -176,17 +177,17 @@ function isPathFragment(name) {
|
|
|
176
177
|
}
|
|
177
178
|
const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
|
|
178
179
|
function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
|
|
179
|
-
let relativePath = normalize(relative(
|
|
180
|
+
let relativePath = normalize(relative(node_path.dirname(importerId), targetPath));
|
|
180
181
|
if (stripJsExtension && relativePath.endsWith('.js')) {
|
|
181
182
|
relativePath = relativePath.slice(0, -3);
|
|
182
183
|
}
|
|
183
184
|
if (ensureFileName) {
|
|
184
185
|
if (relativePath === '')
|
|
185
|
-
return '../' +
|
|
186
|
+
return '../' + node_path.basename(targetPath);
|
|
186
187
|
if (UPPER_DIR_REGEX.test(relativePath)) {
|
|
187
188
|
return relativePath
|
|
188
189
|
.split('/')
|
|
189
|
-
.concat(['..',
|
|
190
|
+
.concat(['..', node_path.basename(targetPath)])
|
|
190
191
|
.join('/');
|
|
191
192
|
}
|
|
192
193
|
}
|
|
@@ -217,7 +218,7 @@ function augmentCodeLocation(props, pos, source, id) {
|
|
|
217
218
|
}
|
|
218
219
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
219
220
|
// error code below
|
|
220
|
-
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR',
|
|
221
|
+
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
221
222
|
function errAddonNotGenerated(message, hook, plugin) {
|
|
222
223
|
return {
|
|
223
224
|
code: ADDON_ERROR,
|
|
@@ -408,6 +409,33 @@ function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
|
|
|
408
409
|
message: `Cannot assign "${relativeId(moduleId)}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
|
|
409
410
|
};
|
|
410
411
|
}
|
|
412
|
+
function errCannotBundleConfigAsEsm(originalError) {
|
|
413
|
+
return {
|
|
414
|
+
cause: originalError,
|
|
415
|
+
code: INVALID_CONFIG_MODULE_FORMAT,
|
|
416
|
+
message: `Rollup transpiled your configuration to an ES module even though it appears to contain CommonJS elements. To resolve this, you can pass the "--bundleConfigAsCjs" flag to Rollup or change your configuration to only contain valid ESM code.\n\nOriginal error: ${originalError.message}`,
|
|
417
|
+
stack: originalError.stack,
|
|
418
|
+
url: 'https://rollupjs.org/guide/en/#--bundleconfigascjs'
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function errCannotLoadConfigAsCjs(originalError) {
|
|
422
|
+
return {
|
|
423
|
+
cause: originalError,
|
|
424
|
+
code: INVALID_CONFIG_MODULE_FORMAT,
|
|
425
|
+
message: `Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: ${originalError.message}`,
|
|
426
|
+
stack: originalError.stack,
|
|
427
|
+
url: 'https://rollupjs.org/guide/en/#--bundleconfigascjs'
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function errCannotLoadConfigAsEsm(originalError) {
|
|
431
|
+
return {
|
|
432
|
+
cause: originalError,
|
|
433
|
+
code: INVALID_CONFIG_MODULE_FORMAT,
|
|
434
|
+
message: `Node tried to load your configuration as an ES module even though it is likely CommonJS. To resolve this, change the extension of your configuration to ".cjs" or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: ${originalError.message}`,
|
|
435
|
+
stack: originalError.stack,
|
|
436
|
+
url: 'https://rollupjs.org/guide/en/#--bundleconfigascjs'
|
|
437
|
+
};
|
|
438
|
+
}
|
|
411
439
|
function errInvalidExportOptionValue(optionValue) {
|
|
412
440
|
return {
|
|
413
441
|
code: INVALID_EXPORT_OPTION,
|
|
@@ -435,11 +463,19 @@ function errInvalidOption(option, urlHash, explanation, value) {
|
|
|
435
463
|
url: `https://rollupjs.org/guide/en/#${urlHash}`
|
|
436
464
|
};
|
|
437
465
|
}
|
|
438
|
-
function
|
|
466
|
+
function errInvalidAddonPluginHook(hook, plugin) {
|
|
439
467
|
return {
|
|
440
468
|
code: INVALID_PLUGIN_HOOK,
|
|
441
469
|
hook,
|
|
442
|
-
message: `Error running plugin hook "${hook}" for "${plugin}", expected a function hook.`,
|
|
470
|
+
message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a string, a function hook or an object with a "handler" string or function.`,
|
|
471
|
+
plugin
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function errInvalidFunctionPluginHook(hook, plugin) {
|
|
475
|
+
return {
|
|
476
|
+
code: INVALID_PLUGIN_HOOK,
|
|
477
|
+
hook,
|
|
478
|
+
message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a function hook or an object with a "handler" function.`,
|
|
443
479
|
plugin
|
|
444
480
|
};
|
|
445
481
|
}
|
|
@@ -615,15 +651,6 @@ function errPluginError(error, plugin, { hook, id } = {}) {
|
|
|
615
651
|
}
|
|
616
652
|
return error;
|
|
617
653
|
}
|
|
618
|
-
function errPreferNamedExports(facadeModuleId) {
|
|
619
|
-
const file = relativeId(facadeModuleId);
|
|
620
|
-
return {
|
|
621
|
-
code: PREFER_NAMED_EXPORTS,
|
|
622
|
-
id: facadeModuleId,
|
|
623
|
-
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.`,
|
|
624
|
-
url: `https://rollupjs.org/guide/en/#outputexports`
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
654
|
function errShimmedExport(id, binding) {
|
|
628
655
|
return {
|
|
629
656
|
binding,
|
|
@@ -670,12 +697,6 @@ function errThisIsUndefined() {
|
|
|
670
697
|
url: `https://rollupjs.org/guide/en/#error-this-is-undefined`
|
|
671
698
|
};
|
|
672
699
|
}
|
|
673
|
-
function errTranspiledEsmConfig(fileName) {
|
|
674
|
-
return {
|
|
675
|
-
code: TRANSPILED_ESM_CONFIG,
|
|
676
|
-
message: `While loading the Rollup configuration from "${relativeId(fileName)}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
700
|
function errUnexpectedNamedImport(id, imported, isReexport) {
|
|
680
701
|
const importType = isReexport ? 'reexport' : 'import';
|
|
681
702
|
return {
|
|
@@ -1149,15 +1170,20 @@ class Chunk$1 {
|
|
|
1149
1170
|
}
|
|
1150
1171
|
}
|
|
1151
1172
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
if (typeof
|
|
1156
|
-
|
|
1157
|
-
} else
|
|
1158
|
-
|
|
1173
|
+
function getBtoa () {
|
|
1174
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
1175
|
+
return (str) => window.btoa(unescape(encodeURIComponent(str)));
|
|
1176
|
+
} else if (typeof Buffer === 'function') {
|
|
1177
|
+
return (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
1178
|
+
} else {
|
|
1179
|
+
return () => {
|
|
1180
|
+
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1159
1183
|
}
|
|
1160
1184
|
|
|
1185
|
+
const btoa = /*#__PURE__*/ getBtoa();
|
|
1186
|
+
|
|
1161
1187
|
class SourceMap {
|
|
1162
1188
|
constructor(properties) {
|
|
1163
1189
|
this.version = 3;
|
|
@@ -1349,7 +1375,7 @@ class MagicString {
|
|
|
1349
1375
|
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
1350
1376
|
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
1351
1377
|
storedNames: { writable: true, value: {} },
|
|
1352
|
-
indentStr: { writable: true, value:
|
|
1378
|
+
indentStr: { writable: true, value: undefined },
|
|
1353
1379
|
});
|
|
1354
1380
|
|
|
1355
1381
|
this.byStart[0] = chunk;
|
|
@@ -1479,7 +1505,19 @@ class MagicString {
|
|
|
1479
1505
|
return new SourceMap(this.generateDecodedMap(options));
|
|
1480
1506
|
}
|
|
1481
1507
|
|
|
1508
|
+
_ensureindentStr() {
|
|
1509
|
+
if (this.indentStr === undefined) {
|
|
1510
|
+
this.indentStr = guessIndent(this.original);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
_getRawIndentString() {
|
|
1515
|
+
this._ensureindentStr();
|
|
1516
|
+
return this.indentStr;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1482
1519
|
getIndentString() {
|
|
1520
|
+
this._ensureindentStr();
|
|
1483
1521
|
return this.indentStr === null ? '\t' : this.indentStr;
|
|
1484
1522
|
}
|
|
1485
1523
|
|
|
@@ -1491,7 +1529,10 @@ class MagicString {
|
|
|
1491
1529
|
indentStr = undefined;
|
|
1492
1530
|
}
|
|
1493
1531
|
|
|
1494
|
-
|
|
1532
|
+
if (indentStr === undefined) {
|
|
1533
|
+
this._ensureindentStr();
|
|
1534
|
+
indentStr = this.indentStr || '\t';
|
|
1535
|
+
}
|
|
1495
1536
|
|
|
1496
1537
|
if (indentStr === '') return this; // noop
|
|
1497
1538
|
|
|
@@ -2207,7 +2248,7 @@ class Bundle$1 {
|
|
|
2207
2248
|
const indentStringCounts = {};
|
|
2208
2249
|
|
|
2209
2250
|
this.sources.forEach((source) => {
|
|
2210
|
-
const indentStr = source.content.
|
|
2251
|
+
const indentStr = source.content._getRawIndentString();
|
|
2211
2252
|
|
|
2212
2253
|
if (indentStr === null) return;
|
|
2213
2254
|
|
|
@@ -2358,7 +2399,7 @@ class ExternalChunk {
|
|
|
2358
2399
|
const { paths } = this.options;
|
|
2359
2400
|
return (this.fileName =
|
|
2360
2401
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
2361
|
-
(this.renormalizeRenderPath ? normalize(
|
|
2402
|
+
(this.renormalizeRenderPath ? normalize(node_path.relative(this.inputBase, this.id)) : this.id));
|
|
2362
2403
|
}
|
|
2363
2404
|
getImportPath(importer) {
|
|
2364
2405
|
return escapeId(this.renormalizeRenderPath
|
|
@@ -2380,6 +2421,7 @@ function getOrCreate(map, key, init) {
|
|
|
2380
2421
|
const UnknownKey = Symbol('Unknown Key');
|
|
2381
2422
|
const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key');
|
|
2382
2423
|
const UnknownInteger = Symbol('Unknown Integer');
|
|
2424
|
+
const SymbolToStringTag = Symbol('Symbol.toStringTag');
|
|
2383
2425
|
const EMPTY_PATH = [];
|
|
2384
2426
|
const UNKNOWN_PATH = [UnknownKey];
|
|
2385
2427
|
// For deoptimizations, this means we are modifying an unknown property but did
|
|
@@ -2457,7 +2499,7 @@ class ExpressionEntity {
|
|
|
2457
2499
|
/**
|
|
2458
2500
|
* If possible it returns a stringifyable literal value for this node that can be used
|
|
2459
2501
|
* for inlining or comparing values.
|
|
2460
|
-
* Otherwise it should return UnknownValue.
|
|
2502
|
+
* Otherwise, it should return UnknownValue.
|
|
2461
2503
|
*/
|
|
2462
2504
|
getLiteralValueAtPath(_path, _recursionTracker, _origin) {
|
|
2463
2505
|
return UnknownValue;
|
|
@@ -2633,15 +2675,16 @@ const RESERVED_NAMES$1 = RESERVED_NAMES;
|
|
|
2633
2675
|
|
|
2634
2676
|
const illegalCharacters = /[^$_a-zA-Z0-9]/g;
|
|
2635
2677
|
const startsWithDigit = (str) => /\d/.test(str[0]);
|
|
2678
|
+
const needsEscape = (str) => startsWithDigit(str) || RESERVED_NAMES$1.has(str) || str === 'arguments';
|
|
2636
2679
|
function isLegal(str) {
|
|
2637
|
-
if (
|
|
2680
|
+
if (needsEscape(str)) {
|
|
2638
2681
|
return false;
|
|
2639
2682
|
}
|
|
2640
2683
|
return !illegalCharacters.test(str);
|
|
2641
2684
|
}
|
|
2642
2685
|
function makeLegal(str) {
|
|
2643
2686
|
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
|
|
2644
|
-
if (
|
|
2687
|
+
if (needsEscape(str))
|
|
2645
2688
|
str = `_${str}`;
|
|
2646
2689
|
return str || '_';
|
|
2647
2690
|
}
|
|
@@ -5431,10 +5474,10 @@ const SequenceExpression$1 = 'SequenceExpression';
|
|
|
5431
5474
|
|
|
5432
5475
|
// this looks ridiculous, but it prevents sourcemap tooling from mistaking
|
|
5433
5476
|
// this for an actual sourceMappingURL
|
|
5434
|
-
|
|
5435
|
-
|
|
5477
|
+
let SOURCEMAPPING_URL = 'sourceMa';
|
|
5478
|
+
SOURCEMAPPING_URL += 'ppingURL';
|
|
5436
5479
|
const whiteSpaceNoNewline = '[ \\f\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]';
|
|
5437
|
-
const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${
|
|
5480
|
+
const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${SOURCEMAPPING_URL}=.+`);
|
|
5438
5481
|
|
|
5439
5482
|
const ANNOTATION_KEY = '_rollupAnnotations';
|
|
5440
5483
|
const INVALID_COMMENT_KEY = '_rollupRemoved';
|
|
@@ -6597,7 +6640,7 @@ function toBase64(num) {
|
|
|
6597
6640
|
let outStr = '';
|
|
6598
6641
|
do {
|
|
6599
6642
|
const curDigit = num % base;
|
|
6600
|
-
num =
|
|
6643
|
+
num = (num / base) | 0;
|
|
6601
6644
|
outStr = chars[curDigit] + outStr;
|
|
6602
6645
|
} while (num !== 0);
|
|
6603
6646
|
return outStr;
|
|
@@ -6875,15 +6918,16 @@ function is_reference (node, parent) {
|
|
|
6875
6918
|
|
|
6876
6919
|
/* eslint sort-keys: "off" */
|
|
6877
6920
|
const ValueProperties = Symbol('Value Properties');
|
|
6921
|
+
const getTruthyLiteralValue = () => UnknownTruthyValue;
|
|
6922
|
+
const returnFalse = () => false;
|
|
6923
|
+
const returnTrue = () => true;
|
|
6878
6924
|
const PURE = {
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
}
|
|
6925
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
6926
|
+
hasEffectsWhenCalled: returnFalse
|
|
6882
6927
|
};
|
|
6883
6928
|
const IMPURE = {
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
}
|
|
6929
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
6930
|
+
hasEffectsWhenCalled: returnTrue
|
|
6887
6931
|
};
|
|
6888
6932
|
// We use shortened variables to reduce file size here
|
|
6889
6933
|
/* OBJECT */
|
|
@@ -6900,6 +6944,7 @@ const PF = {
|
|
|
6900
6944
|
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
6901
6945
|
__proto__: null,
|
|
6902
6946
|
[ValueProperties]: {
|
|
6947
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
6903
6948
|
hasEffectsWhenCalled({ args }, context) {
|
|
6904
6949
|
return (!args.length ||
|
|
6905
6950
|
args[0].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
@@ -7095,7 +7140,16 @@ const knownGlobals = {
|
|
|
7095
7140
|
[ValueProperties]: PURE,
|
|
7096
7141
|
for: PF,
|
|
7097
7142
|
keyFor: PF,
|
|
7098
|
-
prototype: O
|
|
7143
|
+
prototype: O,
|
|
7144
|
+
toStringTag: {
|
|
7145
|
+
__proto__: null,
|
|
7146
|
+
[ValueProperties]: {
|
|
7147
|
+
getLiteralValue() {
|
|
7148
|
+
return SymbolToStringTag;
|
|
7149
|
+
},
|
|
7150
|
+
hasEffectsWhenCalled: returnTrue
|
|
7151
|
+
}
|
|
7152
|
+
}
|
|
7099
7153
|
},
|
|
7100
7154
|
SyntaxError: PC,
|
|
7101
7155
|
toLocaleString: O,
|
|
@@ -7741,7 +7795,8 @@ class GlobalVariable extends Variable {
|
|
|
7741
7795
|
this.isReassigned = true;
|
|
7742
7796
|
}
|
|
7743
7797
|
getLiteralValueAtPath(path, _recursionTracker, _origin) {
|
|
7744
|
-
|
|
7798
|
+
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7799
|
+
return globalAtPath ? globalAtPath.getLiteralValue() : UnknownValue;
|
|
7745
7800
|
}
|
|
7746
7801
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7747
7802
|
switch (interaction.type) {
|
|
@@ -8932,7 +8987,7 @@ class MemberExpression extends NodeBase {
|
|
|
8932
8987
|
this.assignmentDeoptimized = false;
|
|
8933
8988
|
this.bound = false;
|
|
8934
8989
|
this.expressionsToBeDeoptimized = [];
|
|
8935
|
-
this.
|
|
8990
|
+
this.isUndefined = false;
|
|
8936
8991
|
}
|
|
8937
8992
|
bind() {
|
|
8938
8993
|
this.bound = true;
|
|
@@ -8943,8 +8998,8 @@ class MemberExpression extends NodeBase {
|
|
|
8943
8998
|
if (!resolvedVariable) {
|
|
8944
8999
|
super.bind();
|
|
8945
9000
|
}
|
|
8946
|
-
else if (
|
|
8947
|
-
this.
|
|
9001
|
+
else if (resolvedVariable === 'undefined') {
|
|
9002
|
+
this.isUndefined = true;
|
|
8948
9003
|
}
|
|
8949
9004
|
else {
|
|
8950
9005
|
this.variable = resolvedVariable;
|
|
@@ -8970,7 +9025,7 @@ class MemberExpression extends NodeBase {
|
|
|
8970
9025
|
if (this.variable) {
|
|
8971
9026
|
this.variable.deoptimizePath(path);
|
|
8972
9027
|
}
|
|
8973
|
-
else if (!this.
|
|
9028
|
+
else if (!this.isUndefined) {
|
|
8974
9029
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8975
9030
|
const propertyKey = this.getPropertyKey();
|
|
8976
9031
|
this.object.deoptimizePath([
|
|
@@ -8984,7 +9039,7 @@ class MemberExpression extends NodeBase {
|
|
|
8984
9039
|
if (this.variable) {
|
|
8985
9040
|
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8986
9041
|
}
|
|
8987
|
-
else if (!this.
|
|
9042
|
+
else if (!this.isUndefined) {
|
|
8988
9043
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8989
9044
|
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
8990
9045
|
}
|
|
@@ -8997,8 +9052,8 @@ class MemberExpression extends NodeBase {
|
|
|
8997
9052
|
if (this.variable) {
|
|
8998
9053
|
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8999
9054
|
}
|
|
9000
|
-
if (this.
|
|
9001
|
-
return
|
|
9055
|
+
if (this.isUndefined) {
|
|
9056
|
+
return undefined;
|
|
9002
9057
|
}
|
|
9003
9058
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9004
9059
|
if (path.length < MAX_PATH_DEPTH) {
|
|
@@ -9010,8 +9065,8 @@ class MemberExpression extends NodeBase {
|
|
|
9010
9065
|
if (this.variable) {
|
|
9011
9066
|
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9012
9067
|
}
|
|
9013
|
-
if (this.
|
|
9014
|
-
return
|
|
9068
|
+
if (this.isUndefined) {
|
|
9069
|
+
return UNDEFINED_EXPRESSION;
|
|
9015
9070
|
}
|
|
9016
9071
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9017
9072
|
if (path.length < MAX_PATH_DEPTH) {
|
|
@@ -9040,7 +9095,7 @@ class MemberExpression extends NodeBase {
|
|
|
9040
9095
|
if (this.variable) {
|
|
9041
9096
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9042
9097
|
}
|
|
9043
|
-
if (this.
|
|
9098
|
+
if (this.isUndefined) {
|
|
9044
9099
|
return true;
|
|
9045
9100
|
}
|
|
9046
9101
|
if (path.length < MAX_PATH_DEPTH) {
|
|
@@ -9076,9 +9131,9 @@ class MemberExpression extends NodeBase {
|
|
|
9076
9131
|
this.accessInteraction = { thisArg: this.object, type: INTERACTION_ACCESSED };
|
|
9077
9132
|
}
|
|
9078
9133
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
9079
|
-
if (this.variable || this.
|
|
9134
|
+
if (this.variable || this.isUndefined) {
|
|
9080
9135
|
const { snippets: { getPropertyAccess } } = options;
|
|
9081
|
-
let replacement = this.variable ? this.variable.getName(getPropertyAccess) :
|
|
9136
|
+
let replacement = this.variable ? this.variable.getName(getPropertyAccess) : 'undefined';
|
|
9082
9137
|
if (renderedParentType && isCalleeOfRenderedParent)
|
|
9083
9138
|
replacement = '0, ' + replacement;
|
|
9084
9139
|
code.overwrite(this.start, this.end, replacement, {
|
|
@@ -9109,7 +9164,7 @@ class MemberExpression extends NodeBase {
|
|
|
9109
9164
|
// Namespaces are not bound and should not be deoptimized
|
|
9110
9165
|
this.bound &&
|
|
9111
9166
|
propertyReadSideEffects &&
|
|
9112
|
-
!(this.variable || this.
|
|
9167
|
+
!(this.variable || this.isUndefined)) {
|
|
9113
9168
|
const propertyKey = this.getPropertyKey();
|
|
9114
9169
|
this.object.deoptimizeThisOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
9115
9170
|
this.context.requestTreeshakingPass();
|
|
@@ -9123,7 +9178,7 @@ class MemberExpression extends NodeBase {
|
|
|
9123
9178
|
// Namespaces are not bound and should not be deoptimized
|
|
9124
9179
|
this.bound &&
|
|
9125
9180
|
propertyReadSideEffects &&
|
|
9126
|
-
!(this.variable || this.
|
|
9181
|
+
!(this.variable || this.isUndefined)) {
|
|
9127
9182
|
this.object.deoptimizeThisOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
9128
9183
|
this.context.requestTreeshakingPass();
|
|
9129
9184
|
}
|
|
@@ -9143,14 +9198,19 @@ class MemberExpression extends NodeBase {
|
|
|
9143
9198
|
if (this.propertyKey === null) {
|
|
9144
9199
|
this.propertyKey = UnknownKey;
|
|
9145
9200
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
9146
|
-
return (this.propertyKey =
|
|
9201
|
+
return (this.propertyKey =
|
|
9202
|
+
value === SymbolToStringTag
|
|
9203
|
+
? value
|
|
9204
|
+
: typeof value === 'symbol'
|
|
9205
|
+
? UnknownKey
|
|
9206
|
+
: String(value));
|
|
9147
9207
|
}
|
|
9148
9208
|
return this.propertyKey;
|
|
9149
9209
|
}
|
|
9150
9210
|
hasAccessEffect(context) {
|
|
9151
9211
|
const { propertyReadSideEffects } = this.context.options
|
|
9152
9212
|
.treeshake;
|
|
9153
|
-
return (!(this.variable || this.
|
|
9213
|
+
return (!(this.variable || this.isUndefined) &&
|
|
9154
9214
|
propertyReadSideEffects &&
|
|
9155
9215
|
(propertyReadSideEffects === 'always' ||
|
|
9156
9216
|
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
@@ -10357,31 +10417,29 @@ class ImportDefaultSpecifier extends NodeBase {
|
|
|
10357
10417
|
}
|
|
10358
10418
|
|
|
10359
10419
|
const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
|
|
10360
|
-
const
|
|
10420
|
+
const INTEROP_DEFAULT_COMPAT_VARIABLE = '_interopDefaultCompat';
|
|
10361
10421
|
const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
|
|
10422
|
+
const INTEROP_NAMESPACE_COMPAT_VARIABLE = '_interopNamespaceCompat';
|
|
10362
10423
|
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
10363
10424
|
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
10364
10425
|
const MERGE_NAMESPACES_VARIABLE = '_mergeNamespaces';
|
|
10365
10426
|
const defaultInteropHelpersByInteropType = {
|
|
10366
10427
|
auto: INTEROP_DEFAULT_VARIABLE,
|
|
10428
|
+
compat: INTEROP_DEFAULT_COMPAT_VARIABLE,
|
|
10367
10429
|
default: null,
|
|
10368
10430
|
defaultOnly: null,
|
|
10369
|
-
esModule: null
|
|
10370
|
-
false: null,
|
|
10371
|
-
true: INTEROP_DEFAULT_LEGACY_VARIABLE
|
|
10431
|
+
esModule: null
|
|
10372
10432
|
};
|
|
10373
10433
|
const isDefaultAProperty = (interopType, externalLiveBindings) => interopType === 'esModule' ||
|
|
10374
|
-
(externalLiveBindings && (interopType === 'auto' || interopType === '
|
|
10434
|
+
(externalLiveBindings && (interopType === 'auto' || interopType === 'compat'));
|
|
10375
10435
|
const namespaceInteropHelpersByInteropType = {
|
|
10376
10436
|
auto: INTEROP_NAMESPACE_VARIABLE,
|
|
10437
|
+
compat: INTEROP_NAMESPACE_COMPAT_VARIABLE,
|
|
10377
10438
|
default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
|
|
10378
10439
|
defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
|
|
10379
|
-
esModule: null
|
|
10380
|
-
false: null,
|
|
10381
|
-
true: INTEROP_NAMESPACE_VARIABLE
|
|
10440
|
+
esModule: null
|
|
10382
10441
|
};
|
|
10383
|
-
const canDefaultBeTakenFromNamespace = (interopType, externalLiveBindings) => isDefaultAProperty(interopType, externalLiveBindings)
|
|
10384
|
-
defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE;
|
|
10442
|
+
const canDefaultBeTakenFromNamespace = (interopType, externalLiveBindings) => interopType !== 'esModule' && isDefaultAProperty(interopType, externalLiveBindings);
|
|
10385
10443
|
const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, liveBindings, freeze, namespaceToStringTag) => {
|
|
10386
10444
|
const usedHelpers = new Set(additionalHelpers);
|
|
10387
10445
|
for (const variable of HELPER_NAMES) {
|
|
@@ -10394,14 +10452,14 @@ const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, l
|
|
|
10394
10452
|
: '').join('');
|
|
10395
10453
|
};
|
|
10396
10454
|
const HELPER_GENERATORS = {
|
|
10397
|
-
[
|
|
10455
|
+
[INTEROP_DEFAULT_COMPAT_VARIABLE](_t, snippets, liveBindings) {
|
|
10398
10456
|
const { _, getDirectReturnFunction, n } = snippets;
|
|
10399
10457
|
const [left, right] = getDirectReturnFunction(['e'], {
|
|
10400
10458
|
functionReturn: true,
|
|
10401
10459
|
lineBreakIndent: null,
|
|
10402
|
-
name:
|
|
10460
|
+
name: INTEROP_DEFAULT_COMPAT_VARIABLE
|
|
10403
10461
|
});
|
|
10404
|
-
return (`${left}
|
|
10462
|
+
return (`${left}${getIsCompatNamespace(snippets)}${_}?${_}` +
|
|
10405
10463
|
`${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
|
|
10406
10464
|
},
|
|
10407
10465
|
[INTEROP_DEFAULT_VARIABLE](_t, snippets, liveBindings) {
|
|
@@ -10414,6 +10472,21 @@ const HELPER_GENERATORS = {
|
|
|
10414
10472
|
return (`${left}e${_}&&${_}e.__esModule${_}?${_}` +
|
|
10415
10473
|
`${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
|
|
10416
10474
|
},
|
|
10475
|
+
[INTEROP_NAMESPACE_COMPAT_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag, usedHelpers) {
|
|
10476
|
+
const { _, getDirectReturnFunction, n } = snippets;
|
|
10477
|
+
if (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)) {
|
|
10478
|
+
const [left, right] = getDirectReturnFunction(['e'], {
|
|
10479
|
+
functionReturn: true,
|
|
10480
|
+
lineBreakIndent: null,
|
|
10481
|
+
name: INTEROP_NAMESPACE_COMPAT_VARIABLE
|
|
10482
|
+
});
|
|
10483
|
+
return `${left}${getIsCompatNamespace(snippets)}${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${right}${n}${n}`;
|
|
10484
|
+
}
|
|
10485
|
+
return (`function ${INTEROP_NAMESPACE_COMPAT_VARIABLE}(e)${_}{${n}` +
|
|
10486
|
+
`${t}if${_}(${getIsCompatNamespace(snippets)})${_}return e;${n}` +
|
|
10487
|
+
createNamespaceObject(t, t, snippets, liveBindings, freeze, namespaceToStringTag) +
|
|
10488
|
+
`}${n}${n}`);
|
|
10489
|
+
},
|
|
10417
10490
|
[INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE](_t, snippets, _liveBindings, freeze, namespaceToStringTag) {
|
|
10418
10491
|
const { getDirectReturnFunction, getObject, n } = snippets;
|
|
10419
10492
|
const [left, right] = getDirectReturnFunction(['e'], {
|
|
@@ -10466,6 +10539,7 @@ const HELPER_GENERATORS = {
|
|
|
10466
10539
|
};
|
|
10467
10540
|
const getDefaultLiveBinding = ({ _, getObject }) => `e${_}:${_}${getObject([['default', 'e']], { lineBreakIndent: null })}`;
|
|
10468
10541
|
const getDefaultStatic = ({ _, getPropertyAccess }) => `e${getPropertyAccess('default')}${_}:${_}e`;
|
|
10542
|
+
const getIsCompatNamespace = ({ _ }) => `e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e`;
|
|
10469
10543
|
const createNamespaceObject = (t, i, snippets, liveBindings, freeze, namespaceToStringTag) => {
|
|
10470
10544
|
const { _, cnst, getObject, getPropertyAccess, n, s } = snippets;
|
|
10471
10545
|
const copyProperty = `{${n}` +
|
|
@@ -10716,7 +10790,7 @@ class ImportExpression extends NodeBase {
|
|
|
10716
10790
|
}
|
|
10717
10791
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
10718
10792
|
return exportMode === 'external'
|
|
10719
|
-
? namespaceInteropHelpersByInteropType[
|
|
10793
|
+
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
10720
10794
|
: exportMode === 'default'
|
|
10721
10795
|
? INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE
|
|
10722
10796
|
: null;
|
|
@@ -10943,7 +11017,7 @@ class MetaProperty extends NodeBase {
|
|
|
10943
11017
|
const chunkId = this.preliminaryChunkId;
|
|
10944
11018
|
if (referenceId) {
|
|
10945
11019
|
const fileName = pluginDriver.getFileName(referenceId);
|
|
10946
|
-
const relativePath = normalize(
|
|
11020
|
+
const relativePath = normalize(node_path.relative(node_path.dirname(chunkId), fileName));
|
|
10947
11021
|
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
10948
11022
|
{
|
|
10949
11023
|
chunkId,
|
|
@@ -12287,6 +12361,10 @@ class NamespaceVariable extends Variable {
|
|
|
12287
12361
|
this.references.push(identifier);
|
|
12288
12362
|
this.name = identifier.name;
|
|
12289
12363
|
}
|
|
12364
|
+
getLiteralValueAtPath() {
|
|
12365
|
+
// This can only happen for Symbol.toStringTag right now
|
|
12366
|
+
return 'Module';
|
|
12367
|
+
}
|
|
12290
12368
|
getMemberVariables() {
|
|
12291
12369
|
if (this.memberVariables) {
|
|
12292
12370
|
return this.memberVariables;
|
|
@@ -12302,6 +12380,9 @@ class NamespaceVariable extends Variable {
|
|
|
12302
12380
|
}
|
|
12303
12381
|
return (this.memberVariables = memberVariables);
|
|
12304
12382
|
}
|
|
12383
|
+
hasEffectsOnInteractionAtPath() {
|
|
12384
|
+
return false;
|
|
12385
|
+
}
|
|
12305
12386
|
include() {
|
|
12306
12387
|
this.included = true;
|
|
12307
12388
|
this.context.includeAllExports();
|
|
@@ -12453,7 +12534,7 @@ function getPersistedLabel(label, level) {
|
|
|
12453
12534
|
function timeStartImpl(label, level = 3) {
|
|
12454
12535
|
label = getPersistedLabel(label, level);
|
|
12455
12536
|
const startMemory = process$1.memoryUsage().heapUsed;
|
|
12456
|
-
const startTime =
|
|
12537
|
+
const startTime = node_perf_hooks.performance.now();
|
|
12457
12538
|
const timer = timers.get(label);
|
|
12458
12539
|
if (timer === undefined) {
|
|
12459
12540
|
timers.set(label, {
|
|
@@ -12475,7 +12556,7 @@ function timeEndImpl(label, level = 3) {
|
|
|
12475
12556
|
if (timer !== undefined) {
|
|
12476
12557
|
const currentMemory = process$1.memoryUsage().heapUsed;
|
|
12477
12558
|
timer.memory += currentMemory - timer.startMemory;
|
|
12478
|
-
timer.time +=
|
|
12559
|
+
timer.time += node_perf_hooks.performance.now() - timer.startTime;
|
|
12479
12560
|
timer.totalMemory = Math.max(timer.totalMemory, currentMemory);
|
|
12480
12561
|
}
|
|
12481
12562
|
}
|
|
@@ -12715,8 +12796,8 @@ class Module {
|
|
|
12715
12796
|
});
|
|
12716
12797
|
}
|
|
12717
12798
|
basename() {
|
|
12718
|
-
const base =
|
|
12719
|
-
const ext =
|
|
12799
|
+
const base = node_path.basename(this.id);
|
|
12800
|
+
const ext = node_path.extname(this.id);
|
|
12720
12801
|
return makeLegal(ext ? base.slice(0, -ext.length) : base);
|
|
12721
12802
|
}
|
|
12722
12803
|
bindReferences() {
|
|
@@ -13475,7 +13556,7 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
|
|
|
13475
13556
|
function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
|
|
13476
13557
|
if (imported === 'default') {
|
|
13477
13558
|
if (!isChunk) {
|
|
13478
|
-
const moduleInterop =
|
|
13559
|
+
const moduleInterop = interop(moduleId);
|
|
13479
13560
|
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
13480
13561
|
? defaultVariableName
|
|
13481
13562
|
: moduleVariableName;
|
|
@@ -13488,9 +13569,7 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
|
|
|
13488
13569
|
: moduleVariableName;
|
|
13489
13570
|
}
|
|
13490
13571
|
if (imported === '*') {
|
|
13491
|
-
return (isChunk
|
|
13492
|
-
? !depNamedExportsMode
|
|
13493
|
-
: namespaceInteropHelpersByInteropType[String(interop(moduleId))])
|
|
13572
|
+
return (isChunk ? !depNamedExportsMode : namespaceInteropHelpersByInteropType[interop(moduleId)])
|
|
13494
13573
|
? namespaceVariableName
|
|
13495
13574
|
: moduleVariableName;
|
|
13496
13575
|
}
|
|
@@ -13557,7 +13636,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13557
13636
|
}
|
|
13558
13637
|
}
|
|
13559
13638
|
else {
|
|
13560
|
-
const moduleInterop =
|
|
13639
|
+
const moduleInterop = interop(importPath);
|
|
13561
13640
|
let hasDefault = false;
|
|
13562
13641
|
let hasNamespace = false;
|
|
13563
13642
|
for (const { imported, reexported } of [
|
|
@@ -13591,48 +13670,55 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
|
|
|
13591
13670
|
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, indent, snippets, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
13592
13671
|
}
|
|
13593
13672
|
|
|
13673
|
+
function addJsExtension(name) {
|
|
13674
|
+
return name.endsWith('.js') ? name : name + '.js';
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13594
13677
|
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
13595
13678
|
// The assumption is that this makes sense for all relative ids:
|
|
13596
13679
|
// https://requirejs.org/docs/api.html#jsfiles
|
|
13597
|
-
function
|
|
13598
|
-
|
|
13680
|
+
function updateExtensionForRelativeAmdId(id, forceJsExtensionForImports) {
|
|
13681
|
+
if (id[0] !== '.') {
|
|
13682
|
+
return id;
|
|
13683
|
+
}
|
|
13684
|
+
return forceJsExtensionForImports ? addJsExtension(id) : removeJsExtension(id);
|
|
13599
13685
|
}
|
|
13600
13686
|
|
|
13601
13687
|
const builtins = {
|
|
13602
|
-
assert:
|
|
13603
|
-
buffer:
|
|
13604
|
-
console:
|
|
13605
|
-
constants:
|
|
13606
|
-
domain:
|
|
13607
|
-
events:
|
|
13608
|
-
http:
|
|
13609
|
-
https:
|
|
13610
|
-
os:
|
|
13611
|
-
path:
|
|
13612
|
-
process:
|
|
13613
|
-
punycode:
|
|
13614
|
-
querystring:
|
|
13615
|
-
stream:
|
|
13616
|
-
string_decoder:
|
|
13617
|
-
timers:
|
|
13618
|
-
tty:
|
|
13619
|
-
url:
|
|
13620
|
-
util:
|
|
13621
|
-
vm:
|
|
13622
|
-
zlib:
|
|
13688
|
+
assert: 1,
|
|
13689
|
+
buffer: 1,
|
|
13690
|
+
console: 1,
|
|
13691
|
+
constants: 1,
|
|
13692
|
+
domain: 1,
|
|
13693
|
+
events: 1,
|
|
13694
|
+
http: 1,
|
|
13695
|
+
https: 1,
|
|
13696
|
+
os: 1,
|
|
13697
|
+
path: 1,
|
|
13698
|
+
process: 1,
|
|
13699
|
+
punycode: 1,
|
|
13700
|
+
querystring: 1,
|
|
13701
|
+
stream: 1,
|
|
13702
|
+
string_decoder: 1,
|
|
13703
|
+
timers: 1,
|
|
13704
|
+
tty: 1,
|
|
13705
|
+
url: 1,
|
|
13706
|
+
util: 1,
|
|
13707
|
+
vm: 1,
|
|
13708
|
+
zlib: 1
|
|
13623
13709
|
};
|
|
13624
13710
|
function warnOnBuiltins(warn, dependencies) {
|
|
13625
13711
|
const externalBuiltins = dependencies
|
|
13626
13712
|
.map(({ importPath }) => importPath)
|
|
13627
|
-
.filter(importPath => importPath in builtins);
|
|
13713
|
+
.filter(importPath => importPath in builtins || importPath.startsWith('node:'));
|
|
13628
13714
|
if (!externalBuiltins.length)
|
|
13629
13715
|
return;
|
|
13630
13716
|
warn(errMissingNodeBuiltins(externalBuiltins));
|
|
13631
13717
|
}
|
|
13632
13718
|
|
|
13633
|
-
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13719
|
+
function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13634
13720
|
warnOnBuiltins(onwarn, dependencies);
|
|
13635
|
-
const deps = dependencies.map(m => `'${
|
|
13721
|
+
const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
13636
13722
|
const args = dependencies.map(m => m.name);
|
|
13637
13723
|
const { n, getNonArrowFunctionIntro, _ } = snippets;
|
|
13638
13724
|
if (namedExportsMode && hasExports) {
|
|
@@ -13653,7 +13739,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13653
13739
|
const useStrict = strict ? `${_}'use strict';` : '';
|
|
13654
13740
|
magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
|
|
13655
13741
|
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
13656
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
|
|
13742
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && namespaceToStringTag, snippets);
|
|
13657
13743
|
if (namespaceMarkers) {
|
|
13658
13744
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13659
13745
|
}
|
|
@@ -13669,10 +13755,10 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13669
13755
|
.append(`${n}${n}}));`);
|
|
13670
13756
|
}
|
|
13671
13757
|
|
|
13672
|
-
function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13758
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
13673
13759
|
const { _, n } = snippets;
|
|
13674
13760
|
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
13675
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
|
|
13761
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && namespaceToStringTag, snippets);
|
|
13676
13762
|
if (namespaceMarkers) {
|
|
13677
13763
|
namespaceMarkers += n + n;
|
|
13678
13764
|
}
|
|
@@ -13864,7 +13950,7 @@ function trimEmptyImports(dependencies) {
|
|
|
13864
13950
|
return [];
|
|
13865
13951
|
}
|
|
13866
13952
|
|
|
13867
|
-
function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
|
|
13953
|
+
function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
|
|
13868
13954
|
const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
|
|
13869
13955
|
const isNamespaced = name && name.includes('.');
|
|
13870
13956
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
@@ -13910,7 +13996,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
13910
13996
|
wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
|
|
13911
13997
|
}
|
|
13912
13998
|
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
13913
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
|
|
13999
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), namespaceToStringTag, snippets);
|
|
13914
14000
|
if (namespaceMarkers) {
|
|
13915
14001
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
13916
14002
|
}
|
|
@@ -14065,7 +14151,7 @@ function safeAccess(name, globalVar, { _, getPropertyAccess }) {
|
|
|
14065
14151
|
.map(part => (propertyPath += getPropertyAccess(part)))
|
|
14066
14152
|
.join(`${_}&&${_}`);
|
|
14067
14153
|
}
|
|
14068
|
-
function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
|
|
14154
|
+
function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
|
|
14069
14155
|
const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
14070
14156
|
const factoryVar = compact ? 'f' : 'factory';
|
|
14071
14157
|
const globalVar = compact ? 'g' : 'global';
|
|
@@ -14073,7 +14159,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
14073
14159
|
return error(errMissingNameOptionForUmdExport());
|
|
14074
14160
|
}
|
|
14075
14161
|
warnOnBuiltins(onwarn, dependencies);
|
|
14076
|
-
const amdDeps = dependencies.map(m => `'${
|
|
14162
|
+
const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
14077
14163
|
const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
|
|
14078
14164
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
14079
14165
|
const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar, getPropertyAccess));
|
|
@@ -14147,7 +14233,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
14147
14233
|
const wrapperOutro = n + n + '}));';
|
|
14148
14234
|
magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
|
|
14149
14235
|
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
14150
|
-
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
|
|
14236
|
+
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), namespaceToStringTag, snippets);
|
|
14151
14237
|
if (namespaceMarkers) {
|
|
14152
14238
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
14153
14239
|
}
|
|
@@ -14161,11 +14247,11 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
14161
14247
|
|
|
14162
14248
|
const finalisers = { amd, cjs, es, iife, system, umd };
|
|
14163
14249
|
|
|
14164
|
-
const createHash = () =>
|
|
14250
|
+
const createHash = () => node_crypto.createHash('sha256');
|
|
14165
14251
|
|
|
14166
14252
|
// Four random characters from the private use area to minimize risk of conflicts
|
|
14167
|
-
const hashPlaceholderLeft = '
|
|
14168
|
-
const hashPlaceholderRight = '
|
|
14253
|
+
const hashPlaceholderLeft = '!~{';
|
|
14254
|
+
const hashPlaceholderRight = '}~';
|
|
14169
14255
|
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
14170
14256
|
// This is the size of a sha256
|
|
14171
14257
|
const maxHashSize = 64;
|
|
@@ -14176,15 +14262,14 @@ const getHashPlaceholderGenerator = () => {
|
|
|
14176
14262
|
if (hashSize > maxHashSize) {
|
|
14177
14263
|
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14178
14264
|
}
|
|
14179
|
-
const placeholder = `${hashPlaceholderLeft}${
|
|
14265
|
+
const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
14180
14266
|
if (placeholder.length > hashSize) {
|
|
14181
14267
|
return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14182
14268
|
}
|
|
14183
|
-
nextIndex++;
|
|
14184
14269
|
return placeholder;
|
|
14185
14270
|
};
|
|
14186
14271
|
};
|
|
14187
|
-
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}
|
|
14272
|
+
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14188
14273
|
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14189
14274
|
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14190
14275
|
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
@@ -14216,7 +14301,7 @@ function makeUnique(name, existingNames) {
|
|
|
14216
14301
|
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14217
14302
|
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14218
14303
|
return name;
|
|
14219
|
-
const ext =
|
|
14304
|
+
const ext = node_path.extname(name);
|
|
14220
14305
|
name = name.substring(0, name.length - ext.length);
|
|
14221
14306
|
let uniqueName, uniqueIndex = 1;
|
|
14222
14307
|
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
@@ -14229,13 +14314,13 @@ function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
|
14229
14314
|
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
14230
14315
|
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
14231
14316
|
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
14232
|
-
ext: () =>
|
|
14233
|
-
extname: () =>
|
|
14317
|
+
ext: () => node_path.extname(emittedName).substring(1),
|
|
14318
|
+
extname: () => node_path.extname(emittedName),
|
|
14234
14319
|
hash: size => createHash()
|
|
14235
14320
|
.update(source)
|
|
14236
14321
|
.digest('hex')
|
|
14237
14322
|
.substring(0, size || defaultHashSize),
|
|
14238
|
-
name: () => emittedName.substring(0, emittedName.length -
|
|
14323
|
+
name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
|
|
14239
14324
|
}), bundle);
|
|
14240
14325
|
}
|
|
14241
14326
|
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
@@ -14530,7 +14615,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14530
14615
|
}
|
|
14531
14616
|
for (const externalModule of deconflictedDefault) {
|
|
14532
14617
|
if (deconflictedNamespace.has(externalModule) &&
|
|
14533
|
-
canDefaultBeTakenFromNamespace(
|
|
14618
|
+
canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
|
|
14534
14619
|
externalModule.defaultVariableName = externalModule.namespaceVariableName;
|
|
14535
14620
|
}
|
|
14536
14621
|
else {
|
|
@@ -14543,7 +14628,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14543
14628
|
const chunk = externalChunkByModule.get(module);
|
|
14544
14629
|
const name = variable.name;
|
|
14545
14630
|
if (name === 'default') {
|
|
14546
|
-
const moduleInterop =
|
|
14631
|
+
const moduleInterop = interop(module.id);
|
|
14547
14632
|
const variableName = defaultInteropHelpersByInteropType[moduleInterop]
|
|
14548
14633
|
? chunk.defaultVariableName
|
|
14549
14634
|
: chunk.variableName;
|
|
@@ -14555,7 +14640,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
14555
14640
|
}
|
|
14556
14641
|
}
|
|
14557
14642
|
else if (name === '*') {
|
|
14558
|
-
variable.setRenderNames(null, namespaceInteropHelpersByInteropType[
|
|
14643
|
+
variable.setRenderNames(null, namespaceInteropHelpersByInteropType[interop(module.id)]
|
|
14559
14644
|
? chunk.namespaceVariableName
|
|
14560
14645
|
: chunk.variableName);
|
|
14561
14646
|
}
|
|
@@ -14625,7 +14710,7 @@ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
|
|
|
14625
14710
|
}
|
|
14626
14711
|
}
|
|
14627
14712
|
|
|
14628
|
-
function getExportMode(chunk, { exports: exportMode, name, format },
|
|
14713
|
+
function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, warn) {
|
|
14629
14714
|
const exportKeys = chunk.getExportNames();
|
|
14630
14715
|
if (exportMode === 'default') {
|
|
14631
14716
|
if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
|
|
@@ -14640,9 +14725,6 @@ function getExportMode(chunk, { exports: exportMode, name, format }, unsetOption
|
|
|
14640
14725
|
exportMode = 'none';
|
|
14641
14726
|
}
|
|
14642
14727
|
else if (exportKeys.length === 1 && exportKeys[0] === 'default') {
|
|
14643
|
-
if (format === 'cjs' && unsetOptions.has('exports')) {
|
|
14644
|
-
warn(errPreferNamedExports(facadeModuleId));
|
|
14645
|
-
}
|
|
14646
14728
|
exportMode = 'default';
|
|
14647
14729
|
}
|
|
14648
14730
|
else {
|
|
@@ -14867,7 +14949,7 @@ class Chunk {
|
|
|
14867
14949
|
assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
|
|
14868
14950
|
}
|
|
14869
14951
|
if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
|
|
14870
|
-
this.exportMode = getExportMode(this, this.outputOptions, this.
|
|
14952
|
+
this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
|
|
14871
14953
|
}
|
|
14872
14954
|
generateFacades() {
|
|
14873
14955
|
var _a;
|
|
@@ -14968,7 +15050,7 @@ class Chunk {
|
|
|
14968
15050
|
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14969
15051
|
}
|
|
14970
15052
|
getImportPath(importer) {
|
|
14971
|
-
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd', true));
|
|
15053
|
+
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
14972
15054
|
}
|
|
14973
15055
|
getPreliminaryFileName() {
|
|
14974
15056
|
var _a;
|
|
@@ -14979,7 +15061,7 @@ class Chunk {
|
|
|
14979
15061
|
let hashPlaceholder = null;
|
|
14980
15062
|
const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
|
|
14981
15063
|
if (file) {
|
|
14982
|
-
fileName =
|
|
15064
|
+
fileName = node_path.basename(file);
|
|
14983
15065
|
}
|
|
14984
15066
|
else if (this.fileName !== null) {
|
|
14985
15067
|
fileName = this.fileName;
|
|
@@ -15047,13 +15129,31 @@ class Chunk {
|
|
|
15047
15129
|
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
15048
15130
|
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
15049
15131
|
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
15050
|
-
|
|
15051
|
-
|
|
15132
|
+
let hasExports = renderedExports.length !== 0;
|
|
15133
|
+
let hasDefaultExport = false;
|
|
15134
|
+
for (const { reexports } of renderedDependencies) {
|
|
15135
|
+
if (reexports === null || reexports === void 0 ? void 0 : reexports.length) {
|
|
15136
|
+
hasExports = true;
|
|
15137
|
+
if (reexports.some(reexport => reexport.reexported === 'default')) {
|
|
15138
|
+
hasDefaultExport = true;
|
|
15139
|
+
break;
|
|
15140
|
+
}
|
|
15141
|
+
}
|
|
15142
|
+
}
|
|
15143
|
+
if (!hasDefaultExport) {
|
|
15144
|
+
for (const { exported } of renderedExports) {
|
|
15145
|
+
if (exported === 'default') {
|
|
15146
|
+
hasDefaultExport = true;
|
|
15147
|
+
break;
|
|
15148
|
+
}
|
|
15149
|
+
}
|
|
15150
|
+
}
|
|
15052
15151
|
const { intro, outro, banner, footer } = await createAddons(outputOptions, pluginDriver, this.getRenderedChunkInfo());
|
|
15053
15152
|
finalisers[format](renderedSource, {
|
|
15054
15153
|
accessedGlobals,
|
|
15055
15154
|
dependencies: renderedDependencies,
|
|
15056
15155
|
exports: renderedExports,
|
|
15156
|
+
hasDefaultExport,
|
|
15057
15157
|
hasExports,
|
|
15058
15158
|
id: preliminaryFileName.fileName,
|
|
15059
15159
|
indent,
|
|
@@ -15214,12 +15314,12 @@ class Chunk {
|
|
|
15214
15314
|
dependencies.add(chunk);
|
|
15215
15315
|
if (addNonNamespacesAndInteropHelpers) {
|
|
15216
15316
|
if (variable.name === 'default') {
|
|
15217
|
-
if (defaultInteropHelpersByInteropType[
|
|
15317
|
+
if (defaultInteropHelpersByInteropType[interop(module.id)]) {
|
|
15218
15318
|
deconflictedDefault.add(chunk);
|
|
15219
15319
|
}
|
|
15220
15320
|
}
|
|
15221
15321
|
else if (variable.name === '*') {
|
|
15222
|
-
if (namespaceInteropHelpersByInteropType[
|
|
15322
|
+
if (namespaceInteropHelpersByInteropType[interop(module.id)]) {
|
|
15223
15323
|
deconflictedNamespace.add(chunk);
|
|
15224
15324
|
}
|
|
15225
15325
|
}
|
|
@@ -15344,17 +15444,17 @@ class Chunk {
|
|
|
15344
15444
|
return predefinedChunkName;
|
|
15345
15445
|
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
15346
15446
|
const sanitizedId = sanitizeFileName(module.id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
15347
|
-
const extName =
|
|
15447
|
+
const extName = node_path.extname(sanitizedId);
|
|
15348
15448
|
const idWithoutExtension = NON_ASSET_EXTENSIONS.includes(extName)
|
|
15349
15449
|
? sanitizedId.slice(0, -extName.length)
|
|
15350
15450
|
: sanitizedId;
|
|
15351
15451
|
if (isAbsolute(idWithoutExtension)) {
|
|
15352
|
-
return preserveModulesRoot && idWithoutExtension.startsWith(preserveModulesRoot)
|
|
15452
|
+
return preserveModulesRoot && node_path.resolve(idWithoutExtension).startsWith(preserveModulesRoot)
|
|
15353
15453
|
? idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[\\/]/, '')
|
|
15354
15454
|
: relative(this.inputBase, idWithoutExtension);
|
|
15355
15455
|
}
|
|
15356
15456
|
else {
|
|
15357
|
-
return `_virtual/${
|
|
15457
|
+
return `_virtual/${node_path.basename(idWithoutExtension)}`;
|
|
15358
15458
|
}
|
|
15359
15459
|
}
|
|
15360
15460
|
getReexportSpecifiers() {
|
|
@@ -15393,7 +15493,7 @@ class Chunk {
|
|
|
15393
15493
|
}
|
|
15394
15494
|
needsLiveBinding =
|
|
15395
15495
|
externalLiveBindings &&
|
|
15396
|
-
(imported !== 'default' || isDefaultAProperty(
|
|
15496
|
+
(imported !== 'default' || isDefaultAProperty(interop(module.id), true));
|
|
15397
15497
|
}
|
|
15398
15498
|
}
|
|
15399
15499
|
getOrCreate(reexportSpecifiers, dependency, () => []).push({
|
|
@@ -15826,7 +15926,7 @@ function commondir(files) {
|
|
|
15826
15926
|
if (files.length === 0)
|
|
15827
15927
|
return '/';
|
|
15828
15928
|
if (files.length === 1)
|
|
15829
|
-
return
|
|
15929
|
+
return node_path.dirname(files[0]);
|
|
15830
15930
|
const commonSegments = files.slice(1).reduce((commonSegments, file) => {
|
|
15831
15931
|
const pathSegements = file.split(/\/+|\\+/);
|
|
15832
15932
|
let i;
|
|
@@ -16083,9 +16183,9 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
|
|
|
16083
16183
|
else {
|
|
16084
16184
|
const sources = originalSourcemap.sources;
|
|
16085
16185
|
const sourcesContent = originalSourcemap.sourcesContent || [];
|
|
16086
|
-
const directory =
|
|
16186
|
+
const directory = node_path.dirname(id) || '.';
|
|
16087
16187
|
const sourceRoot = originalSourcemap.sourceRoot || '.';
|
|
16088
|
-
const baseSources = sources.map((source, i) => new Source(
|
|
16188
|
+
const baseSources = sources.map((source, i) => new Source(node_path.resolve(directory, sourceRoot, source), sourcesContent[i]));
|
|
16089
16189
|
source = new Link(originalSourcemap, baseSources);
|
|
16090
16190
|
}
|
|
16091
16191
|
return sourcemapChain.reduce(linkMap, source);
|
|
@@ -16099,9 +16199,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
|
|
|
16099
16199
|
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
16100
16200
|
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
16101
16201
|
if (file) {
|
|
16102
|
-
const directory =
|
|
16103
|
-
sources = sources.map((source) =>
|
|
16104
|
-
file =
|
|
16202
|
+
const directory = node_path.dirname(file);
|
|
16203
|
+
sources = sources.map((source) => node_path.relative(directory, source));
|
|
16204
|
+
file = node_path.basename(file);
|
|
16105
16205
|
}
|
|
16106
16206
|
sourcesContent = (excludeContent ? null : sourcesContent);
|
|
16107
16207
|
return new SourceMap({ file, mappings, names, sources, sourcesContent });
|
|
@@ -16142,7 +16242,7 @@ async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, o
|
|
|
16142
16242
|
const chunkGraph = getChunkGraph(chunks);
|
|
16143
16243
|
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
16144
16244
|
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle);
|
|
16145
|
-
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders);
|
|
16245
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
16146
16246
|
timeEnd('transform chunks', 2);
|
|
16147
16247
|
}
|
|
16148
16248
|
function reserveEntryChunksInBundle(chunks) {
|
|
@@ -16184,11 +16284,11 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
16184
16284
|
timeStart('sourcemaps', 3);
|
|
16185
16285
|
let file;
|
|
16186
16286
|
if (options.file)
|
|
16187
|
-
file =
|
|
16287
|
+
file = node_path.resolve(options.sourcemapFile || options.file);
|
|
16188
16288
|
else if (options.dir)
|
|
16189
|
-
file =
|
|
16289
|
+
file = node_path.resolve(options.dir, fileName);
|
|
16190
16290
|
else
|
|
16191
|
-
file =
|
|
16291
|
+
file = node_path.resolve(fileName);
|
|
16192
16292
|
const decodedMap = magicString.generateDecodedMap({});
|
|
16193
16293
|
map = collapseSourcemaps(file, decodedMap, usedModules, sourcemapChain, options.sourcemapExcludeSources, onwarn);
|
|
16194
16294
|
map.sources = map.sources
|
|
@@ -16286,22 +16386,40 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
16286
16386
|
}
|
|
16287
16387
|
return hashesByPlaceholder;
|
|
16288
16388
|
}
|
|
16289
|
-
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders) {
|
|
16389
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
16290
16390
|
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16291
|
-
|
|
16391
|
+
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16292
16392
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
16293
16393
|
if (map) {
|
|
16294
16394
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16395
|
+
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16295
16396
|
}
|
|
16296
16397
|
outputBundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16297
16398
|
}
|
|
16298
16399
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16299
|
-
|
|
16400
|
+
let updatedCode = hashesByPlaceholder.size
|
|
16300
16401
|
? replacePlaceholders(code, hashesByPlaceholder)
|
|
16301
16402
|
: code;
|
|
16403
|
+
if (map) {
|
|
16404
|
+
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16405
|
+
}
|
|
16302
16406
|
outputBundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16303
16407
|
}
|
|
16304
16408
|
}
|
|
16409
|
+
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
16410
|
+
let url;
|
|
16411
|
+
if (sourcemap === 'inline') {
|
|
16412
|
+
url = map.toUrl();
|
|
16413
|
+
}
|
|
16414
|
+
else {
|
|
16415
|
+
const sourcemapFileName = `${node_path.basename(fileName)}.map`;
|
|
16416
|
+
url = sourcemapBaseUrl
|
|
16417
|
+
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
16418
|
+
: sourcemapFileName;
|
|
16419
|
+
pluginDriver.emitFile({ fileName: `${fileName}.map`, source: map.toString(), type: 'asset' });
|
|
16420
|
+
}
|
|
16421
|
+
return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
|
|
16422
|
+
}
|
|
16305
16423
|
|
|
16306
16424
|
class Bundle {
|
|
16307
16425
|
constructor(outputOptions, unsetOptions, inputOptions, pluginDriver, graph) {
|
|
@@ -16798,10 +16916,10 @@ function getLineInfo(input, offset) {
|
|
|
16798
16916
|
var defaultOptions = {
|
|
16799
16917
|
// `ecmaVersion` indicates the ECMAScript version to parse. Must be
|
|
16800
16918
|
// either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
|
|
16801
|
-
// (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"`
|
|
16802
|
-
// latest version the library supports). This influences
|
|
16803
|
-
// for strict mode, the set of reserved words, and support
|
|
16804
|
-
// new syntax features.
|
|
16919
|
+
// (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
|
|
16920
|
+
// (the latest version the library supports). This influences
|
|
16921
|
+
// support for strict mode, the set of reserved words, and support
|
|
16922
|
+
// for new syntax features.
|
|
16805
16923
|
ecmaVersion: null,
|
|
16806
16924
|
// `sourceType` indicates the mode the code should be parsed in.
|
|
16807
16925
|
// Can be either `"script"` or `"module"`. This influences global
|
|
@@ -16835,8 +16953,9 @@ var defaultOptions = {
|
|
|
16835
16953
|
// When enabled, super identifiers are not constrained to
|
|
16836
16954
|
// appearing in methods and do not raise an error when they appear elsewhere.
|
|
16837
16955
|
allowSuperOutsideMethod: null,
|
|
16838
|
-
// When enabled, hashbang directive in the beginning of file
|
|
16839
|
-
//
|
|
16956
|
+
// When enabled, hashbang directive in the beginning of file is
|
|
16957
|
+
// allowed and treated as a line comment. Enabled by default when
|
|
16958
|
+
// `ecmaVersion` >= 2023.
|
|
16840
16959
|
allowHashBang: false,
|
|
16841
16960
|
// When `locations` is on, `loc` properties holding objects with
|
|
16842
16961
|
// `start` and `end` properties in `{line, column}` form (with
|
|
@@ -16911,6 +17030,9 @@ function getOptions(opts) {
|
|
|
16911
17030
|
if (options.allowReserved == null)
|
|
16912
17031
|
{ options.allowReserved = options.ecmaVersion < 5; }
|
|
16913
17032
|
|
|
17033
|
+
if (opts.allowHashBang == null)
|
|
17034
|
+
{ options.allowHashBang = options.ecmaVersion >= 14; }
|
|
17035
|
+
|
|
16914
17036
|
if (isArray(options.onToken)) {
|
|
16915
17037
|
var tokens = options.onToken;
|
|
16916
17038
|
options.onToken = function (token) { return tokens.push(token); };
|
|
@@ -17241,7 +17363,7 @@ pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
|
17241
17363
|
if (refDestructuringErrors.trailingComma > -1)
|
|
17242
17364
|
{ this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
|
|
17243
17365
|
var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
|
|
17244
|
-
if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
|
|
17366
|
+
if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
|
|
17245
17367
|
};
|
|
17246
17368
|
|
|
17247
17369
|
pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
|
@@ -18337,6 +18459,7 @@ pp$8.adaptDirectivePrologue = function(statements) {
|
|
|
18337
18459
|
};
|
|
18338
18460
|
pp$8.isDirectiveCandidate = function(statement) {
|
|
18339
18461
|
return (
|
|
18462
|
+
this.options.ecmaVersion >= 5 &&
|
|
18340
18463
|
statement.type === "ExpressionStatement" &&
|
|
18341
18464
|
statement.expression.type === "Literal" &&
|
|
18342
18465
|
typeof statement.expression.value === "string" &&
|
|
@@ -18747,7 +18870,8 @@ pp$6.updateContext = function(prevType) {
|
|
|
18747
18870
|
{ this.exprAllowed = type.beforeExpr; }
|
|
18748
18871
|
};
|
|
18749
18872
|
|
|
18750
|
-
// Used to handle egde
|
|
18873
|
+
// Used to handle egde cases when token context could not be inferred correctly during tokenization phase
|
|
18874
|
+
|
|
18751
18875
|
pp$6.overrideContext = function(tokenCtx) {
|
|
18752
18876
|
if (this.curContext() !== tokenCtx) {
|
|
18753
18877
|
this.context[this.context.length - 1] = tokenCtx;
|
|
@@ -19563,15 +19687,6 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
19563
19687
|
}
|
|
19564
19688
|
return this.finishNode(prop, "RestElement")
|
|
19565
19689
|
}
|
|
19566
|
-
// To disallow parenthesized identifier via `this.toAssignable()`.
|
|
19567
|
-
if (this.type === types$1.parenL && refDestructuringErrors) {
|
|
19568
|
-
if (refDestructuringErrors.parenthesizedAssign < 0) {
|
|
19569
|
-
refDestructuringErrors.parenthesizedAssign = this.start;
|
|
19570
|
-
}
|
|
19571
|
-
if (refDestructuringErrors.parenthesizedBind < 0) {
|
|
19572
|
-
refDestructuringErrors.parenthesizedBind = this.start;
|
|
19573
|
-
}
|
|
19574
|
-
}
|
|
19575
19690
|
// Parse argument.
|
|
19576
19691
|
prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
|
19577
19692
|
// To disallow trailing comma via `this.toAssignable()`.
|
|
@@ -22001,7 +22116,7 @@ pp.readWord = function() {
|
|
|
22001
22116
|
|
|
22002
22117
|
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
|
22003
22118
|
|
|
22004
|
-
var version = "8.
|
|
22119
|
+
var version = "8.8.0";
|
|
22005
22120
|
|
|
22006
22121
|
Parser.acorn = {
|
|
22007
22122
|
Parser: Parser,
|
|
@@ -22057,7 +22172,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
22057
22172
|
// absolute path is created. Absolute importees therefore shortcircuit the
|
|
22058
22173
|
// resolve call and require no special handing on our part.
|
|
22059
22174
|
// See https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
22060
|
-
return addJsExtensionIfNecessary(importer ?
|
|
22175
|
+
return addJsExtensionIfNecessary(importer ? node_path.resolve(node_path.dirname(importer), source) : node_path.resolve(source), preserveSymlinks);
|
|
22061
22176
|
}
|
|
22062
22177
|
async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
22063
22178
|
var _a, _b;
|
|
@@ -22065,13 +22180,13 @@ async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
|
22065
22180
|
}
|
|
22066
22181
|
async function findFile(file, preserveSymlinks) {
|
|
22067
22182
|
try {
|
|
22068
|
-
const stats = await
|
|
22183
|
+
const stats = await node_fs.promises.lstat(file);
|
|
22069
22184
|
if (!preserveSymlinks && stats.isSymbolicLink())
|
|
22070
|
-
return await findFile(await
|
|
22185
|
+
return await findFile(await node_fs.promises.realpath(file), preserveSymlinks);
|
|
22071
22186
|
if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
|
|
22072
22187
|
// check case
|
|
22073
|
-
const name =
|
|
22074
|
-
const files = await
|
|
22188
|
+
const name = node_path.basename(file);
|
|
22189
|
+
const files = await node_fs.promises.readdir(node_path.dirname(file));
|
|
22075
22190
|
if (files.includes(name))
|
|
22076
22191
|
return file;
|
|
22077
22192
|
}
|
|
@@ -22380,7 +22495,7 @@ class ModuleLoader {
|
|
|
22380
22495
|
async addModuleSource(id, importer, module) {
|
|
22381
22496
|
let source;
|
|
22382
22497
|
try {
|
|
22383
|
-
source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await
|
|
22498
|
+
source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await node_fs.promises.readFile(id, 'utf8')); });
|
|
22384
22499
|
}
|
|
22385
22500
|
catch (err) {
|
|
22386
22501
|
let msg = `Could not load ${id}`;
|
|
@@ -22677,8 +22792,8 @@ class ModuleLoader {
|
|
|
22677
22792
|
function normalizeRelativeExternalId(source, importer) {
|
|
22678
22793
|
return isRelative(source)
|
|
22679
22794
|
? importer
|
|
22680
|
-
?
|
|
22681
|
-
:
|
|
22795
|
+
? node_path.resolve(importer, '..', source)
|
|
22796
|
+
: node_path.resolve(source)
|
|
22682
22797
|
: source;
|
|
22683
22798
|
}
|
|
22684
22799
|
function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
|
|
@@ -22743,7 +22858,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22743
22858
|
else {
|
|
22744
22859
|
cacheInstance = getCacheForUncacheablePlugin(plugin.name);
|
|
22745
22860
|
}
|
|
22746
|
-
|
|
22861
|
+
return {
|
|
22747
22862
|
addWatchFile(id) {
|
|
22748
22863
|
if (graph.phase >= BuildPhase.GENERATE) {
|
|
22749
22864
|
return this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
@@ -22793,9 +22908,9 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22793
22908
|
options.onwarn(warning);
|
|
22794
22909
|
}
|
|
22795
22910
|
};
|
|
22796
|
-
return context;
|
|
22797
22911
|
}
|
|
22798
22912
|
|
|
22913
|
+
// This will make sure no input hook is omitted
|
|
22799
22914
|
const inputHookNames = {
|
|
22800
22915
|
buildEnd: 1,
|
|
22801
22916
|
buildStart: 1,
|
|
@@ -22815,8 +22930,9 @@ class PluginDriver {
|
|
|
22815
22930
|
constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
|
|
22816
22931
|
this.graph = graph;
|
|
22817
22932
|
this.options = options;
|
|
22818
|
-
this.unfulfilledActions = new Set();
|
|
22819
22933
|
this.pluginCache = pluginCache;
|
|
22934
|
+
this.sortedPlugins = new Map();
|
|
22935
|
+
this.unfulfilledActions = new Set();
|
|
22820
22936
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
22821
22937
|
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
22822
22938
|
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
@@ -22847,21 +22963,21 @@ class PluginDriver {
|
|
|
22847
22963
|
}
|
|
22848
22964
|
// chains, first non-null result stops and returns
|
|
22849
22965
|
hookFirst(hookName, args, replaceContext, skipped) {
|
|
22850
|
-
let promise = Promise.resolve(
|
|
22851
|
-
for (const plugin of this.
|
|
22966
|
+
let promise = Promise.resolve(null);
|
|
22967
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
22852
22968
|
if (skipped && skipped.has(plugin))
|
|
22853
22969
|
continue;
|
|
22854
22970
|
promise = promise.then(result => {
|
|
22855
22971
|
if (result != null)
|
|
22856
22972
|
return result;
|
|
22857
|
-
return this.runHook(hookName, args, plugin,
|
|
22973
|
+
return this.runHook(hookName, args, plugin, replaceContext);
|
|
22858
22974
|
});
|
|
22859
22975
|
}
|
|
22860
22976
|
return promise;
|
|
22861
22977
|
}
|
|
22862
22978
|
// chains synchronously, first non-null result stops and returns
|
|
22863
22979
|
hookFirstSync(hookName, args, replaceContext) {
|
|
22864
|
-
for (const plugin of this.
|
|
22980
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
22865
22981
|
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
22866
22982
|
if (result != null)
|
|
22867
22983
|
return result;
|
|
@@ -22869,56 +22985,58 @@ class PluginDriver {
|
|
|
22869
22985
|
return null;
|
|
22870
22986
|
}
|
|
22871
22987
|
// parallel, ignores returns
|
|
22872
|
-
hookParallel(hookName, args, replaceContext) {
|
|
22873
|
-
const
|
|
22874
|
-
for (const plugin of this.
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
|
|
22988
|
+
async hookParallel(hookName, args, replaceContext) {
|
|
22989
|
+
const parallelPromises = [];
|
|
22990
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
22991
|
+
if (plugin[hookName].sequential) {
|
|
22992
|
+
await Promise.all(parallelPromises);
|
|
22993
|
+
parallelPromises.length = 0;
|
|
22994
|
+
await this.runHook(hookName, args, plugin, replaceContext);
|
|
22995
|
+
}
|
|
22996
|
+
else {
|
|
22997
|
+
parallelPromises.push(this.runHook(hookName, args, plugin, replaceContext));
|
|
22998
|
+
}
|
|
22879
22999
|
}
|
|
22880
|
-
|
|
23000
|
+
await Promise.all(parallelPromises);
|
|
22881
23001
|
}
|
|
22882
23002
|
// chains, reduces returned value, handling the reduced value as the first hook argument
|
|
22883
23003
|
hookReduceArg0(hookName, [arg0, ...rest], reduce, replaceContext) {
|
|
22884
23004
|
let promise = Promise.resolve(arg0);
|
|
22885
|
-
for (const plugin of this.
|
|
22886
|
-
promise = promise.then(arg0 =>
|
|
22887
|
-
const args = [arg0, ...rest];
|
|
22888
|
-
const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext);
|
|
22889
|
-
if (!hookPromise)
|
|
22890
|
-
return arg0;
|
|
22891
|
-
return hookPromise.then(result => reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin));
|
|
22892
|
-
});
|
|
23005
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
23006
|
+
promise = promise.then(arg0 => this.runHook(hookName, [arg0, ...rest], plugin, replaceContext).then(result => reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin)));
|
|
22893
23007
|
}
|
|
22894
23008
|
return promise;
|
|
22895
23009
|
}
|
|
22896
23010
|
// chains synchronously, reduces returned value, handling the reduced value as the first hook argument
|
|
22897
23011
|
hookReduceArg0Sync(hookName, [arg0, ...rest], reduce, replaceContext) {
|
|
22898
|
-
for (const plugin of this.
|
|
23012
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
22899
23013
|
const args = [arg0, ...rest];
|
|
22900
23014
|
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
22901
23015
|
arg0 = reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin);
|
|
22902
23016
|
}
|
|
22903
23017
|
return arg0;
|
|
22904
23018
|
}
|
|
22905
|
-
// chains, reduces returned value to type
|
|
22906
|
-
hookReduceValue(hookName, initialValue, args,
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
}
|
|
23019
|
+
// chains, reduces returned value to type string, handling the reduced value separately. permits hooks as values.
|
|
23020
|
+
async hookReduceValue(hookName, initialValue, args, reducer) {
|
|
23021
|
+
const results = [];
|
|
23022
|
+
const parallelResults = [];
|
|
23023
|
+
for (const plugin of this.getSortedPlugins(hookName, validateAddonPluginHandler)) {
|
|
23024
|
+
if (plugin[hookName].sequential) {
|
|
23025
|
+
results.push(...(await Promise.all(parallelResults)));
|
|
23026
|
+
parallelResults.length = 0;
|
|
23027
|
+
results.push(await this.runHook(hookName, args, plugin));
|
|
23028
|
+
}
|
|
23029
|
+
else {
|
|
23030
|
+
parallelResults.push(this.runHook(hookName, args, plugin));
|
|
23031
|
+
}
|
|
22915
23032
|
}
|
|
22916
|
-
|
|
23033
|
+
results.push(...(await Promise.all(parallelResults)));
|
|
23034
|
+
return results.reduce(reducer, await initialValue);
|
|
22917
23035
|
}
|
|
22918
23036
|
// chains synchronously, reduces returned value to type T, handling the reduced value separately. permits hooks as values.
|
|
22919
23037
|
hookReduceValueSync(hookName, initialValue, args, reduce, replaceContext) {
|
|
22920
23038
|
let acc = initialValue;
|
|
22921
|
-
for (const plugin of this.
|
|
23039
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
22922
23040
|
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
22923
23041
|
acc = reduce.call(this.pluginContexts.get(plugin), acc, result, plugin);
|
|
22924
23042
|
}
|
|
@@ -22927,31 +23045,32 @@ class PluginDriver {
|
|
|
22927
23045
|
// chains, ignores returns
|
|
22928
23046
|
hookSeq(hookName, args, replaceContext) {
|
|
22929
23047
|
let promise = Promise.resolve();
|
|
22930
|
-
for (const plugin of this.
|
|
22931
|
-
promise = promise.then(() => this.runHook(hookName, args, plugin,
|
|
23048
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
23049
|
+
promise = promise.then(() => this.runHook(hookName, args, plugin, replaceContext));
|
|
22932
23050
|
}
|
|
22933
|
-
return promise;
|
|
23051
|
+
return promise.then(noReturn);
|
|
22934
23052
|
}
|
|
22935
|
-
|
|
23053
|
+
getSortedPlugins(hookName, validateHandler) {
|
|
23054
|
+
return getOrCreate(this.sortedPlugins, hookName, () => getSortedValidatedPlugins(hookName, this.plugins, validateHandler));
|
|
23055
|
+
}
|
|
23056
|
+
// Implementation signature
|
|
23057
|
+
runHook(hookName, args, plugin, replaceContext) {
|
|
23058
|
+
// We always filter for plugins that support the hook before running it
|
|
22936
23059
|
const hook = plugin[hookName];
|
|
22937
|
-
|
|
22938
|
-
return undefined;
|
|
23060
|
+
const handler = typeof hook === 'object' ? hook.handler : hook;
|
|
22939
23061
|
let context = this.pluginContexts.get(plugin);
|
|
22940
|
-
if (
|
|
22941
|
-
context =
|
|
23062
|
+
if (replaceContext) {
|
|
23063
|
+
context = replaceContext(context, plugin);
|
|
22942
23064
|
}
|
|
22943
23065
|
let action = null;
|
|
22944
23066
|
return Promise.resolve()
|
|
22945
23067
|
.then(() => {
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
if (permitValues)
|
|
22949
|
-
return hook;
|
|
22950
|
-
return error(errInvalidPluginHook(hookName, plugin.name));
|
|
23068
|
+
if (typeof handler !== 'function') {
|
|
23069
|
+
return handler;
|
|
22951
23070
|
}
|
|
22952
23071
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22953
|
-
const hookResult =
|
|
22954
|
-
if (!hookResult ||
|
|
23072
|
+
const hookResult = handler.apply(context, args);
|
|
23073
|
+
if (!(hookResult === null || hookResult === void 0 ? void 0 : hookResult.then)) {
|
|
22955
23074
|
// short circuit for non-thenables and non-Promises
|
|
22956
23075
|
return hookResult;
|
|
22957
23076
|
}
|
|
@@ -22984,29 +23103,61 @@ class PluginDriver {
|
|
|
22984
23103
|
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
22985
23104
|
* @param args Arguments passed to the plugin hook.
|
|
22986
23105
|
* @param plugin The acutal plugin
|
|
22987
|
-
* @param
|
|
23106
|
+
* @param replaceContext When passed, the plugin context can be overridden.
|
|
22988
23107
|
*/
|
|
22989
|
-
runHookSync(hookName, args, plugin,
|
|
23108
|
+
runHookSync(hookName, args, plugin, replaceContext) {
|
|
22990
23109
|
const hook = plugin[hookName];
|
|
22991
|
-
|
|
22992
|
-
return undefined;
|
|
23110
|
+
const handler = typeof hook === 'object' ? hook.handler : hook;
|
|
22993
23111
|
let context = this.pluginContexts.get(plugin);
|
|
22994
|
-
if (
|
|
22995
|
-
context =
|
|
23112
|
+
if (replaceContext) {
|
|
23113
|
+
context = replaceContext(context, plugin);
|
|
22996
23114
|
}
|
|
22997
23115
|
try {
|
|
22998
|
-
// permit values allows values to be returned instead of a functional hook
|
|
22999
|
-
if (typeof hook !== 'function') {
|
|
23000
|
-
return error(errInvalidPluginHook(hookName, plugin.name));
|
|
23001
|
-
}
|
|
23002
23116
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
23003
|
-
return
|
|
23117
|
+
return handler.apply(context, args);
|
|
23004
23118
|
}
|
|
23005
23119
|
catch (err) {
|
|
23006
23120
|
return error(errPluginError(err, plugin.name, { hook: hookName }));
|
|
23007
23121
|
}
|
|
23008
23122
|
}
|
|
23009
23123
|
}
|
|
23124
|
+
function getSortedValidatedPlugins(hookName, plugins, validateHandler = validateFunctionPluginHandler) {
|
|
23125
|
+
const pre = [];
|
|
23126
|
+
const normal = [];
|
|
23127
|
+
const post = [];
|
|
23128
|
+
for (const plugin of plugins) {
|
|
23129
|
+
const hook = plugin[hookName];
|
|
23130
|
+
if (hook) {
|
|
23131
|
+
if (typeof hook === 'object') {
|
|
23132
|
+
validateHandler(hook.handler, hookName, plugin);
|
|
23133
|
+
if (hook.order === 'pre') {
|
|
23134
|
+
pre.push(plugin);
|
|
23135
|
+
continue;
|
|
23136
|
+
}
|
|
23137
|
+
if (hook.order === 'post') {
|
|
23138
|
+
post.push(plugin);
|
|
23139
|
+
continue;
|
|
23140
|
+
}
|
|
23141
|
+
}
|
|
23142
|
+
else {
|
|
23143
|
+
validateHandler(hook, hookName, plugin);
|
|
23144
|
+
}
|
|
23145
|
+
normal.push(plugin);
|
|
23146
|
+
}
|
|
23147
|
+
}
|
|
23148
|
+
return [...pre, ...normal, ...post];
|
|
23149
|
+
}
|
|
23150
|
+
function validateFunctionPluginHandler(handler, hookName, plugin) {
|
|
23151
|
+
if (typeof handler !== 'function') {
|
|
23152
|
+
error(errInvalidFunctionPluginHook(hookName, plugin.name));
|
|
23153
|
+
}
|
|
23154
|
+
}
|
|
23155
|
+
function validateAddonPluginHandler(handler, hookName, plugin) {
|
|
23156
|
+
if (typeof handler !== 'string' && typeof handler !== 'function') {
|
|
23157
|
+
return error(errInvalidAddonPluginHook(hookName, plugin.name));
|
|
23158
|
+
}
|
|
23159
|
+
}
|
|
23160
|
+
function noReturn() { }
|
|
23010
23161
|
|
|
23011
23162
|
class Queue {
|
|
23012
23163
|
constructor(maxParallel) {
|
|
@@ -23096,8 +23247,8 @@ class Graph {
|
|
|
23096
23247
|
this.watchMode = true;
|
|
23097
23248
|
const handleChange = (...args) => this.pluginDriver.hookParallel('watchChange', args);
|
|
23098
23249
|
const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []);
|
|
23099
|
-
watcher.
|
|
23100
|
-
watcher.
|
|
23250
|
+
watcher.onCurrentRun('change', handleChange);
|
|
23251
|
+
watcher.onCurrentRun('close', handleClose);
|
|
23101
23252
|
}
|
|
23102
23253
|
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
|
|
23103
23254
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
@@ -23263,7 +23414,7 @@ function formatAction([pluginName, hookName, args]) {
|
|
|
23263
23414
|
// We do not directly listen on process to avoid max listeners warnings for
|
|
23264
23415
|
// complicated build processes
|
|
23265
23416
|
const beforeExitEvent = 'beforeExit';
|
|
23266
|
-
const beforeExitEmitter = new
|
|
23417
|
+
const beforeExitEmitter = new node_events.EventEmitter();
|
|
23267
23418
|
beforeExitEmitter.setMaxListeners(0);
|
|
23268
23419
|
process$1.on(beforeExitEvent, () => beforeExitEmitter.emit(beforeExitEvent));
|
|
23269
23420
|
async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
@@ -23405,7 +23556,7 @@ const getModuleContext = (config, context) => {
|
|
|
23405
23556
|
if (configModuleContext) {
|
|
23406
23557
|
const contextByModuleId = Object.create(null);
|
|
23407
23558
|
for (const [key, moduleContext] of Object.entries(configModuleContext)) {
|
|
23408
|
-
contextByModuleId[
|
|
23559
|
+
contextByModuleId[node_path.resolve(key)] = moduleContext;
|
|
23409
23560
|
}
|
|
23410
23561
|
return id => contextByModuleId[id] || context;
|
|
23411
23562
|
}
|
|
@@ -23498,7 +23649,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23498
23649
|
dir: getDir(config, file),
|
|
23499
23650
|
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
23500
23651
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23501
|
-
esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c :
|
|
23652
|
+
esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : 'if-default-prop',
|
|
23502
23653
|
exports: getExports(config, unsetOptions),
|
|
23503
23654
|
extend: config.extend || false,
|
|
23504
23655
|
externalLiveBindings: (_d = config.externalLiveBindings) !== null && _d !== void 0 ? _d : true,
|
|
@@ -23511,7 +23662,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23511
23662
|
hoistTransitiveImports: (_f = config.hoistTransitiveImports) !== null && _f !== void 0 ? _f : true,
|
|
23512
23663
|
indent: getIndent(config, compact),
|
|
23513
23664
|
inlineDynamicImports,
|
|
23514
|
-
interop: getInterop(config
|
|
23665
|
+
interop: getInterop(config),
|
|
23515
23666
|
intro: getAddon(config, 'intro'),
|
|
23516
23667
|
manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules, inputOptions),
|
|
23517
23668
|
minifyInternalExports: getMinifyInternalExports(config, format, compact),
|
|
@@ -23611,13 +23762,14 @@ const getPreserveModulesRoot = (config) => {
|
|
|
23611
23762
|
if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
|
|
23612
23763
|
return undefined;
|
|
23613
23764
|
}
|
|
23614
|
-
return
|
|
23765
|
+
return node_path.resolve(preserveModulesRoot);
|
|
23615
23766
|
};
|
|
23616
23767
|
const getAmd = (config) => {
|
|
23617
23768
|
const mergedOption = {
|
|
23618
23769
|
autoId: false,
|
|
23619
23770
|
basePath: '',
|
|
23620
23771
|
define: 'define',
|
|
23772
|
+
forceJsExtensionForImports: false,
|
|
23621
23773
|
...config.amd
|
|
23622
23774
|
};
|
|
23623
23775
|
if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
|
|
@@ -23631,13 +23783,15 @@ const getAmd = (config) => {
|
|
|
23631
23783
|
normalized = {
|
|
23632
23784
|
autoId: true,
|
|
23633
23785
|
basePath: mergedOption.basePath,
|
|
23634
|
-
define: mergedOption.define
|
|
23786
|
+
define: mergedOption.define,
|
|
23787
|
+
forceJsExtensionForImports: mergedOption.forceJsExtensionForImports
|
|
23635
23788
|
};
|
|
23636
23789
|
}
|
|
23637
23790
|
else {
|
|
23638
23791
|
normalized = {
|
|
23639
23792
|
autoId: false,
|
|
23640
23793
|
define: mergedOption.define,
|
|
23794
|
+
forceJsExtensionForImports: mergedOption.forceJsExtensionForImports,
|
|
23641
23795
|
id: mergedOption.id
|
|
23642
23796
|
};
|
|
23643
23797
|
}
|
|
@@ -23702,28 +23856,17 @@ const getIndent = (config, compact) => {
|
|
|
23702
23856
|
return configIndent === false ? '' : configIndent !== null && configIndent !== void 0 ? configIndent : true;
|
|
23703
23857
|
};
|
|
23704
23858
|
const ALLOWED_INTEROP_TYPES = new Set([
|
|
23859
|
+
'compat',
|
|
23705
23860
|
'auto',
|
|
23706
23861
|
'esModule',
|
|
23707
23862
|
'default',
|
|
23708
|
-
'defaultOnly'
|
|
23709
|
-
true,
|
|
23710
|
-
false
|
|
23863
|
+
'defaultOnly'
|
|
23711
23864
|
]);
|
|
23712
|
-
const getInterop = (config
|
|
23865
|
+
const getInterop = (config) => {
|
|
23713
23866
|
const configInterop = config.interop;
|
|
23714
|
-
const validatedInteropTypes = new Set();
|
|
23715
23867
|
const validateInterop = (interop) => {
|
|
23716
|
-
if (!
|
|
23717
|
-
|
|
23718
|
-
if (!ALLOWED_INTEROP_TYPES.has(interop)) {
|
|
23719
|
-
return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
|
|
23720
|
-
}
|
|
23721
|
-
if (typeof interop === 'boolean') {
|
|
23722
|
-
warnDeprecation({
|
|
23723
|
-
message: `The boolean value "${interop}" for the "output.interop" option is deprecated. Use ${interop ? '"auto"' : '"esModule", "default" or "defaultOnly"'} instead.`,
|
|
23724
|
-
url: 'https://rollupjs.org/guide/en/#outputinterop'
|
|
23725
|
-
}, true, inputOptions);
|
|
23726
|
-
}
|
|
23868
|
+
if (!ALLOWED_INTEROP_TYPES.has(interop)) {
|
|
23869
|
+
return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
|
|
23727
23870
|
}
|
|
23728
23871
|
return interop;
|
|
23729
23872
|
};
|
|
@@ -23736,7 +23879,7 @@ const getInterop = (config, inputOptions) => {
|
|
|
23736
23879
|
? interopPerId[id]
|
|
23737
23880
|
: validateInterop((interopPerId[id] = configInterop(id)));
|
|
23738
23881
|
}
|
|
23739
|
-
return configInterop === undefined ? () =>
|
|
23882
|
+
return configInterop === undefined ? () => 'default' : () => validateInterop(configInterop);
|
|
23740
23883
|
};
|
|
23741
23884
|
const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOptions) => {
|
|
23742
23885
|
const configManualChunks = config.manualChunks || inputOptions.manualChunks;
|
|
@@ -23829,17 +23972,15 @@ async function getInputOptions(rawInputOptions, watchMode) {
|
|
|
23829
23972
|
if (!rawInputOptions) {
|
|
23830
23973
|
throw new Error('You must supply an options object to rollup');
|
|
23831
23974
|
}
|
|
23832
|
-
const rawPlugins = ensureArray$1(rawInputOptions.plugins);
|
|
23975
|
+
const rawPlugins = getSortedValidatedPlugins('options', ensureArray$1(rawInputOptions.plugins));
|
|
23833
23976
|
const { options, unsetOptions } = normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
|
|
23834
23977
|
normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
|
|
23835
23978
|
return { options, unsetOptions };
|
|
23836
23979
|
}
|
|
23837
23980
|
function applyOptionHook(watchMode) {
|
|
23838
23981
|
return async (inputOptions, plugin) => {
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
}
|
|
23842
|
-
return inputOptions;
|
|
23982
|
+
const handler = 'handler' in plugin.options ? plugin.options.handler : plugin.options;
|
|
23983
|
+
return ((await handler.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) || inputOptions);
|
|
23843
23984
|
};
|
|
23844
23985
|
}
|
|
23845
23986
|
function normalizePlugins(plugins, anonymousPrefix) {
|
|
@@ -23915,35 +24056,10 @@ function getSortingFileType(file) {
|
|
|
23915
24056
|
return SortingFileType.SECONDARY_CHUNK;
|
|
23916
24057
|
}
|
|
23917
24058
|
async function writeOutputFile(outputFile, outputOptions) {
|
|
23918
|
-
const fileName =
|
|
24059
|
+
const fileName = node_path.resolve(outputOptions.dir || node_path.dirname(outputOptions.file), outputFile.fileName);
|
|
23919
24060
|
// 'recursive: true' does not throw if the folder structure, or parts of it, already exist
|
|
23920
|
-
await
|
|
23921
|
-
|
|
23922
|
-
let source;
|
|
23923
|
-
if (outputFile.type === 'asset') {
|
|
23924
|
-
source = outputFile.source;
|
|
23925
|
-
}
|
|
23926
|
-
else {
|
|
23927
|
-
source = outputFile.code;
|
|
23928
|
-
if (outputOptions.sourcemap && outputFile.map) {
|
|
23929
|
-
let url;
|
|
23930
|
-
if (outputOptions.sourcemap === 'inline') {
|
|
23931
|
-
url = outputFile.map.toUrl();
|
|
23932
|
-
}
|
|
23933
|
-
else {
|
|
23934
|
-
const { sourcemapBaseUrl } = outputOptions;
|
|
23935
|
-
const sourcemapFileName = `${require$$0.basename(outputFile.fileName)}.map`;
|
|
23936
|
-
url = sourcemapBaseUrl
|
|
23937
|
-
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
23938
|
-
: sourcemapFileName;
|
|
23939
|
-
writeSourceMapPromise = require$$0$1.promises.writeFile(`${fileName}.map`, outputFile.map.toString());
|
|
23940
|
-
}
|
|
23941
|
-
if (outputOptions.sourcemap !== 'hidden') {
|
|
23942
|
-
source += `//# ${exports.SOURCEMAPPING_URL}=${url}\n`;
|
|
23943
|
-
}
|
|
23944
|
-
}
|
|
23945
|
-
}
|
|
23946
|
-
return Promise.all([require$$0$1.promises.writeFile(fileName, source), writeSourceMapPromise]);
|
|
24061
|
+
await node_fs.promises.mkdir(node_path.dirname(fileName), { recursive: true });
|
|
24062
|
+
return node_fs.promises.writeFile(fileName, outputFile.type === 'asset' ? outputFile.source : outputFile.code);
|
|
23947
24063
|
}
|
|
23948
24064
|
/**
|
|
23949
24065
|
* Auxiliary function for defining rollup configuration
|
|
@@ -23954,30 +24070,58 @@ function defineConfig(options) {
|
|
|
23954
24070
|
return options;
|
|
23955
24071
|
}
|
|
23956
24072
|
|
|
23957
|
-
class WatchEmitter
|
|
24073
|
+
class WatchEmitter {
|
|
23958
24074
|
constructor() {
|
|
23959
|
-
|
|
23960
|
-
this.
|
|
23961
|
-
// Allows more than 10 bundles to be watched without
|
|
23962
|
-
// showing the `MaxListenersExceededWarning` to the user.
|
|
23963
|
-
this.setMaxListeners(Infinity);
|
|
24075
|
+
this.currentHandlers = Object.create(null);
|
|
24076
|
+
this.persistentHandlers = Object.create(null);
|
|
23964
24077
|
}
|
|
23965
24078
|
// Will be overwritten by Rollup
|
|
23966
24079
|
async close() { }
|
|
23967
|
-
|
|
23968
|
-
this.
|
|
23969
|
-
|
|
24080
|
+
emit(event, ...args) {
|
|
24081
|
+
return Promise.all(this.getCurrentHandlers(event)
|
|
24082
|
+
.concat(this.getPersistentHandlers(event))
|
|
24083
|
+
.map(handler => handler(...args)));
|
|
24084
|
+
}
|
|
24085
|
+
off(event, listener) {
|
|
24086
|
+
const listeners = this.persistentHandlers[event];
|
|
24087
|
+
if (listeners) {
|
|
24088
|
+
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
24089
|
+
// (which would remove the last array element if used unchanged) is turned
|
|
24090
|
+
// into max_int, which is outside the array and does not change anything.
|
|
24091
|
+
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
24092
|
+
}
|
|
24093
|
+
return this;
|
|
23970
24094
|
}
|
|
23971
|
-
|
|
23972
|
-
this.
|
|
24095
|
+
on(event, listener) {
|
|
24096
|
+
this.getPersistentHandlers(event).push(listener);
|
|
23973
24097
|
return this;
|
|
23974
24098
|
}
|
|
23975
|
-
|
|
23976
|
-
this.
|
|
24099
|
+
onCurrentRun(event, listener) {
|
|
24100
|
+
this.getCurrentHandlers(event).push(listener);
|
|
23977
24101
|
return this;
|
|
23978
24102
|
}
|
|
23979
|
-
|
|
23980
|
-
|
|
24103
|
+
once(event, listener) {
|
|
24104
|
+
const selfRemovingListener = (...args) => {
|
|
24105
|
+
this.off(event, selfRemovingListener);
|
|
24106
|
+
return listener(...args);
|
|
24107
|
+
};
|
|
24108
|
+
this.on(event, selfRemovingListener);
|
|
24109
|
+
return this;
|
|
24110
|
+
}
|
|
24111
|
+
removeAllListeners() {
|
|
24112
|
+
this.removeListenersForCurrentRun();
|
|
24113
|
+
this.persistentHandlers = Object.create(null);
|
|
24114
|
+
return this;
|
|
24115
|
+
}
|
|
24116
|
+
removeListenersForCurrentRun() {
|
|
24117
|
+
this.currentHandlers = Object.create(null);
|
|
24118
|
+
return this;
|
|
24119
|
+
}
|
|
24120
|
+
getCurrentHandlers(event) {
|
|
24121
|
+
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
24122
|
+
}
|
|
24123
|
+
getPersistentHandlers(event) {
|
|
24124
|
+
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
23981
24125
|
}
|
|
23982
24126
|
}
|
|
23983
24127
|
|
|
@@ -23999,12 +24143,14 @@ exports.createFilter = createFilter;
|
|
|
23999
24143
|
exports.defaultOnWarn = defaultOnWarn;
|
|
24000
24144
|
exports.defineConfig = defineConfig;
|
|
24001
24145
|
exports.ensureArray = ensureArray$1;
|
|
24146
|
+
exports.errCannotBundleConfigAsEsm = errCannotBundleConfigAsEsm;
|
|
24147
|
+
exports.errCannotLoadConfigAsCjs = errCannotLoadConfigAsCjs;
|
|
24148
|
+
exports.errCannotLoadConfigAsEsm = errCannotLoadConfigAsEsm;
|
|
24002
24149
|
exports.errDuplicateImportOptions = errDuplicateImportOptions;
|
|
24003
24150
|
exports.errFailAfterWarnings = errFailAfterWarnings;
|
|
24004
24151
|
exports.errMissingConfig = errMissingConfig;
|
|
24005
24152
|
exports.errMissingExternalConfig = errMissingExternalConfig;
|
|
24006
24153
|
exports.errOnlyInlineSourcemapsForStdout = errOnlyInlineSourcemapsForStdout;
|
|
24007
|
-
exports.errTranspiledEsmConfig = errTranspiledEsmConfig;
|
|
24008
24154
|
exports.error = error;
|
|
24009
24155
|
exports.fseventsImporter = fseventsImporter;
|
|
24010
24156
|
exports.generatedCodePresets = generatedCodePresets;
|