rollup 3.0.0-6 → 3.0.0-8
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/LICENSE.md +7 -0
- package/dist/bin/rollup +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +1235 -760
- package/dist/es/shared/watch.js +7 -6
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +14 -11
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +6 -10
- package/dist/shared/mergeOptions.js +6 -4
- package/dist/shared/rollup.js +1240 -776
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +3 -4
- package/package.json +22 -21
- package/CHANGELOG.md +0 -6748
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.0.0-
|
|
4
|
-
Tue,
|
|
3
|
+
Rollup.js v3.0.0-7
|
|
4
|
+
Tue, 11 Oct 2022 04:31:14 GMT - commit d9237e8c942d96e21de8f275df8d7c9aa2f620f4
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
10
|
import { resolve, basename, extname, dirname, relative as relative$1 } from 'node:path';
|
|
11
|
-
import require$$0, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
|
|
11
|
+
import require$$0$1, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
|
|
12
12
|
import process$1 from 'node:process';
|
|
13
13
|
import { performance } from 'node:perf_hooks';
|
|
14
14
|
import { createHash as createHash$1 } from 'node:crypto';
|
|
15
15
|
import { promises } from 'node:fs';
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
|
|
18
|
-
var version$1 = "3.0.0-
|
|
18
|
+
var version$1 = "3.0.0-7";
|
|
19
19
|
|
|
20
20
|
var charToInteger = {};
|
|
21
21
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -166,11 +166,10 @@ class Chunk$1 {
|
|
|
166
166
|
this.storeName = false;
|
|
167
167
|
this.edited = false;
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
169
|
+
{
|
|
170
|
+
this.previous = null;
|
|
171
|
+
this.next = null;
|
|
172
|
+
}
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
appendLeft(content) {
|
|
@@ -813,6 +812,11 @@ class MagicString {
|
|
|
813
812
|
}
|
|
814
813
|
|
|
815
814
|
overwrite(start, end, content, options) {
|
|
815
|
+
options = options || {};
|
|
816
|
+
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
update(start, end, content, options) {
|
|
816
820
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
817
821
|
|
|
818
822
|
while (start < 0) start += this.original.length;
|
|
@@ -838,7 +842,7 @@ class MagicString {
|
|
|
838
842
|
options = { storeName: true };
|
|
839
843
|
}
|
|
840
844
|
const storeName = options !== undefined ? options.storeName : false;
|
|
841
|
-
const
|
|
845
|
+
const overwrite = options !== undefined ? options.overwrite : false;
|
|
842
846
|
|
|
843
847
|
if (storeName) {
|
|
844
848
|
const original = this.original.slice(start, end);
|
|
@@ -862,7 +866,7 @@ class MagicString {
|
|
|
862
866
|
chunk.edit('', false);
|
|
863
867
|
}
|
|
864
868
|
|
|
865
|
-
first.edit(content, storeName,
|
|
869
|
+
first.edit(content, storeName, !overwrite);
|
|
866
870
|
} else {
|
|
867
871
|
// must be inserting at the end
|
|
868
872
|
const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
|
|
@@ -1181,7 +1185,7 @@ class MagicString {
|
|
|
1181
1185
|
return this.original !== this.toString();
|
|
1182
1186
|
}
|
|
1183
1187
|
|
|
1184
|
-
|
|
1188
|
+
_replaceRegexp(searchValue, replacement) {
|
|
1185
1189
|
function getReplacement(match, str) {
|
|
1186
1190
|
if (typeof replacement === 'string') {
|
|
1187
1191
|
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
@@ -1204,7 +1208,7 @@ class MagicString {
|
|
|
1204
1208
|
}
|
|
1205
1209
|
return matches;
|
|
1206
1210
|
}
|
|
1207
|
-
if (
|
|
1211
|
+
if (searchValue.global) {
|
|
1208
1212
|
const matches = matchAll(searchValue, this.original);
|
|
1209
1213
|
matches.forEach((match) => {
|
|
1210
1214
|
if (match.index != null)
|
|
@@ -1225,6 +1229,53 @@ class MagicString {
|
|
|
1225
1229
|
}
|
|
1226
1230
|
return this;
|
|
1227
1231
|
}
|
|
1232
|
+
|
|
1233
|
+
_replaceString(string, replacement) {
|
|
1234
|
+
const { original } = this;
|
|
1235
|
+
const index = original.indexOf(string);
|
|
1236
|
+
|
|
1237
|
+
if (index !== -1) {
|
|
1238
|
+
this.overwrite(index, index + string.length, replacement);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
replace(searchValue, replacement) {
|
|
1245
|
+
if (typeof searchValue === 'string') {
|
|
1246
|
+
return this._replaceString(searchValue, replacement);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
_replaceAllString(string, replacement) {
|
|
1253
|
+
const { original } = this;
|
|
1254
|
+
const stringLength = string.length;
|
|
1255
|
+
for (
|
|
1256
|
+
let index = original.indexOf(string);
|
|
1257
|
+
index !== -1;
|
|
1258
|
+
index = original.indexOf(string, index + stringLength)
|
|
1259
|
+
) {
|
|
1260
|
+
this.overwrite(index, index + stringLength, replacement);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
return this;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
replaceAll(searchValue, replacement) {
|
|
1267
|
+
if (typeof searchValue === 'string') {
|
|
1268
|
+
return this._replaceAllString(searchValue, replacement);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
if (!searchValue.global) {
|
|
1272
|
+
throw new TypeError(
|
|
1273
|
+
'MagicString.prototype.replaceAll called with a non-global RegExp argument'
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1278
|
+
}
|
|
1228
1279
|
}
|
|
1229
1280
|
|
|
1230
1281
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -1593,7 +1644,9 @@ class ExternalChunk {
|
|
|
1593
1644
|
this.namespaceVariableName = '';
|
|
1594
1645
|
this.variableName = '';
|
|
1595
1646
|
this.fileName = null;
|
|
1647
|
+
this.importAssertions = null;
|
|
1596
1648
|
this.id = module.id;
|
|
1649
|
+
this.moduleInfo = module.info;
|
|
1597
1650
|
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
1598
1651
|
this.suggestedVariableName = module.suggestedVariableName;
|
|
1599
1652
|
}
|
|
@@ -1606,12 +1659,27 @@ class ExternalChunk {
|
|
|
1606
1659
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
1607
1660
|
(this.renormalizeRenderPath ? normalize(relative$1(this.inputBase, this.id)) : this.id));
|
|
1608
1661
|
}
|
|
1662
|
+
getImportAssertions(snippets) {
|
|
1663
|
+
return (this.importAssertions || (this.importAssertions = formatAssertions$1(this.options.format === 'es' &&
|
|
1664
|
+
this.options.externalImportAssertions &&
|
|
1665
|
+
this.moduleInfo.assertions, snippets)));
|
|
1666
|
+
}
|
|
1609
1667
|
getImportPath(importer) {
|
|
1610
1668
|
return escapeId(this.renormalizeRenderPath
|
|
1611
1669
|
? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
|
|
1612
1670
|
: this.getFileName());
|
|
1613
1671
|
}
|
|
1614
1672
|
}
|
|
1673
|
+
function formatAssertions$1(assertions, { getObject }) {
|
|
1674
|
+
if (!assertions) {
|
|
1675
|
+
return null;
|
|
1676
|
+
}
|
|
1677
|
+
const assertionEntries = Object.entries(assertions).map(([key, value]) => [key, `'${value}'`]);
|
|
1678
|
+
if (assertionEntries.length) {
|
|
1679
|
+
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
1680
|
+
}
|
|
1681
|
+
return null;
|
|
1682
|
+
}
|
|
1615
1683
|
|
|
1616
1684
|
function getOrCreate(map, key, init) {
|
|
1617
1685
|
const existing = map.get(key);
|
|
@@ -1936,7 +2004,7 @@ function augmentCodeLocation(props, pos, source, id) {
|
|
|
1936
2004
|
}
|
|
1937
2005
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
1938
2006
|
// error code below
|
|
1939
|
-
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_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', 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_EXPORT = 'MISSING_EXPORT', 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', 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';
|
|
2007
|
+
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_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', 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_EXPORT = 'MISSING_EXPORT', 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', 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';
|
|
1940
2008
|
function errAddonNotGenerated(message, hook, plugin) {
|
|
1941
2009
|
return {
|
|
1942
2010
|
code: ADDON_ERROR,
|
|
@@ -2103,6 +2171,18 @@ function errIllegalImportReassignment(name, importingId) {
|
|
|
2103
2171
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
2104
2172
|
};
|
|
2105
2173
|
}
|
|
2174
|
+
function errInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
|
|
2175
|
+
return {
|
|
2176
|
+
code: INCONSISTENT_IMPORT_ASSERTIONS,
|
|
2177
|
+
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAssertions(newAssertions)} assertions, but it was already imported elsewhere with ${formatAssertions(existingAssertions)} assertions. Please ensure that import assertions for the same module are always consistent.`
|
|
2178
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
const formatAssertions = (assertions) => {
|
|
2181
|
+
const entries = Object.entries(assertions);
|
|
2182
|
+
if (entries.length === 0)
|
|
2183
|
+
return 'no';
|
|
2184
|
+
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
2185
|
+
};
|
|
2106
2186
|
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
2107
2187
|
return {
|
|
2108
2188
|
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
@@ -2510,7 +2590,7 @@ function makeLegal(str) {
|
|
|
2510
2590
|
}
|
|
2511
2591
|
|
|
2512
2592
|
class ExternalModule {
|
|
2513
|
-
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath) {
|
|
2593
|
+
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, assertions) {
|
|
2514
2594
|
this.options = options;
|
|
2515
2595
|
this.id = id;
|
|
2516
2596
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
@@ -2526,6 +2606,7 @@ class ExternalModule {
|
|
|
2526
2606
|
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2527
2607
|
const { importers, dynamicImporters } = this;
|
|
2528
2608
|
const info = (this.info = {
|
|
2609
|
+
assertions,
|
|
2529
2610
|
ast: null,
|
|
2530
2611
|
code: null,
|
|
2531
2612
|
dynamicallyImportedIdResolutions: EMPTY_ARRAY,
|
|
@@ -2568,8 +2649,7 @@ class ExternalModule {
|
|
|
2568
2649
|
return [externalVariable];
|
|
2569
2650
|
}
|
|
2570
2651
|
suggestName(name) {
|
|
2571
|
-
|
|
2572
|
-
const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
2652
|
+
const value = (this.nameSuggestions.get(name) ?? 0) + 1;
|
|
2573
2653
|
this.nameSuggestions.set(name, value);
|
|
2574
2654
|
if (value > this.mostCommonSuggestion) {
|
|
2575
2655
|
this.mostCommonSuggestion = value;
|
|
@@ -2622,7 +2702,7 @@ var picomatch$1 = {exports: {}};
|
|
|
2622
2702
|
|
|
2623
2703
|
var utils$3 = {};
|
|
2624
2704
|
|
|
2625
|
-
const path$1 = require$$0;
|
|
2705
|
+
const path$1 = require$$0$1;
|
|
2626
2706
|
const WIN_SLASH = '\\\\/';
|
|
2627
2707
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2628
2708
|
|
|
@@ -2802,7 +2882,7 @@ var constants$2 = {
|
|
|
2802
2882
|
|
|
2803
2883
|
(function (exports) {
|
|
2804
2884
|
|
|
2805
|
-
const path = require$$0;
|
|
2885
|
+
const path = require$$0$1;
|
|
2806
2886
|
const win32 = process.platform === 'win32';
|
|
2807
2887
|
const {
|
|
2808
2888
|
REGEX_BACKSLASH,
|
|
@@ -3301,7 +3381,7 @@ const syntaxError = (type, char) => {
|
|
|
3301
3381
|
* @return {Object}
|
|
3302
3382
|
*/
|
|
3303
3383
|
|
|
3304
|
-
const parse$
|
|
3384
|
+
const parse$2 = (input, options) => {
|
|
3305
3385
|
if (typeof input !== 'string') {
|
|
3306
3386
|
throw new TypeError('Expected a string');
|
|
3307
3387
|
}
|
|
@@ -3504,7 +3584,7 @@ const parse$1 = (input, options) => {
|
|
|
3504
3584
|
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
3505
3585
|
//
|
|
3506
3586
|
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
3507
|
-
const expression = parse$
|
|
3587
|
+
const expression = parse$2(rest, { ...options, fastpaths: false }).output;
|
|
3508
3588
|
|
|
3509
3589
|
output = token.close = `)${expression})${extglobStar})`;
|
|
3510
3590
|
}
|
|
@@ -4250,7 +4330,7 @@ const parse$1 = (input, options) => {
|
|
|
4250
4330
|
* impact when none of the fast paths match.
|
|
4251
4331
|
*/
|
|
4252
4332
|
|
|
4253
|
-
parse$
|
|
4333
|
+
parse$2.fastpaths = (input, options) => {
|
|
4254
4334
|
const opts = { ...options };
|
|
4255
4335
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
4256
4336
|
const len = input.length;
|
|
@@ -4337,11 +4417,11 @@ parse$1.fastpaths = (input, options) => {
|
|
|
4337
4417
|
return source;
|
|
4338
4418
|
};
|
|
4339
4419
|
|
|
4340
|
-
var parse_1 = parse$
|
|
4420
|
+
var parse_1 = parse$2;
|
|
4341
4421
|
|
|
4342
|
-
const path = require$$0;
|
|
4422
|
+
const path = require$$0$1;
|
|
4343
4423
|
const scan = scan_1;
|
|
4344
|
-
const parse = parse_1;
|
|
4424
|
+
const parse$1 = parse_1;
|
|
4345
4425
|
const utils = utils$3;
|
|
4346
4426
|
const constants = constants$2;
|
|
4347
4427
|
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -4537,7 +4617,7 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
|
|
|
4537
4617
|
|
|
4538
4618
|
picomatch.parse = (pattern, options) => {
|
|
4539
4619
|
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
4540
|
-
return parse(pattern, { ...options, fastpaths: false });
|
|
4620
|
+
return parse$1(pattern, { ...options, fastpaths: false });
|
|
4541
4621
|
};
|
|
4542
4622
|
|
|
4543
4623
|
/**
|
|
@@ -4630,11 +4710,11 @@ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = fal
|
|
|
4630
4710
|
let parsed = { negated: false, fastpaths: true };
|
|
4631
4711
|
|
|
4632
4712
|
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
4633
|
-
parsed.output = parse.fastpaths(input, options);
|
|
4713
|
+
parsed.output = parse$1.fastpaths(input, options);
|
|
4634
4714
|
}
|
|
4635
4715
|
|
|
4636
4716
|
if (!parsed.output) {
|
|
4637
|
-
parsed = parse(input, options);
|
|
4717
|
+
parsed = parse$1(input, options);
|
|
4638
4718
|
}
|
|
4639
4719
|
|
|
4640
4720
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
@@ -4996,11 +5076,10 @@ function getLiteralMembersForValue(value) {
|
|
|
4996
5076
|
return Object.create(null);
|
|
4997
5077
|
}
|
|
4998
5078
|
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
4999
|
-
var _a, _b;
|
|
5000
5079
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
5001
5080
|
return true;
|
|
5002
5081
|
}
|
|
5003
|
-
return
|
|
5082
|
+
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
5004
5083
|
}
|
|
5005
5084
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
5006
5085
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
@@ -5427,6 +5506,9 @@ function annotateNode(node, comment, valid) {
|
|
|
5427
5506
|
}
|
|
5428
5507
|
|
|
5429
5508
|
const keys = {
|
|
5509
|
+
// TODO this should be removed once ImportExpression follows official ESTree
|
|
5510
|
+
// specs with "null" as default
|
|
5511
|
+
ImportExpression: ['arguments'],
|
|
5430
5512
|
Literal: [],
|
|
5431
5513
|
Program: ['body']
|
|
5432
5514
|
};
|
|
@@ -5464,14 +5546,12 @@ class NodeBase extends ExpressionEntity {
|
|
|
5464
5546
|
bind() {
|
|
5465
5547
|
for (const key of this.keys) {
|
|
5466
5548
|
const value = this[key];
|
|
5467
|
-
if (value === null)
|
|
5468
|
-
continue;
|
|
5469
5549
|
if (Array.isArray(value)) {
|
|
5470
5550
|
for (const child of value) {
|
|
5471
|
-
child
|
|
5551
|
+
child?.bind();
|
|
5472
5552
|
}
|
|
5473
5553
|
}
|
|
5474
|
-
else {
|
|
5554
|
+
else if (value) {
|
|
5475
5555
|
value.bind();
|
|
5476
5556
|
}
|
|
5477
5557
|
}
|
|
@@ -5491,7 +5571,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5491
5571
|
continue;
|
|
5492
5572
|
if (Array.isArray(value)) {
|
|
5493
5573
|
for (const child of value) {
|
|
5494
|
-
if (child
|
|
5574
|
+
if (child?.hasEffects(context))
|
|
5495
5575
|
return true;
|
|
5496
5576
|
}
|
|
5497
5577
|
}
|
|
@@ -5514,7 +5594,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5514
5594
|
continue;
|
|
5515
5595
|
if (Array.isArray(value)) {
|
|
5516
5596
|
for (const child of value) {
|
|
5517
|
-
child
|
|
5597
|
+
child?.include(context, includeChildrenRecursively);
|
|
5518
5598
|
}
|
|
5519
5599
|
}
|
|
5520
5600
|
else {
|
|
@@ -5571,7 +5651,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5571
5651
|
continue;
|
|
5572
5652
|
if (Array.isArray(value)) {
|
|
5573
5653
|
for (const child of value) {
|
|
5574
|
-
child
|
|
5654
|
+
child?.render(code, options);
|
|
5575
5655
|
}
|
|
5576
5656
|
}
|
|
5577
5657
|
else {
|
|
@@ -5598,7 +5678,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5598
5678
|
continue;
|
|
5599
5679
|
if (Array.isArray(value)) {
|
|
5600
5680
|
for (const child of value) {
|
|
5601
|
-
child
|
|
5681
|
+
child?.deoptimizePath(UNKNOWN_PATH);
|
|
5602
5682
|
}
|
|
5603
5683
|
}
|
|
5604
5684
|
else {
|
|
@@ -5654,19 +5734,18 @@ class Method extends ExpressionEntity {
|
|
|
5654
5734
|
: this.description.returns()));
|
|
5655
5735
|
}
|
|
5656
5736
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5657
|
-
var _a, _b;
|
|
5658
5737
|
const { type } = interaction;
|
|
5659
5738
|
if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
|
|
5660
5739
|
return true;
|
|
5661
5740
|
}
|
|
5662
5741
|
if (type === INTERACTION_CALLED) {
|
|
5663
5742
|
if (this.description.mutatesSelfAsArray === true &&
|
|
5664
|
-
|
|
5743
|
+
interaction.thisArg?.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)) {
|
|
5665
5744
|
return true;
|
|
5666
5745
|
}
|
|
5667
5746
|
if (this.description.callsArgs) {
|
|
5668
5747
|
for (const argIndex of this.description.callsArgs) {
|
|
5669
|
-
if (
|
|
5748
|
+
if (interaction.args[argIndex]?.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5670
5749
|
return true;
|
|
5671
5750
|
}
|
|
5672
5751
|
}
|
|
@@ -5742,7 +5821,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5742
5821
|
}
|
|
5743
5822
|
}
|
|
5744
5823
|
deoptimizeAllProperties(noAccessors) {
|
|
5745
|
-
var _a;
|
|
5746
5824
|
const isDeoptimized = this.hasLostTrack || this.hasUnknownDeoptimizedProperty;
|
|
5747
5825
|
if (noAccessors) {
|
|
5748
5826
|
this.hasUnknownDeoptimizedProperty = true;
|
|
@@ -5759,7 +5837,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5759
5837
|
}
|
|
5760
5838
|
}
|
|
5761
5839
|
// While the prototype itself cannot be mutated, each property can
|
|
5762
|
-
|
|
5840
|
+
this.prototypeExpression?.deoptimizePath([UnknownKey, UnknownKey]);
|
|
5763
5841
|
this.deoptimizeCachedEntities();
|
|
5764
5842
|
}
|
|
5765
5843
|
deoptimizeIntegerProperties() {
|
|
@@ -5780,7 +5858,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5780
5858
|
}
|
|
5781
5859
|
// Assumption: If only a specific path is deoptimized, no accessors are created
|
|
5782
5860
|
deoptimizePath(path) {
|
|
5783
|
-
var _a;
|
|
5784
5861
|
if (this.hasLostTrack || this.immutable) {
|
|
5785
5862
|
return;
|
|
5786
5863
|
}
|
|
@@ -5810,10 +5887,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5810
5887
|
: this.allProperties) {
|
|
5811
5888
|
property.deoptimizePath(subPath);
|
|
5812
5889
|
}
|
|
5813
|
-
|
|
5890
|
+
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
|
|
5814
5891
|
}
|
|
5815
5892
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5816
|
-
var _a;
|
|
5817
5893
|
const [key, ...subPath] = path;
|
|
5818
5894
|
if (this.hasLostTrack ||
|
|
5819
5895
|
// single paths that are deoptimized will not become getters or setters
|
|
@@ -5869,7 +5945,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5869
5945
|
if (!this.immutable) {
|
|
5870
5946
|
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5871
5947
|
}
|
|
5872
|
-
|
|
5948
|
+
this.prototypeExpression?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
5873
5949
|
}
|
|
5874
5950
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5875
5951
|
if (path.length === 0) {
|
|
@@ -6026,7 +6102,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6026
6102
|
return UNKNOWN_EXPRESSION;
|
|
6027
6103
|
}
|
|
6028
6104
|
const properties = this.propertiesAndGettersByKey[key];
|
|
6029
|
-
if (
|
|
6105
|
+
if (properties?.length === 1) {
|
|
6030
6106
|
return properties[0];
|
|
6031
6107
|
}
|
|
6032
6108
|
if (properties ||
|
|
@@ -6278,7 +6354,7 @@ class ArrayExpression extends NodeBase {
|
|
|
6278
6354
|
class ArrayPattern extends NodeBase {
|
|
6279
6355
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6280
6356
|
for (const element of this.elements) {
|
|
6281
|
-
element
|
|
6357
|
+
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
6282
6358
|
}
|
|
6283
6359
|
}
|
|
6284
6360
|
declare(kind) {
|
|
@@ -6293,20 +6369,20 @@ class ArrayPattern extends NodeBase {
|
|
|
6293
6369
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
6294
6370
|
deoptimizePath() {
|
|
6295
6371
|
for (const element of this.elements) {
|
|
6296
|
-
element
|
|
6372
|
+
element?.deoptimizePath(EMPTY_PATH);
|
|
6297
6373
|
}
|
|
6298
6374
|
}
|
|
6299
6375
|
// Patterns are only checked at the emtpy path at the moment
|
|
6300
6376
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
6301
6377
|
for (const element of this.elements) {
|
|
6302
|
-
if (element
|
|
6378
|
+
if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
6303
6379
|
return true;
|
|
6304
6380
|
}
|
|
6305
6381
|
return false;
|
|
6306
6382
|
}
|
|
6307
6383
|
markDeclarationReached() {
|
|
6308
6384
|
for (const element of this.elements) {
|
|
6309
|
-
element
|
|
6385
|
+
element?.markDeclarationReached();
|
|
6310
6386
|
}
|
|
6311
6387
|
}
|
|
6312
6388
|
}
|
|
@@ -6338,7 +6414,6 @@ class LocalVariable extends Variable {
|
|
|
6338
6414
|
}
|
|
6339
6415
|
}
|
|
6340
6416
|
deoptimizePath(path) {
|
|
6341
|
-
var _a, _b;
|
|
6342
6417
|
if (this.isReassigned ||
|
|
6343
6418
|
this.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
6344
6419
|
return;
|
|
@@ -6351,11 +6426,11 @@ class LocalVariable extends Variable {
|
|
|
6351
6426
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6352
6427
|
expression.deoptimizeCache();
|
|
6353
6428
|
}
|
|
6354
|
-
|
|
6429
|
+
this.init?.deoptimizePath(UNKNOWN_PATH);
|
|
6355
6430
|
}
|
|
6356
6431
|
}
|
|
6357
6432
|
else {
|
|
6358
|
-
|
|
6433
|
+
this.init?.deoptimizePath(path);
|
|
6359
6434
|
}
|
|
6360
6435
|
}
|
|
6361
6436
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -7690,13 +7765,12 @@ class Identifier extends NodeBase {
|
|
|
7690
7765
|
return [(this.variable = variable)];
|
|
7691
7766
|
}
|
|
7692
7767
|
deoptimizePath(path) {
|
|
7693
|
-
var _a;
|
|
7694
7768
|
if (path.length === 0 && !this.scope.contains(this.name)) {
|
|
7695
7769
|
this.disallowImportReassignment();
|
|
7696
7770
|
}
|
|
7697
7771
|
// We keep conditional chaining because an unknown Node could have an
|
|
7698
7772
|
// Identifier as property that might be deoptimized by default
|
|
7699
|
-
|
|
7773
|
+
this.variable?.deoptimizePath(path);
|
|
7700
7774
|
}
|
|
7701
7775
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7702
7776
|
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -8520,10 +8594,9 @@ class FunctionNode extends FunctionBase {
|
|
|
8520
8594
|
}
|
|
8521
8595
|
}
|
|
8522
8596
|
hasEffects(context) {
|
|
8523
|
-
var _a;
|
|
8524
8597
|
if (!this.deoptimized)
|
|
8525
8598
|
this.applyDeoptimizations();
|
|
8526
|
-
return !!
|
|
8599
|
+
return !!this.id?.hasEffects(context);
|
|
8527
8600
|
}
|
|
8528
8601
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8529
8602
|
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
@@ -8554,9 +8627,8 @@ class FunctionNode extends FunctionBase {
|
|
|
8554
8627
|
return false;
|
|
8555
8628
|
}
|
|
8556
8629
|
include(context, includeChildrenRecursively) {
|
|
8557
|
-
var _a;
|
|
8558
8630
|
super.include(context, includeChildrenRecursively);
|
|
8559
|
-
|
|
8631
|
+
this.id?.include();
|
|
8560
8632
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
8561
8633
|
for (const param of this.params) {
|
|
8562
8634
|
if (!(param instanceof Identifier) || hasArguments) {
|
|
@@ -8565,9 +8637,8 @@ class FunctionNode extends FunctionBase {
|
|
|
8565
8637
|
}
|
|
8566
8638
|
}
|
|
8567
8639
|
initialise() {
|
|
8568
|
-
var _a;
|
|
8569
8640
|
super.initialise();
|
|
8570
|
-
|
|
8641
|
+
this.id?.declare('function', this);
|
|
8571
8642
|
}
|
|
8572
8643
|
getObjectEntity() {
|
|
8573
8644
|
if (this.objectEntity !== null) {
|
|
@@ -9412,20 +9483,18 @@ class ClassNode extends NodeBase {
|
|
|
9412
9483
|
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9413
9484
|
}
|
|
9414
9485
|
hasEffects(context) {
|
|
9415
|
-
var _a, _b;
|
|
9416
9486
|
if (!this.deoptimized)
|
|
9417
9487
|
this.applyDeoptimizations();
|
|
9418
|
-
const initEffect =
|
|
9419
|
-
|
|
9488
|
+
const initEffect = this.superClass?.hasEffects(context) || this.body.hasEffects(context);
|
|
9489
|
+
this.id?.markDeclarationReached();
|
|
9420
9490
|
return initEffect || super.hasEffects(context);
|
|
9421
9491
|
}
|
|
9422
9492
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9423
|
-
var _a;
|
|
9424
9493
|
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
9425
9494
|
return (!interaction.withNew ||
|
|
9426
9495
|
(this.classConstructor !== null
|
|
9427
9496
|
? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
9428
|
-
:
|
|
9497
|
+
: this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
9429
9498
|
false);
|
|
9430
9499
|
}
|
|
9431
9500
|
else {
|
|
@@ -9433,11 +9502,10 @@ class ClassNode extends NodeBase {
|
|
|
9433
9502
|
}
|
|
9434
9503
|
}
|
|
9435
9504
|
include(context, includeChildrenRecursively) {
|
|
9436
|
-
var _a;
|
|
9437
9505
|
if (!this.deoptimized)
|
|
9438
9506
|
this.applyDeoptimizations();
|
|
9439
9507
|
this.included = true;
|
|
9440
|
-
|
|
9508
|
+
this.superClass?.include(context, includeChildrenRecursively);
|
|
9441
9509
|
this.body.include(context, includeChildrenRecursively);
|
|
9442
9510
|
if (this.id) {
|
|
9443
9511
|
this.id.markDeclarationReached();
|
|
@@ -9445,8 +9513,7 @@ class ClassNode extends NodeBase {
|
|
|
9445
9513
|
}
|
|
9446
9514
|
}
|
|
9447
9515
|
initialise() {
|
|
9448
|
-
|
|
9449
|
-
(_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('class', this);
|
|
9516
|
+
this.id?.declare('class', this);
|
|
9450
9517
|
for (const method of this.body.body) {
|
|
9451
9518
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
9452
9519
|
this.classConstructor = method;
|
|
@@ -9862,13 +9929,11 @@ ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
|
9862
9929
|
|
|
9863
9930
|
class ExportNamedDeclaration extends NodeBase {
|
|
9864
9931
|
bind() {
|
|
9865
|
-
var _a;
|
|
9866
9932
|
// Do not bind specifiers
|
|
9867
|
-
|
|
9933
|
+
this.declaration?.bind();
|
|
9868
9934
|
}
|
|
9869
9935
|
hasEffects(context) {
|
|
9870
|
-
|
|
9871
|
-
return !!((_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
|
|
9936
|
+
return !!this.declaration?.hasEffects(context);
|
|
9872
9937
|
}
|
|
9873
9938
|
initialise() {
|
|
9874
9939
|
this.context.addExport(this);
|
|
@@ -9986,10 +10051,9 @@ class ForStatement extends NodeBase {
|
|
|
9986
10051
|
this.scope = new BlockScope(parentScope);
|
|
9987
10052
|
}
|
|
9988
10053
|
hasEffects(context) {
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
((_c = this.update) === null || _c === void 0 ? void 0 : _c.hasEffects(context)))
|
|
10054
|
+
if (this.init?.hasEffects(context) ||
|
|
10055
|
+
this.test?.hasEffects(context) ||
|
|
10056
|
+
this.update?.hasEffects(context))
|
|
9993
10057
|
return true;
|
|
9994
10058
|
const { brokenFlow, ignore: { breaks, continues } } = context;
|
|
9995
10059
|
context.ignore.breaks = true;
|
|
@@ -10002,20 +10066,18 @@ class ForStatement extends NodeBase {
|
|
|
10002
10066
|
return false;
|
|
10003
10067
|
}
|
|
10004
10068
|
include(context, includeChildrenRecursively) {
|
|
10005
|
-
var _a, _b, _c;
|
|
10006
10069
|
this.included = true;
|
|
10007
|
-
|
|
10008
|
-
|
|
10070
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10071
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
10009
10072
|
const { brokenFlow } = context;
|
|
10010
|
-
|
|
10073
|
+
this.update?.include(context, includeChildrenRecursively);
|
|
10011
10074
|
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10012
10075
|
context.brokenFlow = brokenFlow;
|
|
10013
10076
|
}
|
|
10014
10077
|
render(code, options) {
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
(_c = this.update) === null || _c === void 0 ? void 0 : _c.render(code, options, NO_SEMICOLON);
|
|
10078
|
+
this.init?.render(code, options, NO_SEMICOLON);
|
|
10079
|
+
this.test?.render(code, options, NO_SEMICOLON);
|
|
10080
|
+
this.update?.render(code, options, NO_SEMICOLON);
|
|
10019
10081
|
this.body.render(code, options);
|
|
10020
10082
|
}
|
|
10021
10083
|
}
|
|
@@ -10051,7 +10113,6 @@ class IfStatement extends NodeBase {
|
|
|
10051
10113
|
this.testValue = UnknownValue;
|
|
10052
10114
|
}
|
|
10053
10115
|
hasEffects(context) {
|
|
10054
|
-
var _a;
|
|
10055
10116
|
if (this.test.hasEffects(context)) {
|
|
10056
10117
|
return true;
|
|
10057
10118
|
}
|
|
@@ -10070,7 +10131,7 @@ class IfStatement extends NodeBase {
|
|
|
10070
10131
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
10071
10132
|
return false;
|
|
10072
10133
|
}
|
|
10073
|
-
return testValue ? this.consequent.hasEffects(context) : !!
|
|
10134
|
+
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
10074
10135
|
}
|
|
10075
10136
|
include(context, includeChildrenRecursively) {
|
|
10076
10137
|
this.included = true;
|
|
@@ -10148,25 +10209,22 @@ class IfStatement extends NodeBase {
|
|
|
10148
10209
|
return this.testValue;
|
|
10149
10210
|
}
|
|
10150
10211
|
includeKnownTest(context, testValue) {
|
|
10151
|
-
var _a;
|
|
10152
10212
|
if (this.test.shouldBeIncluded(context)) {
|
|
10153
10213
|
this.test.include(context, false);
|
|
10154
10214
|
}
|
|
10155
10215
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
10156
10216
|
this.consequent.include(context, false, { asSingleStatement: true });
|
|
10157
10217
|
}
|
|
10158
|
-
if (!testValue &&
|
|
10218
|
+
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
10159
10219
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
10160
10220
|
}
|
|
10161
10221
|
}
|
|
10162
10222
|
includeRecursively(includeChildrenRecursively, context) {
|
|
10163
|
-
var _a;
|
|
10164
10223
|
this.test.include(context, includeChildrenRecursively);
|
|
10165
10224
|
this.consequent.include(context, includeChildrenRecursively);
|
|
10166
|
-
|
|
10225
|
+
this.alternate?.include(context, includeChildrenRecursively);
|
|
10167
10226
|
}
|
|
10168
10227
|
includeUnknownTest(context) {
|
|
10169
|
-
var _a;
|
|
10170
10228
|
this.test.include(context, false);
|
|
10171
10229
|
const { brokenFlow } = context;
|
|
10172
10230
|
let consequentBrokenFlow = BROKEN_FLOW_NONE;
|
|
@@ -10175,7 +10233,7 @@ class IfStatement extends NodeBase {
|
|
|
10175
10233
|
consequentBrokenFlow = context.brokenFlow;
|
|
10176
10234
|
context.brokenFlow = brokenFlow;
|
|
10177
10235
|
}
|
|
10178
|
-
if (
|
|
10236
|
+
if (this.alternate?.shouldBeIncluded(context)) {
|
|
10179
10237
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
10180
10238
|
context.brokenFlow =
|
|
10181
10239
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
@@ -10214,8 +10272,11 @@ class IfStatement extends NodeBase {
|
|
|
10214
10272
|
}
|
|
10215
10273
|
}
|
|
10216
10274
|
|
|
10275
|
+
class ImportAttribute extends NodeBase {
|
|
10276
|
+
}
|
|
10277
|
+
|
|
10217
10278
|
class ImportDeclaration extends NodeBase {
|
|
10218
|
-
// Do not bind specifiers
|
|
10279
|
+
// Do not bind specifiers or assertions
|
|
10219
10280
|
bind() { }
|
|
10220
10281
|
hasEffects() {
|
|
10221
10282
|
return false;
|
|
@@ -10439,15 +10500,22 @@ function getToStringTagValue(getObject) {
|
|
|
10439
10500
|
});
|
|
10440
10501
|
}
|
|
10441
10502
|
|
|
10503
|
+
// TODO once ImportExpression follows official ESTree specs with "null" as
|
|
10504
|
+
// default, keys.ts should be updated
|
|
10442
10505
|
class ImportExpression extends NodeBase {
|
|
10443
10506
|
constructor() {
|
|
10444
10507
|
super(...arguments);
|
|
10445
10508
|
this.inlineNamespace = null;
|
|
10509
|
+
this.assertions = null;
|
|
10446
10510
|
this.mechanism = null;
|
|
10447
10511
|
this.namespaceExportName = undefined;
|
|
10448
10512
|
this.resolution = null;
|
|
10449
10513
|
this.resolutionString = null;
|
|
10450
10514
|
}
|
|
10515
|
+
// Do not bind assertions
|
|
10516
|
+
bind() {
|
|
10517
|
+
this.source.bind();
|
|
10518
|
+
}
|
|
10451
10519
|
hasEffects() {
|
|
10452
10520
|
return true;
|
|
10453
10521
|
}
|
|
@@ -10463,19 +10531,19 @@ class ImportExpression extends NodeBase {
|
|
|
10463
10531
|
this.context.addDynamicImport(this);
|
|
10464
10532
|
}
|
|
10465
10533
|
render(code, options) {
|
|
10466
|
-
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10534
|
+
const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
|
|
10467
10535
|
if (this.inlineNamespace) {
|
|
10468
10536
|
const [left, right] = getDirectReturnFunction([], {
|
|
10469
10537
|
functionReturn: true,
|
|
10470
10538
|
lineBreakIndent: null,
|
|
10471
10539
|
name: null
|
|
10472
10540
|
});
|
|
10473
|
-
code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})
|
|
10541
|
+
code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})`);
|
|
10474
10542
|
return;
|
|
10475
10543
|
}
|
|
10476
10544
|
if (this.mechanism) {
|
|
10477
|
-
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left
|
|
10478
|
-
code.overwrite(this.end - 1, this.end, this.mechanism.right
|
|
10545
|
+
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
|
|
10546
|
+
code.overwrite(this.end - 1, this.end, this.mechanism.right);
|
|
10479
10547
|
}
|
|
10480
10548
|
if (this.resolutionString) {
|
|
10481
10549
|
code.overwrite(this.source.start, this.source.end, this.resolutionString);
|
|
@@ -10491,13 +10559,24 @@ class ImportExpression extends NodeBase {
|
|
|
10491
10559
|
else {
|
|
10492
10560
|
this.source.render(code, options);
|
|
10493
10561
|
}
|
|
10562
|
+
if (this.assertions !== true) {
|
|
10563
|
+
if (this.arguments) {
|
|
10564
|
+
code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true });
|
|
10565
|
+
}
|
|
10566
|
+
if (this.assertions) {
|
|
10567
|
+
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.assertions]], {
|
|
10568
|
+
lineBreakIndent: null
|
|
10569
|
+
})}`);
|
|
10570
|
+
}
|
|
10571
|
+
}
|
|
10494
10572
|
}
|
|
10495
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
|
|
10573
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, assertions) {
|
|
10496
10574
|
const { format } = options;
|
|
10497
10575
|
this.inlineNamespace = null;
|
|
10498
10576
|
this.resolution = resolution;
|
|
10499
10577
|
this.resolutionString = resolutionString;
|
|
10500
10578
|
this.namespaceExportName = namespaceExportName;
|
|
10579
|
+
this.assertions = assertions;
|
|
10501
10580
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
10502
10581
|
let helper;
|
|
10503
10582
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -10512,7 +10591,7 @@ class ImportExpression extends NodeBase {
|
|
|
10512
10591
|
this.inlineNamespace = inlineNamespace;
|
|
10513
10592
|
}
|
|
10514
10593
|
applyDeoptimizations() { }
|
|
10515
|
-
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
10594
|
+
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
10516
10595
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
10517
10596
|
{
|
|
10518
10597
|
customResolution: typeof this.resolution === 'string' ? this.resolution : null,
|
|
@@ -10527,6 +10606,10 @@ class ImportExpression extends NodeBase {
|
|
|
10527
10606
|
const hasDynamicTarget = !this.resolution || typeof this.resolution === 'string';
|
|
10528
10607
|
switch (format) {
|
|
10529
10608
|
case 'cjs': {
|
|
10609
|
+
if (dynamicImportInCjs &&
|
|
10610
|
+
(!resolution || typeof resolution === 'string' || resolution instanceof ExternalModule)) {
|
|
10611
|
+
return { helper: null, mechanism: null };
|
|
10612
|
+
}
|
|
10530
10613
|
const helper = getInteropHelper(resolution, exportMode, interop);
|
|
10531
10614
|
let left = `require(`;
|
|
10532
10615
|
let right = `)`;
|
|
@@ -10802,7 +10885,7 @@ class MetaProperty extends NodeBase {
|
|
|
10802
10885
|
}
|
|
10803
10886
|
getReferencedFileName(outputPluginDriver) {
|
|
10804
10887
|
const { metaProperty } = this;
|
|
10805
|
-
if (metaProperty
|
|
10888
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
10806
10889
|
return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
|
|
10807
10890
|
}
|
|
10808
10891
|
return null;
|
|
@@ -10823,14 +10906,13 @@ class MetaProperty extends NodeBase {
|
|
|
10823
10906
|
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
10824
10907
|
? parent.propertyKey
|
|
10825
10908
|
: null);
|
|
10826
|
-
if (metaProperty
|
|
10909
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
10827
10910
|
this.referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
10828
10911
|
}
|
|
10829
10912
|
}
|
|
10830
10913
|
}
|
|
10831
10914
|
}
|
|
10832
10915
|
render(code, { format, pluginDriver, snippets }) {
|
|
10833
|
-
var _a;
|
|
10834
10916
|
const { metaProperty, parent, referenceId } = this;
|
|
10835
10917
|
const chunkId = this.preliminaryChunkId;
|
|
10836
10918
|
if (referenceId) {
|
|
@@ -10856,7 +10938,7 @@ class MetaProperty extends NodeBase {
|
|
|
10856
10938
|
format,
|
|
10857
10939
|
moduleId: this.context.module.id
|
|
10858
10940
|
}
|
|
10859
|
-
]) ||
|
|
10941
|
+
]) || importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
10860
10942
|
if (typeof replacement === 'string') {
|
|
10861
10943
|
if (parent instanceof MemberExpression) {
|
|
10862
10944
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
@@ -10867,9 +10949,8 @@ class MetaProperty extends NodeBase {
|
|
|
10867
10949
|
}
|
|
10868
10950
|
}
|
|
10869
10951
|
setResolution(format, accessedGlobalsByScope, preliminaryChunkId) {
|
|
10870
|
-
var _a;
|
|
10871
10952
|
this.preliminaryChunkId = preliminaryChunkId;
|
|
10872
|
-
const accessedGlobals = (
|
|
10953
|
+
const accessedGlobals = (this.metaProperty?.startsWith(FILE_PREFIX) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
|
|
10873
10954
|
if (accessedGlobals.length > 0) {
|
|
10874
10955
|
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
10875
10956
|
}
|
|
@@ -11127,12 +11208,10 @@ class Property extends MethodBase {
|
|
|
11127
11208
|
|
|
11128
11209
|
class PropertyDefinition extends NodeBase {
|
|
11129
11210
|
deoptimizePath(path) {
|
|
11130
|
-
|
|
11131
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
11211
|
+
this.value?.deoptimizePath(path);
|
|
11132
11212
|
}
|
|
11133
11213
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11134
|
-
|
|
11135
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11214
|
+
this.value?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11136
11215
|
}
|
|
11137
11216
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11138
11217
|
return this.value
|
|
@@ -11145,8 +11224,7 @@ class PropertyDefinition extends NodeBase {
|
|
|
11145
11224
|
: UNKNOWN_EXPRESSION;
|
|
11146
11225
|
}
|
|
11147
11226
|
hasEffects(context) {
|
|
11148
|
-
|
|
11149
|
-
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
11227
|
+
return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
|
|
11150
11228
|
}
|
|
11151
11229
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11152
11230
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -11156,16 +11234,14 @@ class PropertyDefinition extends NodeBase {
|
|
|
11156
11234
|
|
|
11157
11235
|
class ReturnStatement extends NodeBase {
|
|
11158
11236
|
hasEffects(context) {
|
|
11159
|
-
|
|
11160
|
-
if (!context.ignore.returnYield || ((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)))
|
|
11237
|
+
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
11161
11238
|
return true;
|
|
11162
11239
|
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
11163
11240
|
return false;
|
|
11164
11241
|
}
|
|
11165
11242
|
include(context, includeChildrenRecursively) {
|
|
11166
|
-
var _a;
|
|
11167
11243
|
this.included = true;
|
|
11168
|
-
|
|
11244
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
11169
11245
|
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
11170
11246
|
}
|
|
11171
11247
|
initialise() {
|
|
@@ -11291,8 +11367,7 @@ class Super extends NodeBase {
|
|
|
11291
11367
|
|
|
11292
11368
|
class SwitchCase extends NodeBase {
|
|
11293
11369
|
hasEffects(context) {
|
|
11294
|
-
|
|
11295
|
-
if ((_a = this.test) === null || _a === void 0 ? void 0 : _a.hasEffects(context))
|
|
11370
|
+
if (this.test?.hasEffects(context))
|
|
11296
11371
|
return true;
|
|
11297
11372
|
for (const node of this.consequent) {
|
|
11298
11373
|
if (context.brokenFlow)
|
|
@@ -11303,9 +11378,8 @@ class SwitchCase extends NodeBase {
|
|
|
11303
11378
|
return false;
|
|
11304
11379
|
}
|
|
11305
11380
|
include(context, includeChildrenRecursively) {
|
|
11306
|
-
var _a;
|
|
11307
11381
|
this.included = true;
|
|
11308
|
-
|
|
11382
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
11309
11383
|
for (const node of this.consequent) {
|
|
11310
11384
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
11311
11385
|
node.include(context, includeChildrenRecursively);
|
|
@@ -11692,14 +11766,13 @@ class TryStatement extends NodeBase {
|
|
|
11692
11766
|
this.includedLabelsAfterBlock = null;
|
|
11693
11767
|
}
|
|
11694
11768
|
hasEffects(context) {
|
|
11695
|
-
var _a;
|
|
11696
11769
|
return ((this.context.options.treeshake.tryCatchDeoptimization
|
|
11697
11770
|
? this.block.body.length > 0
|
|
11698
|
-
: this.block.hasEffects(context)) || !!
|
|
11771
|
+
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
11699
11772
|
}
|
|
11700
11773
|
include(context, includeChildrenRecursively) {
|
|
11701
|
-
|
|
11702
|
-
|
|
11774
|
+
const tryCatchDeoptimization = this.context.options.treeshake
|
|
11775
|
+
?.tryCatchDeoptimization;
|
|
11703
11776
|
const { brokenFlow } = context;
|
|
11704
11777
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
11705
11778
|
this.included = true;
|
|
@@ -11719,7 +11792,7 @@ class TryStatement extends NodeBase {
|
|
|
11719
11792
|
this.handler.include(context, includeChildrenRecursively);
|
|
11720
11793
|
context.brokenFlow = brokenFlow;
|
|
11721
11794
|
}
|
|
11722
|
-
|
|
11795
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
11723
11796
|
}
|
|
11724
11797
|
}
|
|
11725
11798
|
|
|
@@ -11971,14 +12044,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
11971
12044
|
}
|
|
11972
12045
|
}
|
|
11973
12046
|
function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
|
|
11974
|
-
var _a;
|
|
11975
12047
|
let singleSystemExport = null;
|
|
11976
12048
|
if (options.format === 'system') {
|
|
11977
12049
|
for (const { node } of separatedNodes) {
|
|
11978
12050
|
if (node.id instanceof Identifier &&
|
|
11979
12051
|
node.init &&
|
|
11980
12052
|
aggregatedSystemExports.length === 0 &&
|
|
11981
|
-
|
|
12053
|
+
options.exportNamesByVariable.get(node.id.variable)?.length === 1) {
|
|
11982
12054
|
singleSystemExport = node.id.variable;
|
|
11983
12055
|
aggregatedSystemExports.push(singleSystemExport);
|
|
11984
12056
|
}
|
|
@@ -12004,15 +12076,13 @@ class VariableDeclarator extends NodeBase {
|
|
|
12004
12076
|
this.id.deoptimizePath(path);
|
|
12005
12077
|
}
|
|
12006
12078
|
hasEffects(context) {
|
|
12007
|
-
|
|
12008
|
-
const initEffect = (_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
|
|
12079
|
+
const initEffect = this.init?.hasEffects(context);
|
|
12009
12080
|
this.id.markDeclarationReached();
|
|
12010
12081
|
return initEffect || this.id.hasEffects(context);
|
|
12011
12082
|
}
|
|
12012
12083
|
include(context, includeChildrenRecursively) {
|
|
12013
|
-
var _a;
|
|
12014
12084
|
this.included = true;
|
|
12015
|
-
|
|
12085
|
+
this.init?.include(context, includeChildrenRecursively);
|
|
12016
12086
|
this.id.markDeclarationReached();
|
|
12017
12087
|
if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
|
|
12018
12088
|
this.id.include(context, includeChildrenRecursively);
|
|
@@ -12064,10 +12134,9 @@ class WhileStatement extends NodeBase {
|
|
|
12064
12134
|
|
|
12065
12135
|
class YieldExpression extends NodeBase {
|
|
12066
12136
|
hasEffects(context) {
|
|
12067
|
-
var _a;
|
|
12068
12137
|
if (!this.deoptimized)
|
|
12069
12138
|
this.applyDeoptimizations();
|
|
12070
|
-
return !(context.ignore.returnYield && !
|
|
12139
|
+
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
12071
12140
|
}
|
|
12072
12141
|
render(code, options) {
|
|
12073
12142
|
if (this.argument) {
|
|
@@ -12111,6 +12180,7 @@ const nodeConstructors = {
|
|
|
12111
12180
|
FunctionExpression,
|
|
12112
12181
|
Identifier,
|
|
12113
12182
|
IfStatement,
|
|
12183
|
+
ImportAttribute,
|
|
12114
12184
|
ImportDeclaration,
|
|
12115
12185
|
ImportDefaultSpecifier,
|
|
12116
12186
|
ImportExpression,
|
|
@@ -12335,6 +12405,41 @@ function getOriginalLocation(sourcemapChain, location) {
|
|
|
12335
12405
|
return location;
|
|
12336
12406
|
}
|
|
12337
12407
|
|
|
12408
|
+
function getAssertionsFromImportExpression(node) {
|
|
12409
|
+
const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
|
|
12410
|
+
if (!assertProperty) {
|
|
12411
|
+
return EMPTY_OBJECT;
|
|
12412
|
+
}
|
|
12413
|
+
const assertFields = assertProperty.properties
|
|
12414
|
+
.map(property => {
|
|
12415
|
+
const key = getPropertyKey(property);
|
|
12416
|
+
if (typeof key === 'string' &&
|
|
12417
|
+
typeof property.value.value === 'string') {
|
|
12418
|
+
return [key, property.value.value];
|
|
12419
|
+
}
|
|
12420
|
+
return null;
|
|
12421
|
+
})
|
|
12422
|
+
.filter((property) => !!property);
|
|
12423
|
+
if (assertFields.length > 0) {
|
|
12424
|
+
return Object.fromEntries(assertFields);
|
|
12425
|
+
}
|
|
12426
|
+
return EMPTY_OBJECT;
|
|
12427
|
+
}
|
|
12428
|
+
const getPropertyKey = (property) => {
|
|
12429
|
+
const key = property.key;
|
|
12430
|
+
return key && (key.name || key.value);
|
|
12431
|
+
};
|
|
12432
|
+
function getAssertionsFromImportExportDeclaration(assertions) {
|
|
12433
|
+
return assertions?.length
|
|
12434
|
+
? Object.fromEntries(assertions.map(assertion => [getPropertyKey(assertion), assertion.value.value]))
|
|
12435
|
+
: EMPTY_OBJECT;
|
|
12436
|
+
}
|
|
12437
|
+
function doAssertionsDiffer(assertionA, assertionB) {
|
|
12438
|
+
const keysA = Object.keys(assertionA);
|
|
12439
|
+
return (keysA.length !== Object.keys(assertionB).length ||
|
|
12440
|
+
keysA.some(key => assertionA[key] !== assertionB[key]));
|
|
12441
|
+
}
|
|
12442
|
+
|
|
12338
12443
|
const NOOP = () => { };
|
|
12339
12444
|
let timers = new Map();
|
|
12340
12445
|
function getPersistedLabel(label, level) {
|
|
@@ -12505,7 +12610,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
12505
12610
|
return sideEffectModules;
|
|
12506
12611
|
}
|
|
12507
12612
|
class Module {
|
|
12508
|
-
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta) {
|
|
12613
|
+
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions) {
|
|
12509
12614
|
this.graph = graph;
|
|
12510
12615
|
this.id = id;
|
|
12511
12616
|
this.options = options;
|
|
@@ -12530,7 +12635,7 @@ class Module {
|
|
|
12530
12635
|
this.isUserDefinedEntryPoint = false;
|
|
12531
12636
|
this.needsExportShim = false;
|
|
12532
12637
|
this.sideEffectDependenciesByVariable = new Map();
|
|
12533
|
-
this.
|
|
12638
|
+
this.sourcesWithAssertions = new Map();
|
|
12534
12639
|
this.allExportNames = null;
|
|
12535
12640
|
this.ast = null;
|
|
12536
12641
|
this.exportAllModules = [];
|
|
@@ -12550,8 +12655,9 @@ class Module {
|
|
|
12550
12655
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
12551
12656
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
12552
12657
|
const module = this;
|
|
12553
|
-
const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions,
|
|
12658
|
+
const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAssertions } = this;
|
|
12554
12659
|
this.info = {
|
|
12660
|
+
assertions,
|
|
12555
12661
|
ast: null,
|
|
12556
12662
|
code: null,
|
|
12557
12663
|
get dynamicallyImportedIdResolutions() {
|
|
@@ -12586,12 +12692,12 @@ class Module {
|
|
|
12586
12692
|
return Array.from(implicitlyLoadedBefore, getId).sort();
|
|
12587
12693
|
},
|
|
12588
12694
|
get importedIdResolutions() {
|
|
12589
|
-
return Array.from(
|
|
12695
|
+
return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]).filter(Boolean);
|
|
12590
12696
|
},
|
|
12591
12697
|
get importedIds() {
|
|
12592
12698
|
// We cannot use this.dependencies because this is needed before
|
|
12593
12699
|
// dependencies are populated
|
|
12594
|
-
return Array.from(
|
|
12700
|
+
return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]?.id).filter(Boolean);
|
|
12595
12701
|
},
|
|
12596
12702
|
get importers() {
|
|
12597
12703
|
return importers.sort();
|
|
@@ -12763,7 +12869,6 @@ class Module {
|
|
|
12763
12869
|
return this.syntheticNamespace;
|
|
12764
12870
|
}
|
|
12765
12871
|
getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, onlyExplicit, searchedNamesAndModules } = EMPTY_OBJECT) {
|
|
12766
|
-
var _a;
|
|
12767
12872
|
if (name[0] === '*') {
|
|
12768
12873
|
if (name.length === 1) {
|
|
12769
12874
|
// export * from './other'
|
|
@@ -12805,7 +12910,8 @@ class Module {
|
|
|
12805
12910
|
return [null];
|
|
12806
12911
|
}
|
|
12807
12912
|
if (name !== 'default') {
|
|
12808
|
-
const foundNamespaceReexport =
|
|
12913
|
+
const foundNamespaceReexport = this.namespaceReexportsByName.get(name) ??
|
|
12914
|
+
this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
|
|
12809
12915
|
this.namespaceReexportsByName.set(name, foundNamespaceReexport);
|
|
12810
12916
|
if (foundNamespaceReexport[0]) {
|
|
12811
12917
|
return foundNamespaceReexport;
|
|
@@ -12957,6 +13063,7 @@ class Module {
|
|
|
12957
13063
|
}
|
|
12958
13064
|
toJSON() {
|
|
12959
13065
|
return {
|
|
13066
|
+
assertions: this.info.assertions,
|
|
12960
13067
|
ast: this.ast.esTreeNode,
|
|
12961
13068
|
code: this.info.code,
|
|
12962
13069
|
customTransformCache: this.customTransformCache,
|
|
@@ -13037,7 +13144,7 @@ class Module {
|
|
|
13037
13144
|
}
|
|
13038
13145
|
else if (node instanceof ExportAllDeclaration) {
|
|
13039
13146
|
const source = node.source.value;
|
|
13040
|
-
this.
|
|
13147
|
+
this.addSource(source, node);
|
|
13041
13148
|
if (node.exported) {
|
|
13042
13149
|
// export * as name from './other'
|
|
13043
13150
|
const name = node.exported.name;
|
|
@@ -13056,7 +13163,7 @@ class Module {
|
|
|
13056
13163
|
else if (node.source instanceof Literal) {
|
|
13057
13164
|
// export { name } from './other'
|
|
13058
13165
|
const source = node.source.value;
|
|
13059
|
-
this.
|
|
13166
|
+
this.addSource(source, node);
|
|
13060
13167
|
for (const specifier of node.specifiers) {
|
|
13061
13168
|
const name = specifier.exported.name;
|
|
13062
13169
|
this.reexportDescriptions.set(name, {
|
|
@@ -13095,7 +13202,7 @@ class Module {
|
|
|
13095
13202
|
}
|
|
13096
13203
|
addImport(node) {
|
|
13097
13204
|
const source = node.source.value;
|
|
13098
|
-
this.
|
|
13205
|
+
this.addSource(source, node);
|
|
13099
13206
|
for (const specifier of node.specifiers) {
|
|
13100
13207
|
const isDefault = specifier.type === ImportDefaultSpecifier$1;
|
|
13101
13208
|
const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
|
|
@@ -13159,6 +13266,18 @@ class Module {
|
|
|
13159
13266
|
addSideEffectDependencies(this.dependencies);
|
|
13160
13267
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
13161
13268
|
}
|
|
13269
|
+
addSource(source, declaration) {
|
|
13270
|
+
const parsedAssertions = getAssertionsFromImportExportDeclaration(declaration.assertions);
|
|
13271
|
+
const existingAssertions = this.sourcesWithAssertions.get(source);
|
|
13272
|
+
if (existingAssertions) {
|
|
13273
|
+
if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
|
|
13274
|
+
this.warn(errInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
|
|
13275
|
+
}
|
|
13276
|
+
}
|
|
13277
|
+
else {
|
|
13278
|
+
this.sourcesWithAssertions.set(source, parsedAssertions);
|
|
13279
|
+
}
|
|
13280
|
+
}
|
|
13162
13281
|
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
|
|
13163
13282
|
let foundSyntheticDeclaration = null;
|
|
13164
13283
|
const foundInternalDeclarations = new Map();
|
|
@@ -13610,8 +13729,8 @@ function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
|
13610
13729
|
}
|
|
13611
13730
|
|
|
13612
13731
|
function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }, { externalLiveBindings, freeze, namespaceToStringTag }) {
|
|
13613
|
-
const {
|
|
13614
|
-
const importBlock = getImportBlock(dependencies,
|
|
13732
|
+
const { n } = snippets;
|
|
13733
|
+
const importBlock = getImportBlock(dependencies, snippets);
|
|
13615
13734
|
if (importBlock.length > 0)
|
|
13616
13735
|
intro += importBlock.join(n) + n + n;
|
|
13617
13736
|
intro += getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, namespaceToStringTag);
|
|
@@ -13624,11 +13743,13 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
13624
13743
|
magicString.append(outro);
|
|
13625
13744
|
magicString.trim();
|
|
13626
13745
|
}
|
|
13627
|
-
function getImportBlock(dependencies, _) {
|
|
13746
|
+
function getImportBlock(dependencies, { _ }) {
|
|
13628
13747
|
const importBlock = [];
|
|
13629
|
-
for (const { importPath, reexports, imports, name } of dependencies) {
|
|
13748
|
+
for (const { importPath, reexports, imports, name, assertions } of dependencies) {
|
|
13749
|
+
const assertion = assertions ? `${_}assert${_}${assertions}` : '';
|
|
13750
|
+
const pathWithAssertion = `'${importPath}'${assertion};`;
|
|
13630
13751
|
if (!reexports && !imports) {
|
|
13631
|
-
importBlock.push(`import${_}
|
|
13752
|
+
importBlock.push(`import${_}${pathWithAssertion}`);
|
|
13632
13753
|
continue;
|
|
13633
13754
|
}
|
|
13634
13755
|
if (imports) {
|
|
@@ -13647,10 +13768,10 @@ function getImportBlock(dependencies, _) {
|
|
|
13647
13768
|
}
|
|
13648
13769
|
}
|
|
13649
13770
|
if (starImport) {
|
|
13650
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}
|
|
13771
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}${pathWithAssertion}`);
|
|
13651
13772
|
}
|
|
13652
13773
|
if (defaultImport && importedNames.length === 0) {
|
|
13653
|
-
importBlock.push(`import ${defaultImport.local} from${_}
|
|
13774
|
+
importBlock.push(`import ${defaultImport.local} from${_}${pathWithAssertion}`);
|
|
13654
13775
|
}
|
|
13655
13776
|
else if (importedNames.length > 0) {
|
|
13656
13777
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
@@ -13662,7 +13783,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13662
13783
|
return `${specifier.imported} as ${specifier.local}`;
|
|
13663
13784
|
}
|
|
13664
13785
|
})
|
|
13665
|
-
.join(`,${_}`)}${_}}${_}from${_}
|
|
13786
|
+
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13666
13787
|
}
|
|
13667
13788
|
}
|
|
13668
13789
|
if (reexports) {
|
|
@@ -13681,12 +13802,12 @@ function getImportBlock(dependencies, _) {
|
|
|
13681
13802
|
}
|
|
13682
13803
|
}
|
|
13683
13804
|
if (starExport) {
|
|
13684
|
-
importBlock.push(`export${_}*${_}from${_}
|
|
13805
|
+
importBlock.push(`export${_}*${_}from${_}${pathWithAssertion}`);
|
|
13685
13806
|
}
|
|
13686
13807
|
if (namespaceReexports.length > 0) {
|
|
13687
13808
|
if (!imports ||
|
|
13688
13809
|
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
13689
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}
|
|
13810
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
|
|
13690
13811
|
}
|
|
13691
13812
|
for (const specifier of namespaceReexports) {
|
|
13692
13813
|
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
@@ -13702,7 +13823,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13702
13823
|
return `${specifier.imported} as ${specifier.reexported}`;
|
|
13703
13824
|
}
|
|
13704
13825
|
})
|
|
13705
|
-
.join(`,${_}`)}${_}}${_}from${_}
|
|
13826
|
+
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13706
13827
|
}
|
|
13707
13828
|
}
|
|
13708
13829
|
}
|
|
@@ -14065,380 +14186,93 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
14065
14186
|
|
|
14066
14187
|
const finalisers = { amd, cjs, es, iife, system, umd };
|
|
14067
14188
|
|
|
14068
|
-
const
|
|
14189
|
+
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14190
|
+
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14191
|
+
async function createAddons(options, outputPluginDriver, chunk) {
|
|
14192
|
+
try {
|
|
14193
|
+
let [banner, footer, intro, outro] = await Promise.all([
|
|
14194
|
+
outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
|
|
14195
|
+
outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
|
|
14196
|
+
outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
|
|
14197
|
+
outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
|
|
14198
|
+
]);
|
|
14199
|
+
if (intro)
|
|
14200
|
+
intro += '\n\n';
|
|
14201
|
+
if (outro)
|
|
14202
|
+
outro = `\n\n${outro}`;
|
|
14203
|
+
if (banner)
|
|
14204
|
+
banner += '\n';
|
|
14205
|
+
if (footer)
|
|
14206
|
+
footer = '\n' + footer;
|
|
14207
|
+
return { banner, footer, intro, outro };
|
|
14208
|
+
}
|
|
14209
|
+
catch (err) {
|
|
14210
|
+
return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14069
14213
|
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14214
|
+
const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
14215
|
+
amd: deconflictImportsOther,
|
|
14216
|
+
cjs: deconflictImportsOther,
|
|
14217
|
+
es: deconflictImportsEsmOrSystem,
|
|
14218
|
+
iife: deconflictImportsOther,
|
|
14219
|
+
system: deconflictImportsEsmOrSystem,
|
|
14220
|
+
umd: deconflictImportsOther
|
|
14221
|
+
};
|
|
14222
|
+
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14223
|
+
const reversedModules = modules.slice().reverse();
|
|
14224
|
+
for (const module of reversedModules) {
|
|
14225
|
+
module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14226
|
+
}
|
|
14227
|
+
deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
|
|
14228
|
+
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
|
|
14229
|
+
for (const module of reversedModules) {
|
|
14230
|
+
module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14231
|
+
}
|
|
14232
|
+
}
|
|
14233
|
+
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
|
|
14234
|
+
// This is needed for namespace reexports
|
|
14235
|
+
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14236
|
+
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14237
|
+
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14082
14238
|
}
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14239
|
+
}
|
|
14240
|
+
for (const variable of imports) {
|
|
14241
|
+
const module = variable.module;
|
|
14242
|
+
const name = variable.name;
|
|
14243
|
+
if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
|
|
14244
|
+
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14245
|
+
? externalChunkByModule.get(module)
|
|
14246
|
+
: chunkByModule.get(module)).variableName);
|
|
14086
14247
|
}
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14092
|
-
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14093
|
-
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14094
|
-
const containedPlaceholders = new Set();
|
|
14095
|
-
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14096
|
-
if (placeholders.has(placeholder)) {
|
|
14097
|
-
containedPlaceholders.add(placeholder);
|
|
14098
|
-
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14248
|
+
else if (module instanceof ExternalModule && name === 'default') {
|
|
14249
|
+
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
14250
|
+
? module.suggestedVariableName + '__default'
|
|
14251
|
+
: module.suggestedVariableName, usedNames));
|
|
14099
14252
|
}
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
return { containedPlaceholders, transformedCode };
|
|
14103
|
-
};
|
|
14104
|
-
|
|
14105
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
14106
|
-
if (isPathFragment(pattern))
|
|
14107
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14108
|
-
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14109
|
-
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14110
|
-
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14253
|
+
else {
|
|
14254
|
+
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
14111
14255
|
}
|
|
14112
|
-
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14113
|
-
if (isPathFragment(replacement))
|
|
14114
|
-
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14115
|
-
return replacement;
|
|
14116
|
-
});
|
|
14117
|
-
}
|
|
14118
|
-
function makeUnique(name, existingNames) {
|
|
14119
|
-
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14120
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14121
|
-
return name;
|
|
14122
|
-
const ext = extname(name);
|
|
14123
|
-
name = name.substring(0, name.length - ext.length);
|
|
14124
|
-
let uniqueName, uniqueIndex = 1;
|
|
14125
|
-
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14126
|
-
;
|
|
14127
|
-
return uniqueName;
|
|
14128
|
-
}
|
|
14129
|
-
|
|
14130
|
-
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
14131
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
14132
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
14133
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
14134
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
14135
|
-
ext: () => extname(emittedName).substring(1),
|
|
14136
|
-
extname: () => extname(emittedName),
|
|
14137
|
-
hash: size => createHash()
|
|
14138
|
-
.update(source)
|
|
14139
|
-
.digest('hex')
|
|
14140
|
-
.substring(0, size || defaultHashSize),
|
|
14141
|
-
name: () => emittedName.substring(0, emittedName.length - extname(emittedName).length)
|
|
14142
|
-
}), bundle);
|
|
14143
|
-
}
|
|
14144
|
-
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
14145
|
-
if (fileName in bundle) {
|
|
14146
|
-
warn(errFileNameConflict(fileName));
|
|
14147
14256
|
}
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
const FILE_PLACEHOLDER = {
|
|
14151
|
-
type: 'placeholder'
|
|
14152
|
-
};
|
|
14153
|
-
function hasValidType(emittedFile) {
|
|
14154
|
-
return Boolean(emittedFile &&
|
|
14155
|
-
(emittedFile.type === 'asset' ||
|
|
14156
|
-
emittedFile.type === 'chunk'));
|
|
14157
|
-
}
|
|
14158
|
-
function hasValidName(emittedFile) {
|
|
14159
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
14160
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
14161
|
-
}
|
|
14162
|
-
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
14163
|
-
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
14164
|
-
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
14165
|
-
return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
|
|
14257
|
+
for (const variable of syntheticExports) {
|
|
14258
|
+
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14166
14259
|
}
|
|
14167
|
-
return source;
|
|
14168
14260
|
}
|
|
14169
|
-
function
|
|
14170
|
-
|
|
14171
|
-
|
|
14261
|
+
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14262
|
+
for (const chunk of dependencies) {
|
|
14263
|
+
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14172
14264
|
}
|
|
14173
|
-
|
|
14174
|
-
}
|
|
14175
|
-
function getChunkFileName(file, facadeChunkByModule) {
|
|
14176
|
-
if (file.fileName) {
|
|
14177
|
-
return file.fileName;
|
|
14265
|
+
for (const chunk of deconflictedNamespace) {
|
|
14266
|
+
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14178
14267
|
}
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
this.graph = graph;
|
|
14188
|
-
this.options = options;
|
|
14189
|
-
this.bundle = null;
|
|
14190
|
-
this.facadeChunkByModule = null;
|
|
14191
|
-
this.outputOptions = null;
|
|
14192
|
-
this.emitFile = (emittedFile) => {
|
|
14193
|
-
if (!hasValidType(emittedFile)) {
|
|
14194
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
14195
|
-
}
|
|
14196
|
-
if (!hasValidName(emittedFile)) {
|
|
14197
|
-
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
14198
|
-
}
|
|
14199
|
-
if (emittedFile.type === 'chunk') {
|
|
14200
|
-
return this.emitChunk(emittedFile);
|
|
14201
|
-
}
|
|
14202
|
-
return this.emitAsset(emittedFile);
|
|
14203
|
-
};
|
|
14204
|
-
this.finaliseAssets = () => {
|
|
14205
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
14206
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
14207
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
14208
|
-
}
|
|
14209
|
-
};
|
|
14210
|
-
this.getFileName = (fileReferenceId) => {
|
|
14211
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
14212
|
-
if (!emittedFile)
|
|
14213
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
14214
|
-
if (emittedFile.type === 'chunk') {
|
|
14215
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
14216
|
-
}
|
|
14217
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
14218
|
-
};
|
|
14219
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
14220
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
14221
|
-
if (!consumedFile)
|
|
14222
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
14223
|
-
if (consumedFile.type !== 'asset') {
|
|
14224
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
14225
|
-
}
|
|
14226
|
-
if (consumedFile.source !== undefined) {
|
|
14227
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
14228
|
-
}
|
|
14229
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
14230
|
-
if (this.bundle) {
|
|
14231
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
14232
|
-
}
|
|
14233
|
-
else {
|
|
14234
|
-
consumedFile.source = source;
|
|
14235
|
-
}
|
|
14236
|
-
};
|
|
14237
|
-
this.setChunkInformation = (facadeChunkByModule) => {
|
|
14238
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
14239
|
-
};
|
|
14240
|
-
this.setOutputBundle = (outputBundle, outputOptions) => {
|
|
14241
|
-
this.outputOptions = outputOptions;
|
|
14242
|
-
this.bundle = outputBundle;
|
|
14243
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
14244
|
-
if (emittedFile.fileName) {
|
|
14245
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
14246
|
-
}
|
|
14247
|
-
}
|
|
14248
|
-
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
14249
|
-
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
14250
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
14251
|
-
}
|
|
14252
|
-
}
|
|
14253
|
-
};
|
|
14254
|
-
this.filesByReferenceId = baseFileEmitter
|
|
14255
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
14256
|
-
: new Map();
|
|
14257
|
-
}
|
|
14258
|
-
assignReferenceId(file, idBase) {
|
|
14259
|
-
let referenceId;
|
|
14260
|
-
do {
|
|
14261
|
-
referenceId = createHash()
|
|
14262
|
-
.update(referenceId || idBase)
|
|
14263
|
-
.digest('hex')
|
|
14264
|
-
.substring(0, 8);
|
|
14265
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
14266
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
14267
|
-
return referenceId;
|
|
14268
|
-
}
|
|
14269
|
-
emitAsset(emittedAsset) {
|
|
14270
|
-
const source = typeof emittedAsset.source !== 'undefined'
|
|
14271
|
-
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
14272
|
-
: undefined;
|
|
14273
|
-
const consumedAsset = {
|
|
14274
|
-
fileName: emittedAsset.fileName,
|
|
14275
|
-
name: emittedAsset.name,
|
|
14276
|
-
source,
|
|
14277
|
-
type: 'asset'
|
|
14278
|
-
};
|
|
14279
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
14280
|
-
if (this.bundle) {
|
|
14281
|
-
if (emittedAsset.fileName) {
|
|
14282
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
14283
|
-
}
|
|
14284
|
-
if (source !== undefined) {
|
|
14285
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
14286
|
-
}
|
|
14287
|
-
}
|
|
14288
|
-
return referenceId;
|
|
14289
|
-
}
|
|
14290
|
-
emitChunk(emittedChunk) {
|
|
14291
|
-
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
14292
|
-
return error(errInvalidRollupPhaseForChunkEmission());
|
|
14293
|
-
}
|
|
14294
|
-
if (typeof emittedChunk.id !== 'string') {
|
|
14295
|
-
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
14296
|
-
}
|
|
14297
|
-
const consumedChunk = {
|
|
14298
|
-
fileName: emittedChunk.fileName,
|
|
14299
|
-
module: null,
|
|
14300
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
14301
|
-
type: 'chunk'
|
|
14302
|
-
};
|
|
14303
|
-
this.graph.moduleLoader
|
|
14304
|
-
.emitChunk(emittedChunk)
|
|
14305
|
-
.then(module => (consumedChunk.module = module))
|
|
14306
|
-
.catch(() => {
|
|
14307
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
14308
|
-
// once module loading has finished
|
|
14309
|
-
});
|
|
14310
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
14311
|
-
}
|
|
14312
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
14313
|
-
const fileName = consumedFile.fileName ||
|
|
14314
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
14315
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
14316
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
14317
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
14318
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
14319
|
-
bundle[fileName] = {
|
|
14320
|
-
fileName,
|
|
14321
|
-
name: consumedFile.name,
|
|
14322
|
-
source,
|
|
14323
|
-
type: 'asset'
|
|
14324
|
-
};
|
|
14325
|
-
}
|
|
14326
|
-
}
|
|
14327
|
-
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
14328
|
-
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
14329
|
-
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
14330
|
-
return fileName;
|
|
14331
|
-
}
|
|
14332
|
-
return null;
|
|
14333
|
-
}
|
|
14334
|
-
function areSourcesEqual(sourceA, sourceB) {
|
|
14335
|
-
if (typeof sourceA === 'string') {
|
|
14336
|
-
return sourceA === sourceB;
|
|
14337
|
-
}
|
|
14338
|
-
if (typeof sourceB === 'string') {
|
|
14339
|
-
return false;
|
|
14340
|
-
}
|
|
14341
|
-
if ('equals' in sourceA) {
|
|
14342
|
-
return sourceA.equals(sourceB);
|
|
14343
|
-
}
|
|
14344
|
-
if (sourceA.length !== sourceB.length) {
|
|
14345
|
-
return false;
|
|
14346
|
-
}
|
|
14347
|
-
for (let index = 0; index < sourceA.length; index++) {
|
|
14348
|
-
if (sourceA[index] !== sourceB[index]) {
|
|
14349
|
-
return false;
|
|
14350
|
-
}
|
|
14351
|
-
}
|
|
14352
|
-
return true;
|
|
14353
|
-
}
|
|
14354
|
-
|
|
14355
|
-
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14356
|
-
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14357
|
-
async function createAddons(options, outputPluginDriver, chunk) {
|
|
14358
|
-
try {
|
|
14359
|
-
let [banner, footer, intro, outro] = await Promise.all([
|
|
14360
|
-
outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
|
|
14361
|
-
outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
|
|
14362
|
-
outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
|
|
14363
|
-
outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
|
|
14364
|
-
]);
|
|
14365
|
-
if (intro)
|
|
14366
|
-
intro += '\n\n';
|
|
14367
|
-
if (outro)
|
|
14368
|
-
outro = `\n\n${outro}`;
|
|
14369
|
-
if (banner)
|
|
14370
|
-
banner += '\n';
|
|
14371
|
-
if (footer)
|
|
14372
|
-
footer = '\n' + footer;
|
|
14373
|
-
return { banner, footer, intro, outro };
|
|
14374
|
-
}
|
|
14375
|
-
catch (err) {
|
|
14376
|
-
return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
|
|
14377
|
-
}
|
|
14378
|
-
}
|
|
14379
|
-
|
|
14380
|
-
const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
|
|
14381
|
-
amd: deconflictImportsOther,
|
|
14382
|
-
cjs: deconflictImportsOther,
|
|
14383
|
-
es: deconflictImportsEsmOrSystem,
|
|
14384
|
-
iife: deconflictImportsOther,
|
|
14385
|
-
system: deconflictImportsEsmOrSystem,
|
|
14386
|
-
umd: deconflictImportsOther
|
|
14387
|
-
};
|
|
14388
|
-
function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
|
|
14389
|
-
const reversedModules = modules.slice().reverse();
|
|
14390
|
-
for (const module of reversedModules) {
|
|
14391
|
-
module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14392
|
-
}
|
|
14393
|
-
deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
|
|
14394
|
-
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
|
|
14395
|
-
for (const module of reversedModules) {
|
|
14396
|
-
module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
14397
|
-
}
|
|
14398
|
-
}
|
|
14399
|
-
function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
|
|
14400
|
-
// This is needed for namespace reexports
|
|
14401
|
-
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14402
|
-
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14403
|
-
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14404
|
-
}
|
|
14405
|
-
}
|
|
14406
|
-
for (const variable of imports) {
|
|
14407
|
-
const module = variable.module;
|
|
14408
|
-
const name = variable.name;
|
|
14409
|
-
if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
|
|
14410
|
-
variable.setRenderNames(null, (module instanceof ExternalModule
|
|
14411
|
-
? externalChunkByModule.get(module)
|
|
14412
|
-
: chunkByModule.get(module)).variableName);
|
|
14413
|
-
}
|
|
14414
|
-
else if (module instanceof ExternalModule && name === 'default') {
|
|
14415
|
-
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
14416
|
-
? module.suggestedVariableName + '__default'
|
|
14417
|
-
: module.suggestedVariableName, usedNames));
|
|
14418
|
-
}
|
|
14419
|
-
else {
|
|
14420
|
-
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
14421
|
-
}
|
|
14422
|
-
}
|
|
14423
|
-
for (const variable of syntheticExports) {
|
|
14424
|
-
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14425
|
-
}
|
|
14426
|
-
}
|
|
14427
|
-
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14428
|
-
for (const chunk of dependencies) {
|
|
14429
|
-
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14430
|
-
}
|
|
14431
|
-
for (const chunk of deconflictedNamespace) {
|
|
14432
|
-
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14433
|
-
}
|
|
14434
|
-
for (const externalModule of deconflictedDefault) {
|
|
14435
|
-
if (deconflictedNamespace.has(externalModule) &&
|
|
14436
|
-
canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
|
|
14437
|
-
externalModule.defaultVariableName = externalModule.namespaceVariableName;
|
|
14438
|
-
}
|
|
14439
|
-
else {
|
|
14440
|
-
externalModule.defaultVariableName = getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
|
|
14441
|
-
}
|
|
14268
|
+
for (const externalModule of deconflictedDefault) {
|
|
14269
|
+
if (deconflictedNamespace.has(externalModule) &&
|
|
14270
|
+
canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
|
|
14271
|
+
externalModule.defaultVariableName = externalModule.namespaceVariableName;
|
|
14272
|
+
}
|
|
14273
|
+
else {
|
|
14274
|
+
externalModule.defaultVariableName = getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
|
|
14275
|
+
}
|
|
14442
14276
|
}
|
|
14443
14277
|
for (const variable of imports) {
|
|
14444
14278
|
const module = variable.module;
|
|
@@ -14624,6 +14458,93 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
|
|
|
14624
14458
|
}
|
|
14625
14459
|
}
|
|
14626
14460
|
|
|
14461
|
+
// Four random characters from the private use area to minimize risk of conflicts
|
|
14462
|
+
const hashPlaceholderLeft = '!~{';
|
|
14463
|
+
const hashPlaceholderRight = '}~';
|
|
14464
|
+
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
14465
|
+
// This is the size of a sha256
|
|
14466
|
+
const maxHashSize = 64;
|
|
14467
|
+
const defaultHashSize = 8;
|
|
14468
|
+
const getHashPlaceholderGenerator = () => {
|
|
14469
|
+
let nextIndex = 0;
|
|
14470
|
+
return (optionName, hashSize = defaultHashSize) => {
|
|
14471
|
+
if (hashSize > maxHashSize) {
|
|
14472
|
+
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14473
|
+
}
|
|
14474
|
+
const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
14475
|
+
if (placeholder.length > hashSize) {
|
|
14476
|
+
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.`));
|
|
14477
|
+
}
|
|
14478
|
+
return placeholder;
|
|
14479
|
+
};
|
|
14480
|
+
};
|
|
14481
|
+
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14482
|
+
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14483
|
+
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14484
|
+
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14485
|
+
const containedPlaceholders = new Set();
|
|
14486
|
+
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14487
|
+
if (placeholders.has(placeholder)) {
|
|
14488
|
+
containedPlaceholders.add(placeholder);
|
|
14489
|
+
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14490
|
+
}
|
|
14491
|
+
return placeholder;
|
|
14492
|
+
});
|
|
14493
|
+
return { containedPlaceholders, transformedCode };
|
|
14494
|
+
};
|
|
14495
|
+
|
|
14496
|
+
const lowercaseBundleKeys = Symbol('bundleKeys');
|
|
14497
|
+
const FILE_PLACEHOLDER = {
|
|
14498
|
+
type: 'placeholder'
|
|
14499
|
+
};
|
|
14500
|
+
const getOutputBundle = (outputBundleBase) => {
|
|
14501
|
+
const reservedLowercaseBundleKeys = new Set();
|
|
14502
|
+
return new Proxy(outputBundleBase, {
|
|
14503
|
+
deleteProperty(target, key) {
|
|
14504
|
+
if (typeof key === 'string') {
|
|
14505
|
+
reservedLowercaseBundleKeys.delete(key.toLowerCase());
|
|
14506
|
+
}
|
|
14507
|
+
return Reflect.deleteProperty(target, key);
|
|
14508
|
+
},
|
|
14509
|
+
get(target, key) {
|
|
14510
|
+
if (key === lowercaseBundleKeys) {
|
|
14511
|
+
return reservedLowercaseBundleKeys;
|
|
14512
|
+
}
|
|
14513
|
+
return Reflect.get(target, key);
|
|
14514
|
+
},
|
|
14515
|
+
set(target, key, value) {
|
|
14516
|
+
if (typeof key === 'string') {
|
|
14517
|
+
reservedLowercaseBundleKeys.add(key.toLowerCase());
|
|
14518
|
+
}
|
|
14519
|
+
return Reflect.set(target, key, value);
|
|
14520
|
+
}
|
|
14521
|
+
});
|
|
14522
|
+
};
|
|
14523
|
+
|
|
14524
|
+
function renderNamePattern(pattern, patternName, replacements) {
|
|
14525
|
+
if (isPathFragment(pattern))
|
|
14526
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14527
|
+
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14528
|
+
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14529
|
+
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14530
|
+
}
|
|
14531
|
+
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14532
|
+
if (isPathFragment(replacement))
|
|
14533
|
+
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14534
|
+
return replacement;
|
|
14535
|
+
});
|
|
14536
|
+
}
|
|
14537
|
+
function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
|
|
14538
|
+
if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
|
|
14539
|
+
return name;
|
|
14540
|
+
const ext = extname(name);
|
|
14541
|
+
name = name.substring(0, name.length - ext.length);
|
|
14542
|
+
let uniqueName, uniqueIndex = 1;
|
|
14543
|
+
while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14544
|
+
;
|
|
14545
|
+
return uniqueName;
|
|
14546
|
+
}
|
|
14547
|
+
|
|
14627
14548
|
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
|
|
14628
14549
|
function getGlobalName(chunk, globals, hasExports, warn) {
|
|
14629
14550
|
const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
|
|
@@ -14770,7 +14691,6 @@ class Chunk {
|
|
|
14770
14691
|
this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
|
|
14771
14692
|
}
|
|
14772
14693
|
generateFacades() {
|
|
14773
|
-
var _a;
|
|
14774
14694
|
const facades = [];
|
|
14775
14695
|
const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
|
|
14776
14696
|
const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
|
|
@@ -14827,7 +14747,7 @@ class Chunk {
|
|
|
14827
14747
|
this.canModuleBeFacade(module, exposedVariables)) {
|
|
14828
14748
|
this.strictFacade = true;
|
|
14829
14749
|
}
|
|
14830
|
-
else if (!
|
|
14750
|
+
else if (!this.facadeChunkByModule.get(module)?.strictFacade) {
|
|
14831
14751
|
this.includedNamespaces.add(module);
|
|
14832
14752
|
this.exports.add(module.namespace);
|
|
14833
14753
|
}
|
|
@@ -14856,22 +14776,18 @@ class Chunk {
|
|
|
14856
14776
|
};
|
|
14857
14777
|
}
|
|
14858
14778
|
getChunkName() {
|
|
14859
|
-
|
|
14860
|
-
return ((_a = this.name) !== null && _a !== void 0 ? _a : (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14779
|
+
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14861
14780
|
}
|
|
14862
14781
|
getExportNames() {
|
|
14863
|
-
|
|
14864
|
-
return ((_a = this.sortedExportNames) !== null && _a !== void 0 ? _a : (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14782
|
+
return (this.sortedExportNames ?? (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14865
14783
|
}
|
|
14866
14784
|
getFileName() {
|
|
14867
|
-
|
|
14868
|
-
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14785
|
+
return this.preliminaryFileName?.fileName || this.getPreliminaryFileName().fileName;
|
|
14869
14786
|
}
|
|
14870
14787
|
getImportPath(importer) {
|
|
14871
14788
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
14872
14789
|
}
|
|
14873
14790
|
getPreliminaryFileName() {
|
|
14874
|
-
var _a;
|
|
14875
14791
|
if (this.preliminaryFileName) {
|
|
14876
14792
|
return this.preliminaryFileName;
|
|
14877
14793
|
}
|
|
@@ -14885,7 +14801,7 @@ class Chunk {
|
|
|
14885
14801
|
fileName = this.fileName;
|
|
14886
14802
|
}
|
|
14887
14803
|
else {
|
|
14888
|
-
const [pattern, patternName] = preserveModules ||
|
|
14804
|
+
const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
|
|
14889
14805
|
? [entryFileNames, 'output.entryFileNames']
|
|
14890
14806
|
: [chunkFileNames, 'output.chunkFileNames'];
|
|
14891
14807
|
fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
@@ -14950,7 +14866,7 @@ class Chunk {
|
|
|
14950
14866
|
let hasExports = renderedExports.length !== 0;
|
|
14951
14867
|
let hasDefaultExport = false;
|
|
14952
14868
|
for (const { reexports } of renderedDependencies) {
|
|
14953
|
-
if (reexports
|
|
14869
|
+
if (reexports?.length) {
|
|
14954
14870
|
hasExports = true;
|
|
14955
14871
|
if (reexports.some(reexport => reexport.reexported === 'default')) {
|
|
14956
14872
|
hasDefaultExport = true;
|
|
@@ -15172,6 +15088,16 @@ class Chunk {
|
|
|
15172
15088
|
.filter((resolution) => resolution !== this &&
|
|
15173
15089
|
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
15174
15090
|
}
|
|
15091
|
+
getDynamicImportStringAndAssertions(resolution, fileName) {
|
|
15092
|
+
if (resolution instanceof ExternalModule) {
|
|
15093
|
+
const chunk = this.externalChunkByModule.get(resolution);
|
|
15094
|
+
return [`'${chunk.getImportPath(fileName)}'`, chunk.getImportAssertions(this.snippets)];
|
|
15095
|
+
}
|
|
15096
|
+
return [
|
|
15097
|
+
resolution || '',
|
|
15098
|
+
(this.outputOptions.format === 'es' && this.outputOptions.externalImportAssertions) || null
|
|
15099
|
+
];
|
|
15100
|
+
}
|
|
15175
15101
|
getFallbackChunkName() {
|
|
15176
15102
|
if (this.manualChunkAlias) {
|
|
15177
15103
|
return this.manualChunkAlias;
|
|
@@ -15249,7 +15175,7 @@ class Chunk {
|
|
|
15249
15175
|
exports: this.getExportNames(),
|
|
15250
15176
|
facadeModuleId: facadeModule && facadeModule.id,
|
|
15251
15177
|
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
15252
|
-
isEntry: !!
|
|
15178
|
+
isEntry: !!facadeModule?.info.isEntry,
|
|
15253
15179
|
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
15254
15180
|
moduleIds: this.orderedModules.map(({ id }) => id),
|
|
15255
15181
|
name: this.getChunkName(),
|
|
@@ -15348,6 +15274,7 @@ class Chunk {
|
|
|
15348
15274
|
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
15349
15275
|
const importPath = dep.getImportPath(fileName);
|
|
15350
15276
|
renderedDependencies.set(dep, {
|
|
15277
|
+
assertions: dep instanceof ExternalChunk ? dep.getImportAssertions(this.snippets) : null,
|
|
15351
15278
|
defaultVariableName: dep.defaultVariableName,
|
|
15352
15279
|
globalName: dep instanceof ExternalChunk &&
|
|
15353
15280
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
@@ -15431,8 +15358,7 @@ class Chunk {
|
|
|
15431
15358
|
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
15432
15359
|
renderedModules[module.id] = {
|
|
15433
15360
|
get code() {
|
|
15434
|
-
|
|
15435
|
-
return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
|
|
15361
|
+
return source?.toString() ?? null;
|
|
15436
15362
|
},
|
|
15437
15363
|
originalLength: module.originalCode.length,
|
|
15438
15364
|
removedExports,
|
|
@@ -15460,14 +15386,13 @@ class Chunk {
|
|
|
15460
15386
|
node.setInternalResolution(resolution.namespace);
|
|
15461
15387
|
}
|
|
15462
15388
|
else {
|
|
15463
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !
|
|
15389
|
+
node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null);
|
|
15464
15390
|
}
|
|
15465
15391
|
}
|
|
15466
15392
|
else {
|
|
15467
15393
|
const { resolution } = resolvedDynamicImport;
|
|
15468
|
-
|
|
15469
|
-
|
|
15470
|
-
: resolution || '', false);
|
|
15394
|
+
const [resolutionString, assertions] = this.getDynamicImportStringAndAssertions(resolution, fileName);
|
|
15395
|
+
resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, assertions);
|
|
15471
15396
|
}
|
|
15472
15397
|
}
|
|
15473
15398
|
}
|
|
@@ -15576,12 +15501,10 @@ class Chunk {
|
|
|
15576
15501
|
}
|
|
15577
15502
|
}
|
|
15578
15503
|
function getChunkNameFromModule(module) {
|
|
15579
|
-
|
|
15580
|
-
return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
|
|
15504
|
+
return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
|
|
15581
15505
|
}
|
|
15582
15506
|
function getPredefinedChunkNameFromModule(module) {
|
|
15583
|
-
|
|
15584
|
-
return ((_b = (_a = module.chunkNames.find(({ isUserDefined }) => isUserDefined)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = module.chunkNames[0]) === null || _c === void 0 ? void 0 : _c.name);
|
|
15507
|
+
return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
|
|
15585
15508
|
}
|
|
15586
15509
|
function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
|
|
15587
15510
|
const importedBindingsPerDependency = {};
|
|
@@ -16033,6 +15956,8 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
|
16033
15956
|
return { version: 3, ...map };
|
|
16034
15957
|
}
|
|
16035
15958
|
|
|
15959
|
+
const createHash = () => createHash$1('sha256');
|
|
15960
|
+
|
|
16036
15961
|
function decodedSourcemap(map) {
|
|
16037
15962
|
if (!map)
|
|
16038
15963
|
return null;
|
|
@@ -16051,7 +15976,7 @@ function decodedSourcemap(map) {
|
|
|
16051
15976
|
return { ...map, mappings };
|
|
16052
15977
|
}
|
|
16053
15978
|
|
|
16054
|
-
async function renderChunks(chunks,
|
|
15979
|
+
async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
|
|
16055
15980
|
timeStart('render chunks', 2);
|
|
16056
15981
|
reserveEntryChunksInBundle(chunks);
|
|
16057
15982
|
const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
|
|
@@ -16059,8 +15984,8 @@ async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, o
|
|
|
16059
15984
|
timeStart('transform chunks', 2);
|
|
16060
15985
|
const chunkGraph = getChunkGraph(chunks);
|
|
16061
15986
|
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
16062
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16063
|
-
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
15987
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
|
|
15988
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
16064
15989
|
timeEnd('transform chunks', 2);
|
|
16065
15990
|
}
|
|
16066
15991
|
function reserveEntryChunksInBundle(chunks) {
|
|
@@ -16175,7 +16100,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
16175
16100
|
renderedChunksByPlaceholder
|
|
16176
16101
|
};
|
|
16177
16102
|
}
|
|
16178
|
-
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16103
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
|
|
16179
16104
|
const hashesByPlaceholder = new Map();
|
|
16180
16105
|
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
16181
16106
|
let hash = createHash();
|
|
@@ -16198,13 +16123,13 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
16198
16123
|
}
|
|
16199
16124
|
finalHash = hash.digest('hex').slice(0, placeholder.length);
|
|
16200
16125
|
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
16201
|
-
} while (
|
|
16202
|
-
|
|
16203
|
-
hashesByPlaceholder.set(placeholder, finalHash
|
|
16126
|
+
} while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
|
|
16127
|
+
bundle[finalFileName] = FILE_PLACEHOLDER;
|
|
16128
|
+
hashesByPlaceholder.set(placeholder, finalHash);
|
|
16204
16129
|
}
|
|
16205
16130
|
return hashesByPlaceholder;
|
|
16206
16131
|
}
|
|
16207
|
-
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
16132
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
16208
16133
|
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16209
16134
|
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16210
16135
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
@@ -16212,7 +16137,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16212
16137
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16213
16138
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16214
16139
|
}
|
|
16215
|
-
|
|
16140
|
+
bundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16216
16141
|
}
|
|
16217
16142
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16218
16143
|
let updatedCode = hashesByPlaceholder.size
|
|
@@ -16221,7 +16146,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16221
16146
|
if (map) {
|
|
16222
16147
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16223
16148
|
}
|
|
16224
|
-
|
|
16149
|
+
bundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16225
16150
|
}
|
|
16226
16151
|
}
|
|
16227
16152
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -16251,7 +16176,8 @@ class Bundle {
|
|
|
16251
16176
|
}
|
|
16252
16177
|
async generate(isWrite) {
|
|
16253
16178
|
timeStart('GENERATE', 1);
|
|
16254
|
-
const
|
|
16179
|
+
const outputBundleBase = Object.create(null);
|
|
16180
|
+
const outputBundle = getOutputBundle(outputBundleBase);
|
|
16255
16181
|
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
|
|
16256
16182
|
try {
|
|
16257
16183
|
timeStart('initialize render', 2);
|
|
@@ -16283,7 +16209,7 @@ class Bundle {
|
|
|
16283
16209
|
this.finaliseAssets(outputBundle);
|
|
16284
16210
|
timeEnd('generate bundle', 2);
|
|
16285
16211
|
timeEnd('GENERATE', 1);
|
|
16286
|
-
return
|
|
16212
|
+
return outputBundleBase;
|
|
16287
16213
|
}
|
|
16288
16214
|
async addManualChunks(manualChunks) {
|
|
16289
16215
|
const manualChunkAliasByEntry = new Map();
|
|
@@ -16319,17 +16245,19 @@ class Bundle {
|
|
|
16319
16245
|
}
|
|
16320
16246
|
return manualChunkAliasByEntry;
|
|
16321
16247
|
}
|
|
16322
|
-
finaliseAssets(
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16248
|
+
finaliseAssets(bundle) {
|
|
16249
|
+
if (this.outputOptions.validate) {
|
|
16250
|
+
for (const file of Object.values(bundle)) {
|
|
16251
|
+
if ('code' in file) {
|
|
16252
|
+
try {
|
|
16253
|
+
this.graph.contextParse(file.code, {
|
|
16254
|
+
allowHashBang: true,
|
|
16255
|
+
ecmaVersion: 'latest'
|
|
16256
|
+
});
|
|
16257
|
+
}
|
|
16258
|
+
catch (err) {
|
|
16259
|
+
this.inputOptions.onwarn(errChunkInvalid(file, err));
|
|
16260
|
+
}
|
|
16333
16261
|
}
|
|
16334
16262
|
}
|
|
16335
16263
|
}
|
|
@@ -17462,7 +17390,7 @@ pp$8.parseForStatement = function(node) {
|
|
|
17462
17390
|
|
|
17463
17391
|
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
17464
17392
|
this.next();
|
|
17465
|
-
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
17393
|
+
return this.parseFunction(node, FUNC_STATEMENT$1 | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
17466
17394
|
};
|
|
17467
17395
|
|
|
17468
17396
|
pp$8.parseIfStatement = function(node) {
|
|
@@ -17726,7 +17654,7 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
17726
17654
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
17727
17655
|
};
|
|
17728
17656
|
|
|
17729
|
-
var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
|
|
17657
|
+
var FUNC_STATEMENT$1 = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID$1 = 4;
|
|
17730
17658
|
|
|
17731
17659
|
// Parse a function declaration or literal (depending on the
|
|
17732
17660
|
// `statement & FUNC_STATEMENT`).
|
|
@@ -17742,8 +17670,8 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17742
17670
|
if (this.options.ecmaVersion >= 8)
|
|
17743
17671
|
{ node.async = !!isAsync; }
|
|
17744
17672
|
|
|
17745
|
-
if (statement & FUNC_STATEMENT) {
|
|
17746
|
-
node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
|
|
17673
|
+
if (statement & FUNC_STATEMENT$1) {
|
|
17674
|
+
node.id = (statement & FUNC_NULLABLE_ID$1) && this.type !== types$1.name ? null : this.parseIdent();
|
|
17747
17675
|
if (node.id && !(statement & FUNC_HANGING_STATEMENT))
|
|
17748
17676
|
// If it is a regular function declaration in sloppy mode, then it is
|
|
17749
17677
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
|
@@ -17758,7 +17686,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17758
17686
|
this.awaitIdentPos = 0;
|
|
17759
17687
|
this.enterScope(functionFlags(node.async, node.generator));
|
|
17760
17688
|
|
|
17761
|
-
if (!(statement & FUNC_STATEMENT))
|
|
17689
|
+
if (!(statement & FUNC_STATEMENT$1))
|
|
17762
17690
|
{ node.id = this.type === types$1.name ? this.parseIdent() : null; }
|
|
17763
17691
|
|
|
17764
17692
|
this.parseFunctionParams(node);
|
|
@@ -17767,7 +17695,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17767
17695
|
this.yieldPos = oldYieldPos;
|
|
17768
17696
|
this.awaitPos = oldAwaitPos;
|
|
17769
17697
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
17770
|
-
return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17698
|
+
return this.finishNode(node, (statement & FUNC_STATEMENT$1) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17771
17699
|
};
|
|
17772
17700
|
|
|
17773
17701
|
pp$8.parseFunctionParams = function(node) {
|
|
@@ -18073,7 +18001,7 @@ pp$8.parseExport = function(node, exports) {
|
|
|
18073
18001
|
var fNode = this.startNode();
|
|
18074
18002
|
this.next();
|
|
18075
18003
|
if (isAsync) { this.next(); }
|
|
18076
|
-
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
18004
|
+
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync);
|
|
18077
18005
|
} else if (this.type === types$1._class) {
|
|
18078
18006
|
var cNode = this.startNode();
|
|
18079
18007
|
node.declaration = this.parseClass(cNode, "nullableID");
|
|
@@ -21958,7 +21886,59 @@ Parser.acorn = {
|
|
|
21958
21886
|
nonASCIIwhitespace: nonASCIIwhitespace
|
|
21959
21887
|
};
|
|
21960
21888
|
|
|
21961
|
-
|
|
21889
|
+
// The main exported interface (under `self.acorn` when in the
|
|
21890
|
+
// browser) is a `parse` function that takes a code string and
|
|
21891
|
+
// returns an abstract syntax tree as specified by [Mozilla parser
|
|
21892
|
+
// API][api].
|
|
21893
|
+
//
|
|
21894
|
+
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
|
|
21895
|
+
|
|
21896
|
+
function parse(input, options) {
|
|
21897
|
+
return Parser.parse(input, options)
|
|
21898
|
+
}
|
|
21899
|
+
|
|
21900
|
+
// This function tries to parse a single expression at a given
|
|
21901
|
+
// offset in a string. Useful for parsing mixed-language formats
|
|
21902
|
+
// that embed JavaScript expressions.
|
|
21903
|
+
|
|
21904
|
+
function parseExpressionAt(input, pos, options) {
|
|
21905
|
+
return Parser.parseExpressionAt(input, pos, options)
|
|
21906
|
+
}
|
|
21907
|
+
|
|
21908
|
+
// Acorn is organized as a tokenizer and a recursive-descent parser.
|
|
21909
|
+
// The `tokenizer` export provides an interface to the tokenizer.
|
|
21910
|
+
|
|
21911
|
+
function tokenizer(input, options) {
|
|
21912
|
+
return Parser.tokenizer(input, options)
|
|
21913
|
+
}
|
|
21914
|
+
|
|
21915
|
+
const acorn = /*#__PURE__*/Object.defineProperty({
|
|
21916
|
+
__proto__: null,
|
|
21917
|
+
Node,
|
|
21918
|
+
Parser,
|
|
21919
|
+
Position,
|
|
21920
|
+
SourceLocation,
|
|
21921
|
+
TokContext,
|
|
21922
|
+
Token,
|
|
21923
|
+
TokenType,
|
|
21924
|
+
defaultOptions,
|
|
21925
|
+
getLineInfo,
|
|
21926
|
+
isIdentifierChar,
|
|
21927
|
+
isIdentifierStart,
|
|
21928
|
+
isNewLine,
|
|
21929
|
+
keywordTypes: keywords,
|
|
21930
|
+
lineBreak,
|
|
21931
|
+
lineBreakG,
|
|
21932
|
+
nonASCIIwhitespace,
|
|
21933
|
+
parse,
|
|
21934
|
+
parseExpressionAt,
|
|
21935
|
+
tokContexts: types,
|
|
21936
|
+
tokTypes: types$1,
|
|
21937
|
+
tokenizer,
|
|
21938
|
+
version
|
|
21939
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
21940
|
+
|
|
21941
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
|
|
21962
21942
|
let skipped = null;
|
|
21963
21943
|
let replaceContext = null;
|
|
21964
21944
|
if (skip) {
|
|
@@ -21970,16 +21950,16 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
21970
21950
|
}
|
|
21971
21951
|
replaceContext = (pluginContext, plugin) => ({
|
|
21972
21952
|
...pluginContext,
|
|
21973
|
-
resolve: (source, importer, { custom, isEntry, skipSelf } = BLANK) => {
|
|
21974
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
21953
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
21954
|
+
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
21975
21955
|
}
|
|
21976
21956
|
});
|
|
21977
21957
|
}
|
|
21978
|
-
return pluginDriver.hookFirst('resolveId', [source, importer, { custom: customOptions, isEntry }], replaceContext, skipped);
|
|
21958
|
+
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
21979
21959
|
}
|
|
21980
21960
|
|
|
21981
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
|
|
21982
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry);
|
|
21961
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
|
|
21962
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions);
|
|
21983
21963
|
if (pluginResult != null)
|
|
21984
21964
|
return pluginResult;
|
|
21985
21965
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
@@ -21993,8 +21973,9 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
21993
21973
|
return addJsExtensionIfNecessary(importer ? resolve(dirname(importer), source) : resolve(source), preserveSymlinks);
|
|
21994
21974
|
}
|
|
21995
21975
|
async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
21996
|
-
|
|
21997
|
-
|
|
21976
|
+
return ((await findFile(file, preserveSymlinks)) ??
|
|
21977
|
+
(await findFile(file + '.mjs', preserveSymlinks)) ??
|
|
21978
|
+
(await findFile(file + '.js', preserveSymlinks)));
|
|
21998
21979
|
}
|
|
21999
21980
|
async function findFile(file, preserveSymlinks) {
|
|
22000
21981
|
try {
|
|
@@ -22228,11 +22209,9 @@ class ModuleLoader {
|
|
|
22228
22209
|
this.modulesWithLoadedDependencies = new Set();
|
|
22229
22210
|
this.nextChunkNamePriority = 0;
|
|
22230
22211
|
this.nextEntryModuleIndex = 0;
|
|
22231
|
-
this.resolveId = async (source, importer, customOptions, isEntry, skip = null) =>
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer), importer, source));
|
|
22235
|
-
};
|
|
22212
|
+
this.resolveId = async (source, importer, customOptions, isEntry, assertions, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
22213
|
+
? false
|
|
22214
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, assertions), importer, source), assertions);
|
|
22236
22215
|
this.hasModuleSideEffects = options.treeshake
|
|
22237
22216
|
? options.treeshake.moduleSideEffects
|
|
22238
22217
|
: () => true;
|
|
@@ -22290,7 +22269,7 @@ class ModuleLoader {
|
|
|
22290
22269
|
return module;
|
|
22291
22270
|
}
|
|
22292
22271
|
async preloadModule(resolvedId) {
|
|
22293
|
-
const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
|
|
22272
|
+
const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId, EMPTY_OBJECT), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
|
|
22294
22273
|
return module.info;
|
|
22295
22274
|
}
|
|
22296
22275
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
@@ -22313,7 +22292,7 @@ class ModuleLoader {
|
|
|
22313
22292
|
async addModuleSource(id, importer, module) {
|
|
22314
22293
|
let source;
|
|
22315
22294
|
try {
|
|
22316
|
-
source = await this.graph.fileOperationQueue.run(async () =>
|
|
22295
|
+
source = await this.graph.fileOperationQueue.run(async () => (await this.pluginDriver.hookFirst('load', [id])) ?? (await promises.readFile(id, 'utf8')));
|
|
22317
22296
|
}
|
|
22318
22297
|
catch (err) {
|
|
22319
22298
|
let msg = `Could not load ${id}`;
|
|
@@ -22388,16 +22367,21 @@ class ModuleLoader {
|
|
|
22388
22367
|
}
|
|
22389
22368
|
}
|
|
22390
22369
|
}
|
|
22391
|
-
// If this is a preload, then this method always waits for the dependencies of
|
|
22392
|
-
//
|
|
22393
|
-
// Otherwise it
|
|
22394
|
-
|
|
22370
|
+
// If this is a preload, then this method always waits for the dependencies of
|
|
22371
|
+
// the module to be resolved.
|
|
22372
|
+
// Otherwise, if the module does not exist, it waits for the module and all
|
|
22373
|
+
// its dependencies to be loaded.
|
|
22374
|
+
// Otherwise, it returns immediately.
|
|
22375
|
+
async fetchModule({ assertions, id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
|
|
22395
22376
|
const existingModule = this.modulesById.get(id);
|
|
22396
22377
|
if (existingModule instanceof Module) {
|
|
22378
|
+
if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
|
|
22379
|
+
this.options.onwarn(errInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
|
|
22380
|
+
}
|
|
22397
22381
|
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
22398
22382
|
return existingModule;
|
|
22399
22383
|
}
|
|
22400
|
-
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta);
|
|
22384
|
+
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions);
|
|
22401
22385
|
this.modulesById.set(id, module);
|
|
22402
22386
|
this.graph.watchFiles[id] = true;
|
|
22403
22387
|
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
@@ -22434,14 +22418,18 @@ class ModuleLoader {
|
|
|
22434
22418
|
}
|
|
22435
22419
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
22436
22420
|
if (resolvedId.external) {
|
|
22437
|
-
const { external, id, moduleSideEffects, meta } = resolvedId;
|
|
22438
|
-
|
|
22439
|
-
|
|
22421
|
+
const { assertions, external, id, moduleSideEffects, meta } = resolvedId;
|
|
22422
|
+
let externalModule = this.modulesById.get(id);
|
|
22423
|
+
if (!externalModule) {
|
|
22424
|
+
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id), assertions);
|
|
22425
|
+
this.modulesById.set(id, externalModule);
|
|
22440
22426
|
}
|
|
22441
|
-
|
|
22442
|
-
if (!(externalModule instanceof ExternalModule)) {
|
|
22427
|
+
else if (!(externalModule instanceof ExternalModule)) {
|
|
22443
22428
|
return error(errInternalIdCannotBeExternal(source, importer));
|
|
22444
22429
|
}
|
|
22430
|
+
else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
|
|
22431
|
+
this.options.onwarn(errInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
|
|
22432
|
+
}
|
|
22445
22433
|
return Promise.resolve(externalModule);
|
|
22446
22434
|
}
|
|
22447
22435
|
return this.fetchModule(resolvedId, importer, false, false);
|
|
@@ -22499,7 +22487,7 @@ class ModuleLoader {
|
|
|
22499
22487
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
22500
22488
|
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
22501
22489
|
? dynamicImport.argument
|
|
22502
|
-
: dynamicImport.argument.esTreeNode, module.id);
|
|
22490
|
+
: dynamicImport.argument.esTreeNode, module.id, getAssertionsFromImportExpression(dynamicImport.node));
|
|
22503
22491
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
22504
22492
|
dynamicImport.id = resolvedId.id;
|
|
22505
22493
|
}
|
|
@@ -22507,149 +22495,354 @@ class ModuleLoader {
|
|
|
22507
22495
|
});
|
|
22508
22496
|
}
|
|
22509
22497
|
getResolveStaticDependencyPromises(module) {
|
|
22510
|
-
return Array.from(module.
|
|
22498
|
+
return Array.from(module.sourcesWithAssertions, async ([source, assertions]) => [
|
|
22511
22499
|
source,
|
|
22512
22500
|
(module.resolvedIds[source] =
|
|
22513
22501
|
module.resolvedIds[source] ||
|
|
22514
|
-
this.
|
|
22502
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, assertions), source, module.id, assertions))
|
|
22515
22503
|
]);
|
|
22516
22504
|
}
|
|
22517
|
-
getResolvedIdWithDefaults(resolvedId) {
|
|
22518
|
-
var _a, _b;
|
|
22505
|
+
getResolvedIdWithDefaults(resolvedId, assertions) {
|
|
22519
22506
|
if (!resolvedId) {
|
|
22520
22507
|
return null;
|
|
22521
22508
|
}
|
|
22522
22509
|
const external = resolvedId.external || false;
|
|
22523
22510
|
return {
|
|
22511
|
+
assertions: resolvedId.assertions || assertions,
|
|
22524
22512
|
external,
|
|
22525
22513
|
id: resolvedId.id,
|
|
22526
22514
|
meta: resolvedId.meta || {},
|
|
22527
|
-
moduleSideEffects:
|
|
22528
|
-
syntheticNamedExports:
|
|
22515
|
+
moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
|
|
22516
|
+
syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
|
|
22517
|
+
};
|
|
22518
|
+
}
|
|
22519
|
+
async handleExistingModule(module, isEntry, isPreload) {
|
|
22520
|
+
const loadPromise = this.moduleLoadPromises.get(module);
|
|
22521
|
+
if (isPreload) {
|
|
22522
|
+
return isPreload === RESOLVE_DEPENDENCIES
|
|
22523
|
+
? waitForDependencyResolution(loadPromise)
|
|
22524
|
+
: loadPromise;
|
|
22525
|
+
}
|
|
22526
|
+
if (isEntry) {
|
|
22527
|
+
module.info.isEntry = true;
|
|
22528
|
+
this.implicitEntryModules.delete(module);
|
|
22529
|
+
for (const dependant of module.implicitlyLoadedAfter) {
|
|
22530
|
+
dependant.implicitlyLoadedBefore.delete(module);
|
|
22531
|
+
}
|
|
22532
|
+
module.implicitlyLoadedAfter.clear();
|
|
22533
|
+
}
|
|
22534
|
+
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22535
|
+
}
|
|
22536
|
+
handleInvalidResolvedId(resolvedId, source, importer, assertions) {
|
|
22537
|
+
if (resolvedId === null) {
|
|
22538
|
+
if (isRelative(source)) {
|
|
22539
|
+
return error(errUnresolvedImport(source, importer));
|
|
22540
|
+
}
|
|
22541
|
+
this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
22542
|
+
return {
|
|
22543
|
+
assertions,
|
|
22544
|
+
external: true,
|
|
22545
|
+
id: source,
|
|
22546
|
+
meta: {},
|
|
22547
|
+
moduleSideEffects: this.hasModuleSideEffects(source, true),
|
|
22548
|
+
syntheticNamedExports: false
|
|
22549
|
+
};
|
|
22550
|
+
}
|
|
22551
|
+
else if (resolvedId.external && resolvedId.syntheticNamedExports) {
|
|
22552
|
+
this.options.onwarn(errExternalSyntheticExports(source, importer));
|
|
22553
|
+
}
|
|
22554
|
+
return resolvedId;
|
|
22555
|
+
}
|
|
22556
|
+
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
|
|
22557
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
|
|
22558
|
+
if (resolveIdResult == null) {
|
|
22559
|
+
return error(implicitlyLoadedBefore === null
|
|
22560
|
+
? errUnresolvedEntry(unresolvedId)
|
|
22561
|
+
: errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
|
|
22562
|
+
}
|
|
22563
|
+
if (resolveIdResult === false ||
|
|
22564
|
+
(typeof resolveIdResult === 'object' && resolveIdResult.external)) {
|
|
22565
|
+
return error(implicitlyLoadedBefore === null
|
|
22566
|
+
? errEntryCannotBeExternal(unresolvedId)
|
|
22567
|
+
: errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
|
|
22568
|
+
}
|
|
22569
|
+
return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
|
|
22570
|
+
? resolveIdResult
|
|
22571
|
+
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
22572
|
+
}
|
|
22573
|
+
async resolveDynamicImport(module, specifier, importer, assertions) {
|
|
22574
|
+
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
22575
|
+
specifier,
|
|
22576
|
+
importer,
|
|
22577
|
+
{ assertions }
|
|
22578
|
+
]);
|
|
22579
|
+
if (typeof specifier !== 'string') {
|
|
22580
|
+
if (typeof resolution === 'string') {
|
|
22581
|
+
return resolution;
|
|
22582
|
+
}
|
|
22583
|
+
if (!resolution) {
|
|
22584
|
+
return null;
|
|
22585
|
+
}
|
|
22586
|
+
return this.getResolvedIdWithDefaults(resolution, assertions);
|
|
22587
|
+
}
|
|
22588
|
+
if (resolution == null) {
|
|
22589
|
+
const existingResolution = module.resolvedIds[specifier];
|
|
22590
|
+
if (existingResolution) {
|
|
22591
|
+
if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
|
|
22592
|
+
this.options.onwarn(errInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
|
|
22593
|
+
}
|
|
22594
|
+
return existingResolution;
|
|
22595
|
+
}
|
|
22596
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, assertions), specifier, module.id, assertions));
|
|
22597
|
+
}
|
|
22598
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), assertions), specifier, importer, assertions);
|
|
22599
|
+
}
|
|
22600
|
+
}
|
|
22601
|
+
function normalizeRelativeExternalId(source, importer) {
|
|
22602
|
+
return isRelative(source)
|
|
22603
|
+
? importer
|
|
22604
|
+
? resolve(importer, '..', source)
|
|
22605
|
+
: resolve(source)
|
|
22606
|
+
: source;
|
|
22607
|
+
}
|
|
22608
|
+
function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
|
|
22609
|
+
if (fileName !== null) {
|
|
22610
|
+
module.chunkFileNames.add(fileName);
|
|
22611
|
+
}
|
|
22612
|
+
else if (name !== null) {
|
|
22613
|
+
// Always keep chunkNames sorted by priority
|
|
22614
|
+
let namePosition = 0;
|
|
22615
|
+
while (module.chunkNames[namePosition]?.priority < priority)
|
|
22616
|
+
namePosition++;
|
|
22617
|
+
module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
|
|
22618
|
+
}
|
|
22619
|
+
}
|
|
22620
|
+
function isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) {
|
|
22621
|
+
return (makeAbsoluteExternalsRelative === true ||
|
|
22622
|
+
(makeAbsoluteExternalsRelative === 'ifRelativeSource' && isRelative(source)) ||
|
|
22623
|
+
!isAbsolute(id));
|
|
22624
|
+
}
|
|
22625
|
+
async function waitForDependencyResolution(loadPromise) {
|
|
22626
|
+
const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise;
|
|
22627
|
+
return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
|
|
22628
|
+
}
|
|
22629
|
+
|
|
22630
|
+
class GlobalScope extends Scope$1 {
|
|
22631
|
+
constructor() {
|
|
22632
|
+
super();
|
|
22633
|
+
this.parent = null;
|
|
22634
|
+
this.variables.set('undefined', new UndefinedVariable());
|
|
22635
|
+
}
|
|
22636
|
+
findVariable(name) {
|
|
22637
|
+
let variable = this.variables.get(name);
|
|
22638
|
+
if (!variable) {
|
|
22639
|
+
variable = new GlobalVariable(name);
|
|
22640
|
+
this.variables.set(name, variable);
|
|
22641
|
+
}
|
|
22642
|
+
return variable;
|
|
22643
|
+
}
|
|
22644
|
+
}
|
|
22645
|
+
|
|
22646
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
22647
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
22648
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
22649
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
22650
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
22651
|
+
ext: () => extname(emittedName).substring(1),
|
|
22652
|
+
extname: () => extname(emittedName),
|
|
22653
|
+
hash: size => createHash()
|
|
22654
|
+
.update(source)
|
|
22655
|
+
.digest('hex')
|
|
22656
|
+
.substring(0, size || defaultHashSize),
|
|
22657
|
+
name: () => emittedName.substring(0, emittedName.length - extname(emittedName).length)
|
|
22658
|
+
}), bundle);
|
|
22659
|
+
}
|
|
22660
|
+
function reserveFileNameInBundle(fileName, { bundle }, warn) {
|
|
22661
|
+
if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
|
|
22662
|
+
warn(errFileNameConflict(fileName));
|
|
22663
|
+
}
|
|
22664
|
+
else {
|
|
22665
|
+
bundle[fileName] = FILE_PLACEHOLDER;
|
|
22666
|
+
}
|
|
22667
|
+
}
|
|
22668
|
+
function hasValidType(emittedFile) {
|
|
22669
|
+
return Boolean(emittedFile &&
|
|
22670
|
+
(emittedFile.type === 'asset' ||
|
|
22671
|
+
emittedFile.type === 'chunk'));
|
|
22672
|
+
}
|
|
22673
|
+
function hasValidName(emittedFile) {
|
|
22674
|
+
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
22675
|
+
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
22676
|
+
}
|
|
22677
|
+
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
22678
|
+
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
22679
|
+
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
22680
|
+
return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
|
|
22681
|
+
}
|
|
22682
|
+
return source;
|
|
22683
|
+
}
|
|
22684
|
+
function getAssetFileName(file, referenceId) {
|
|
22685
|
+
if (typeof file.fileName !== 'string') {
|
|
22686
|
+
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
22687
|
+
}
|
|
22688
|
+
return file.fileName;
|
|
22689
|
+
}
|
|
22690
|
+
function getChunkFileName(file, facadeChunkByModule) {
|
|
22691
|
+
if (file.fileName) {
|
|
22692
|
+
return file.fileName;
|
|
22693
|
+
}
|
|
22694
|
+
if (facadeChunkByModule) {
|
|
22695
|
+
const chunk = facadeChunkByModule.get(file.module);
|
|
22696
|
+
return chunk.id || chunk.getFileName();
|
|
22697
|
+
}
|
|
22698
|
+
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
22699
|
+
}
|
|
22700
|
+
class FileEmitter {
|
|
22701
|
+
constructor(graph, options, baseFileEmitter) {
|
|
22702
|
+
this.graph = graph;
|
|
22703
|
+
this.options = options;
|
|
22704
|
+
this.facadeChunkByModule = null;
|
|
22705
|
+
this.nextIdBase = 1;
|
|
22706
|
+
this.output = null;
|
|
22707
|
+
this.emitFile = (emittedFile) => {
|
|
22708
|
+
if (!hasValidType(emittedFile)) {
|
|
22709
|
+
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
22710
|
+
}
|
|
22711
|
+
if (!hasValidName(emittedFile)) {
|
|
22712
|
+
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
22713
|
+
}
|
|
22714
|
+
if (emittedFile.type === 'chunk') {
|
|
22715
|
+
return this.emitChunk(emittedFile);
|
|
22716
|
+
}
|
|
22717
|
+
return this.emitAsset(emittedFile);
|
|
22718
|
+
};
|
|
22719
|
+
this.finaliseAssets = () => {
|
|
22720
|
+
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
22721
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
22722
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
22723
|
+
}
|
|
22724
|
+
};
|
|
22725
|
+
this.getFileName = (fileReferenceId) => {
|
|
22726
|
+
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
22727
|
+
if (!emittedFile)
|
|
22728
|
+
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
22729
|
+
if (emittedFile.type === 'chunk') {
|
|
22730
|
+
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
22731
|
+
}
|
|
22732
|
+
return getAssetFileName(emittedFile, fileReferenceId);
|
|
22733
|
+
};
|
|
22734
|
+
this.setAssetSource = (referenceId, requestedSource) => {
|
|
22735
|
+
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
22736
|
+
if (!consumedFile)
|
|
22737
|
+
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
22738
|
+
if (consumedFile.type !== 'asset') {
|
|
22739
|
+
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
22740
|
+
}
|
|
22741
|
+
if (consumedFile.source !== undefined) {
|
|
22742
|
+
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
22743
|
+
}
|
|
22744
|
+
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
22745
|
+
if (this.output) {
|
|
22746
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.output);
|
|
22747
|
+
}
|
|
22748
|
+
else {
|
|
22749
|
+
consumedFile.source = source;
|
|
22750
|
+
}
|
|
22751
|
+
};
|
|
22752
|
+
this.setChunkInformation = (facadeChunkByModule) => {
|
|
22753
|
+
this.facadeChunkByModule = facadeChunkByModule;
|
|
22754
|
+
};
|
|
22755
|
+
this.setOutputBundle = (bundle, outputOptions) => {
|
|
22756
|
+
const fileNamesBySource = new Map();
|
|
22757
|
+
const output = (this.output = { bundle, fileNamesBySource, outputOptions });
|
|
22758
|
+
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
22759
|
+
if (emittedFile.fileName) {
|
|
22760
|
+
reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
|
|
22761
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
|
|
22762
|
+
fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
|
|
22763
|
+
}
|
|
22764
|
+
}
|
|
22765
|
+
}
|
|
22766
|
+
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
22767
|
+
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
22768
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, output);
|
|
22769
|
+
}
|
|
22770
|
+
}
|
|
22771
|
+
};
|
|
22772
|
+
this.filesByReferenceId = baseFileEmitter
|
|
22773
|
+
? new Map(baseFileEmitter.filesByReferenceId)
|
|
22774
|
+
: new Map();
|
|
22775
|
+
}
|
|
22776
|
+
assignReferenceId(file, idBase) {
|
|
22777
|
+
let referenceId;
|
|
22778
|
+
do {
|
|
22779
|
+
referenceId = createHash()
|
|
22780
|
+
.update(referenceId || idBase)
|
|
22781
|
+
.digest('hex')
|
|
22782
|
+
.substring(0, 8);
|
|
22783
|
+
} while (this.filesByReferenceId.has(referenceId));
|
|
22784
|
+
this.filesByReferenceId.set(referenceId, file);
|
|
22785
|
+
return referenceId;
|
|
22786
|
+
}
|
|
22787
|
+
emitAsset(emittedAsset) {
|
|
22788
|
+
const source = typeof emittedAsset.source !== 'undefined'
|
|
22789
|
+
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
22790
|
+
: undefined;
|
|
22791
|
+
const consumedAsset = {
|
|
22792
|
+
fileName: emittedAsset.fileName,
|
|
22793
|
+
name: emittedAsset.name,
|
|
22794
|
+
source,
|
|
22795
|
+
type: 'asset'
|
|
22529
22796
|
};
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
return isPreload === RESOLVE_DEPENDENCIES
|
|
22535
|
-
? waitForDependencyResolution(loadPromise)
|
|
22536
|
-
: loadPromise;
|
|
22537
|
-
}
|
|
22538
|
-
if (isEntry) {
|
|
22539
|
-
module.info.isEntry = true;
|
|
22540
|
-
this.implicitEntryModules.delete(module);
|
|
22541
|
-
for (const dependant of module.implicitlyLoadedAfter) {
|
|
22542
|
-
dependant.implicitlyLoadedBefore.delete(module);
|
|
22797
|
+
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || String(this.nextIdBase++));
|
|
22798
|
+
if (this.output) {
|
|
22799
|
+
if (emittedAsset.fileName) {
|
|
22800
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.output, this.options.onwarn);
|
|
22543
22801
|
}
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22547
|
-
}
|
|
22548
|
-
handleResolveId(resolvedId, source, importer) {
|
|
22549
|
-
if (resolvedId === null) {
|
|
22550
|
-
if (isRelative(source)) {
|
|
22551
|
-
return error(errUnresolvedImport(source, importer));
|
|
22802
|
+
if (source !== undefined) {
|
|
22803
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.output);
|
|
22552
22804
|
}
|
|
22553
|
-
this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
22554
|
-
return {
|
|
22555
|
-
external: true,
|
|
22556
|
-
id: source,
|
|
22557
|
-
meta: {},
|
|
22558
|
-
moduleSideEffects: this.hasModuleSideEffects(source, true),
|
|
22559
|
-
syntheticNamedExports: false
|
|
22560
|
-
};
|
|
22561
|
-
}
|
|
22562
|
-
else if (resolvedId.external && resolvedId.syntheticNamedExports) {
|
|
22563
|
-
this.options.onwarn(errExternalSyntheticExports(source, importer));
|
|
22564
|
-
}
|
|
22565
|
-
return resolvedId;
|
|
22566
|
-
}
|
|
22567
|
-
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
|
|
22568
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true);
|
|
22569
|
-
if (resolveIdResult == null) {
|
|
22570
|
-
return error(implicitlyLoadedBefore === null
|
|
22571
|
-
? errUnresolvedEntry(unresolvedId)
|
|
22572
|
-
: errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
|
|
22573
|
-
}
|
|
22574
|
-
if (resolveIdResult === false ||
|
|
22575
|
-
(typeof resolveIdResult === 'object' && resolveIdResult.external)) {
|
|
22576
|
-
return error(implicitlyLoadedBefore === null
|
|
22577
|
-
? errEntryCannotBeExternal(unresolvedId)
|
|
22578
|
-
: errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
|
|
22579
22805
|
}
|
|
22580
|
-
return
|
|
22581
|
-
? resolveIdResult
|
|
22582
|
-
: { id: resolveIdResult }), undefined, isEntry, false);
|
|
22806
|
+
return referenceId;
|
|
22583
22807
|
}
|
|
22584
|
-
|
|
22585
|
-
|
|
22586
|
-
|
|
22587
|
-
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
22588
|
-
specifier,
|
|
22589
|
-
importer
|
|
22590
|
-
]);
|
|
22591
|
-
if (typeof specifier !== 'string') {
|
|
22592
|
-
if (typeof resolution === 'string') {
|
|
22593
|
-
return resolution;
|
|
22594
|
-
}
|
|
22595
|
-
if (!resolution) {
|
|
22596
|
-
return null;
|
|
22597
|
-
}
|
|
22598
|
-
return {
|
|
22599
|
-
external: false,
|
|
22600
|
-
moduleSideEffects: true,
|
|
22601
|
-
...resolution
|
|
22602
|
-
};
|
|
22808
|
+
emitChunk(emittedChunk) {
|
|
22809
|
+
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
22810
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
22603
22811
|
}
|
|
22604
|
-
if (
|
|
22605
|
-
return ((
|
|
22812
|
+
if (typeof emittedChunk.id !== 'string') {
|
|
22813
|
+
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
22606
22814
|
}
|
|
22607
|
-
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
}
|
|
22622
|
-
else if (name !== null) {
|
|
22623
|
-
// Always keep chunkNames sorted by priority
|
|
22624
|
-
let namePosition = 0;
|
|
22625
|
-
while (((_a = module.chunkNames[namePosition]) === null || _a === void 0 ? void 0 : _a.priority) < priority)
|
|
22626
|
-
namePosition++;
|
|
22627
|
-
module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
|
|
22628
|
-
}
|
|
22629
|
-
}
|
|
22630
|
-
function isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) {
|
|
22631
|
-
return (makeAbsoluteExternalsRelative === true ||
|
|
22632
|
-
(makeAbsoluteExternalsRelative === 'ifRelativeSource' && isRelative(source)) ||
|
|
22633
|
-
!isAbsolute(id));
|
|
22634
|
-
}
|
|
22635
|
-
async function waitForDependencyResolution(loadPromise) {
|
|
22636
|
-
const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise;
|
|
22637
|
-
return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
|
|
22638
|
-
}
|
|
22639
|
-
|
|
22640
|
-
class GlobalScope extends Scope$1 {
|
|
22641
|
-
constructor() {
|
|
22642
|
-
super();
|
|
22643
|
-
this.parent = null;
|
|
22644
|
-
this.variables.set('undefined', new UndefinedVariable());
|
|
22815
|
+
const consumedChunk = {
|
|
22816
|
+
fileName: emittedChunk.fileName,
|
|
22817
|
+
module: null,
|
|
22818
|
+
name: emittedChunk.name || emittedChunk.id,
|
|
22819
|
+
type: 'chunk'
|
|
22820
|
+
};
|
|
22821
|
+
this.graph.moduleLoader
|
|
22822
|
+
.emitChunk(emittedChunk)
|
|
22823
|
+
.then(module => (consumedChunk.module = module))
|
|
22824
|
+
.catch(() => {
|
|
22825
|
+
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
22826
|
+
// once module loading has finished
|
|
22827
|
+
});
|
|
22828
|
+
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
22645
22829
|
}
|
|
22646
|
-
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
22830
|
+
finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
|
|
22831
|
+
const fileName = consumedFile.fileName ||
|
|
22832
|
+
(typeof source === 'string' && fileNamesBySource.get(source)) ||
|
|
22833
|
+
generateAssetFileName(consumedFile.name, source, outputOptions, bundle);
|
|
22834
|
+
// We must not modify the original assets to avoid interaction between outputs
|
|
22835
|
+
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
22836
|
+
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
22837
|
+
if (typeof source === 'string') {
|
|
22838
|
+
fileNamesBySource.set(source, fileName);
|
|
22651
22839
|
}
|
|
22652
|
-
|
|
22840
|
+
bundle[fileName] = {
|
|
22841
|
+
fileName,
|
|
22842
|
+
name: consumedFile.name,
|
|
22843
|
+
source,
|
|
22844
|
+
type: 'asset'
|
|
22845
|
+
};
|
|
22653
22846
|
}
|
|
22654
22847
|
}
|
|
22655
22848
|
|
|
@@ -22712,8 +22905,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22712
22905
|
return wrappedModuleIds();
|
|
22713
22906
|
},
|
|
22714
22907
|
parse: graph.contextParse.bind(graph),
|
|
22715
|
-
resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
|
|
22716
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22908
|
+
resolve(source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) {
|
|
22909
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22717
22910
|
},
|
|
22718
22911
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22719
22912
|
warn(warning) {
|
|
@@ -22888,7 +23081,7 @@ class PluginDriver {
|
|
|
22888
23081
|
}
|
|
22889
23082
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22890
23083
|
const hookResult = handler.apply(context, args);
|
|
22891
|
-
if (!
|
|
23084
|
+
if (!hookResult?.then) {
|
|
22892
23085
|
// short circuit for non-thenables and non-Promises
|
|
22893
23086
|
return hookResult;
|
|
22894
23087
|
}
|
|
@@ -23028,7 +23221,6 @@ function normalizeEntryModules(entryModules) {
|
|
|
23028
23221
|
}
|
|
23029
23222
|
class Graph {
|
|
23030
23223
|
constructor(options, watcher) {
|
|
23031
|
-
var _a, _b;
|
|
23032
23224
|
this.options = options;
|
|
23033
23225
|
this.cachedModules = new Map();
|
|
23034
23226
|
this.deoptimizationTracker = new PathTracker();
|
|
@@ -23049,11 +23241,11 @@ class Graph {
|
|
|
23049
23241
|
return foundModule.info;
|
|
23050
23242
|
};
|
|
23051
23243
|
if (options.cache !== false) {
|
|
23052
|
-
if (
|
|
23244
|
+
if (options.cache?.modules) {
|
|
23053
23245
|
for (const module of options.cache.modules)
|
|
23054
23246
|
this.cachedModules.set(module.id, module);
|
|
23055
23247
|
}
|
|
23056
|
-
this.pluginCache =
|
|
23248
|
+
this.pluginCache = options.cache?.plugins || Object.create(null);
|
|
23057
23249
|
// increment access counter
|
|
23058
23250
|
for (const name in this.pluginCache) {
|
|
23059
23251
|
const cache = this.pluginCache[name];
|
|
@@ -23260,6 +23452,295 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
23260
23452
|
return result;
|
|
23261
23453
|
}
|
|
23262
23454
|
|
|
23455
|
+
var lib = {};
|
|
23456
|
+
|
|
23457
|
+
const require$$0 = /*@__PURE__*/getAugmentedNamespace(acorn);
|
|
23458
|
+
|
|
23459
|
+
Object.defineProperty(lib, "__esModule", {
|
|
23460
|
+
value: true
|
|
23461
|
+
});
|
|
23462
|
+
var importAssertions_1 = lib.importAssertions = importAssertions;
|
|
23463
|
+
|
|
23464
|
+
var _acorn = _interopRequireWildcard(require$$0);
|
|
23465
|
+
|
|
23466
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23467
|
+
|
|
23468
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23469
|
+
|
|
23470
|
+
const leftCurlyBrace = "{".charCodeAt(0);
|
|
23471
|
+
const space = " ".charCodeAt(0);
|
|
23472
|
+
const keyword = "assert";
|
|
23473
|
+
const FUNC_STATEMENT = 1,
|
|
23474
|
+
FUNC_NULLABLE_ID = 4;
|
|
23475
|
+
|
|
23476
|
+
function importAssertions(Parser) {
|
|
23477
|
+
// Use supplied version acorn version if present, to avoid
|
|
23478
|
+
// reference mismatches due to different acorn versions. This
|
|
23479
|
+
// allows this plugin to be used with Rollup which supplies
|
|
23480
|
+
// its own internal version of acorn and thereby sidesteps
|
|
23481
|
+
// the package manager.
|
|
23482
|
+
const acorn = Parser.acorn || _acorn;
|
|
23483
|
+
const {
|
|
23484
|
+
tokTypes: tt,
|
|
23485
|
+
TokenType
|
|
23486
|
+
} = acorn;
|
|
23487
|
+
return class extends Parser {
|
|
23488
|
+
constructor(...args) {
|
|
23489
|
+
super(...args);
|
|
23490
|
+
this.assertToken = new TokenType(keyword);
|
|
23491
|
+
}
|
|
23492
|
+
|
|
23493
|
+
_codeAt(i) {
|
|
23494
|
+
return this.input.charCodeAt(i);
|
|
23495
|
+
}
|
|
23496
|
+
|
|
23497
|
+
_eat(t) {
|
|
23498
|
+
if (this.type !== t) {
|
|
23499
|
+
this.unexpected();
|
|
23500
|
+
}
|
|
23501
|
+
|
|
23502
|
+
this.next();
|
|
23503
|
+
}
|
|
23504
|
+
|
|
23505
|
+
readToken(code) {
|
|
23506
|
+
let i = 0;
|
|
23507
|
+
|
|
23508
|
+
for (; i < keyword.length; i++) {
|
|
23509
|
+
if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
|
|
23510
|
+
return super.readToken(code);
|
|
23511
|
+
}
|
|
23512
|
+
} // ensure that the keyword is at the correct location
|
|
23513
|
+
// ie `assert{...` or `assert {...`
|
|
23514
|
+
|
|
23515
|
+
|
|
23516
|
+
for (;; i++) {
|
|
23517
|
+
if (this._codeAt(this.pos + i) === leftCurlyBrace) {
|
|
23518
|
+
// Found '{'
|
|
23519
|
+
break;
|
|
23520
|
+
} else if (this._codeAt(this.pos + i) === space) {
|
|
23521
|
+
// white space is allowed between `assert` and `{`, so continue.
|
|
23522
|
+
continue;
|
|
23523
|
+
} else {
|
|
23524
|
+
return super.readToken(code);
|
|
23525
|
+
}
|
|
23526
|
+
} // If we're inside a dynamic import expression we'll parse
|
|
23527
|
+
// the `assert` keyword as a standard object property name
|
|
23528
|
+
// ie `import(""./foo.json", { assert: { type: "json" } })`
|
|
23529
|
+
|
|
23530
|
+
|
|
23531
|
+
if (this.type.label === "{") {
|
|
23532
|
+
return super.readToken(code);
|
|
23533
|
+
}
|
|
23534
|
+
|
|
23535
|
+
this.pos += keyword.length;
|
|
23536
|
+
return this.finishToken(this.assertToken);
|
|
23537
|
+
}
|
|
23538
|
+
|
|
23539
|
+
parseDynamicImport(node) {
|
|
23540
|
+
this.next(); // skip `(`
|
|
23541
|
+
// Parse node.source.
|
|
23542
|
+
|
|
23543
|
+
node.source = this.parseMaybeAssign();
|
|
23544
|
+
|
|
23545
|
+
if (this.eat(tt.comma)) {
|
|
23546
|
+
const obj = this.parseObj(false);
|
|
23547
|
+
node.arguments = [obj];
|
|
23548
|
+
}
|
|
23549
|
+
|
|
23550
|
+
this._eat(tt.parenR);
|
|
23551
|
+
|
|
23552
|
+
return this.finishNode(node, "ImportExpression");
|
|
23553
|
+
} // ported from acorn/src/statement.js pp.parseExport
|
|
23554
|
+
|
|
23555
|
+
|
|
23556
|
+
parseExport(node, exports) {
|
|
23557
|
+
this.next(); // export * from '...'
|
|
23558
|
+
|
|
23559
|
+
if (this.eat(tt.star)) {
|
|
23560
|
+
if (this.options.ecmaVersion >= 11) {
|
|
23561
|
+
if (this.eatContextual("as")) {
|
|
23562
|
+
node.exported = this.parseIdent(true);
|
|
23563
|
+
this.checkExport(exports, node.exported.name, this.lastTokStart);
|
|
23564
|
+
} else {
|
|
23565
|
+
node.exported = null;
|
|
23566
|
+
}
|
|
23567
|
+
}
|
|
23568
|
+
|
|
23569
|
+
this.expectContextual("from");
|
|
23570
|
+
|
|
23571
|
+
if (this.type !== tt.string) {
|
|
23572
|
+
this.unexpected();
|
|
23573
|
+
}
|
|
23574
|
+
|
|
23575
|
+
node.source = this.parseExprAtom();
|
|
23576
|
+
|
|
23577
|
+
if (this.type === this.assertToken) {
|
|
23578
|
+
this.next();
|
|
23579
|
+
const assertions = this.parseImportAssertions();
|
|
23580
|
+
|
|
23581
|
+
if (assertions) {
|
|
23582
|
+
node.assertions = assertions;
|
|
23583
|
+
}
|
|
23584
|
+
}
|
|
23585
|
+
|
|
23586
|
+
this.semicolon();
|
|
23587
|
+
return this.finishNode(node, "ExportAllDeclaration");
|
|
23588
|
+
}
|
|
23589
|
+
|
|
23590
|
+
if (this.eat(tt._default)) {
|
|
23591
|
+
// export default ...
|
|
23592
|
+
this.checkExport(exports, "default", this.lastTokStart);
|
|
23593
|
+
var isAsync;
|
|
23594
|
+
|
|
23595
|
+
if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
|
|
23596
|
+
var fNode = this.startNode();
|
|
23597
|
+
this.next();
|
|
23598
|
+
|
|
23599
|
+
if (isAsync) {
|
|
23600
|
+
this.next();
|
|
23601
|
+
}
|
|
23602
|
+
|
|
23603
|
+
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
23604
|
+
} else if (this.type === tt._class) {
|
|
23605
|
+
var cNode = this.startNode();
|
|
23606
|
+
node.declaration = this.parseClass(cNode, "nullableID");
|
|
23607
|
+
} else {
|
|
23608
|
+
node.declaration = this.parseMaybeAssign();
|
|
23609
|
+
this.semicolon();
|
|
23610
|
+
}
|
|
23611
|
+
|
|
23612
|
+
return this.finishNode(node, "ExportDefaultDeclaration");
|
|
23613
|
+
} // export var|const|let|function|class ...
|
|
23614
|
+
|
|
23615
|
+
|
|
23616
|
+
if (this.shouldParseExportStatement()) {
|
|
23617
|
+
node.declaration = this.parseStatement(null);
|
|
23618
|
+
|
|
23619
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
23620
|
+
this.checkVariableExport(exports, node.declaration.declarations);
|
|
23621
|
+
} else {
|
|
23622
|
+
this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
|
|
23623
|
+
}
|
|
23624
|
+
|
|
23625
|
+
node.specifiers = [];
|
|
23626
|
+
node.source = null;
|
|
23627
|
+
} else {
|
|
23628
|
+
// export { x, y as z } [from '...']
|
|
23629
|
+
node.declaration = null;
|
|
23630
|
+
node.specifiers = this.parseExportSpecifiers(exports);
|
|
23631
|
+
|
|
23632
|
+
if (this.eatContextual("from")) {
|
|
23633
|
+
if (this.type !== tt.string) {
|
|
23634
|
+
this.unexpected();
|
|
23635
|
+
}
|
|
23636
|
+
|
|
23637
|
+
node.source = this.parseExprAtom();
|
|
23638
|
+
|
|
23639
|
+
if (this.type === this.assertToken) {
|
|
23640
|
+
this.next();
|
|
23641
|
+
const assertions = this.parseImportAssertions();
|
|
23642
|
+
|
|
23643
|
+
if (assertions) {
|
|
23644
|
+
node.assertions = assertions;
|
|
23645
|
+
}
|
|
23646
|
+
}
|
|
23647
|
+
} else {
|
|
23648
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
23649
|
+
// check for keywords used as local names
|
|
23650
|
+
var spec = list[i];
|
|
23651
|
+
this.checkUnreserved(spec.local); // check if export is defined
|
|
23652
|
+
|
|
23653
|
+
this.checkLocalExport(spec.local);
|
|
23654
|
+
}
|
|
23655
|
+
|
|
23656
|
+
node.source = null;
|
|
23657
|
+
}
|
|
23658
|
+
|
|
23659
|
+
this.semicolon();
|
|
23660
|
+
}
|
|
23661
|
+
|
|
23662
|
+
return this.finishNode(node, "ExportNamedDeclaration");
|
|
23663
|
+
}
|
|
23664
|
+
|
|
23665
|
+
parseImport(node) {
|
|
23666
|
+
this.next(); // import '...'
|
|
23667
|
+
|
|
23668
|
+
if (this.type === tt.string) {
|
|
23669
|
+
node.specifiers = [];
|
|
23670
|
+
node.source = this.parseExprAtom();
|
|
23671
|
+
} else {
|
|
23672
|
+
node.specifiers = this.parseImportSpecifiers();
|
|
23673
|
+
this.expectContextual("from");
|
|
23674
|
+
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
|
23675
|
+
}
|
|
23676
|
+
|
|
23677
|
+
if (this.type === this.assertToken) {
|
|
23678
|
+
this.next();
|
|
23679
|
+
const assertions = this.parseImportAssertions();
|
|
23680
|
+
|
|
23681
|
+
if (assertions) {
|
|
23682
|
+
node.assertions = assertions;
|
|
23683
|
+
}
|
|
23684
|
+
}
|
|
23685
|
+
|
|
23686
|
+
this.semicolon();
|
|
23687
|
+
return this.finishNode(node, "ImportDeclaration");
|
|
23688
|
+
}
|
|
23689
|
+
|
|
23690
|
+
parseImportAssertions() {
|
|
23691
|
+
this._eat(tt.braceL);
|
|
23692
|
+
|
|
23693
|
+
const attrs = this.parseAssertEntries();
|
|
23694
|
+
|
|
23695
|
+
this._eat(tt.braceR);
|
|
23696
|
+
|
|
23697
|
+
return attrs;
|
|
23698
|
+
}
|
|
23699
|
+
|
|
23700
|
+
parseAssertEntries() {
|
|
23701
|
+
const attrs = [];
|
|
23702
|
+
const attrNames = new Set();
|
|
23703
|
+
|
|
23704
|
+
do {
|
|
23705
|
+
if (this.type === tt.braceR) {
|
|
23706
|
+
break;
|
|
23707
|
+
}
|
|
23708
|
+
|
|
23709
|
+
const node = this.startNode(); // parse AssertionKey : IdentifierName, StringLiteral
|
|
23710
|
+
|
|
23711
|
+
let assertionKeyNode;
|
|
23712
|
+
|
|
23713
|
+
if (this.type === tt.string) {
|
|
23714
|
+
assertionKeyNode = this.parseLiteral(this.value);
|
|
23715
|
+
} else {
|
|
23716
|
+
assertionKeyNode = this.parseIdent(true);
|
|
23717
|
+
}
|
|
23718
|
+
|
|
23719
|
+
this.next();
|
|
23720
|
+
node.key = assertionKeyNode; // check if we already have an entry for an attribute
|
|
23721
|
+
// if a duplicate entry is found, throw an error
|
|
23722
|
+
// for now this logic will come into play only when someone declares `type` twice
|
|
23723
|
+
|
|
23724
|
+
if (attrNames.has(node.key.name)) {
|
|
23725
|
+
this.raise(this.pos, "Duplicated key in assertions");
|
|
23726
|
+
}
|
|
23727
|
+
|
|
23728
|
+
attrNames.add(node.key.name);
|
|
23729
|
+
|
|
23730
|
+
if (this.type !== tt.string) {
|
|
23731
|
+
this.raise(this.pos, "Only string is supported as an assertion value");
|
|
23732
|
+
}
|
|
23733
|
+
|
|
23734
|
+
node.value = this.parseLiteral(this.value);
|
|
23735
|
+
attrs.push(this.finishNode(node, "ImportAttribute"));
|
|
23736
|
+
} while (this.eat(tt.comma));
|
|
23737
|
+
|
|
23738
|
+
return attrs;
|
|
23739
|
+
}
|
|
23740
|
+
|
|
23741
|
+
};
|
|
23742
|
+
}
|
|
23743
|
+
|
|
23263
23744
|
const defaultOnWarn = warning => console.warn(warning.message || warning);
|
|
23264
23745
|
function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
|
|
23265
23746
|
const validOptionSet = new Set(validOptions);
|
|
@@ -23322,7 +23803,7 @@ const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (v
|
|
|
23322
23803
|
return objectifyOption(value);
|
|
23323
23804
|
};
|
|
23324
23805
|
const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
23325
|
-
const presetName = value
|
|
23806
|
+
const presetName = value?.preset;
|
|
23326
23807
|
if (presetName) {
|
|
23327
23808
|
const preset = presets[presetName];
|
|
23328
23809
|
if (preset) {
|
|
@@ -23337,11 +23818,10 @@ const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
|
23337
23818
|
const getHashFromObjectOption = (optionName) => optionName.split('.').join('').toLowerCase();
|
|
23338
23819
|
|
|
23339
23820
|
function normalizeInputOptions(config) {
|
|
23340
|
-
var _a, _b, _c, _d;
|
|
23341
23821
|
// These are options that may trigger special warnings or behaviour later
|
|
23342
23822
|
// if the user did not select an explicit value
|
|
23343
23823
|
const unsetOptions = new Set();
|
|
23344
|
-
const context =
|
|
23824
|
+
const context = config.context ?? 'undefined';
|
|
23345
23825
|
const onwarn = getOnwarn(config);
|
|
23346
23826
|
const strictDeprecations = config.strictDeprecations || false;
|
|
23347
23827
|
const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
|
|
@@ -23350,11 +23830,11 @@ function normalizeInputOptions(config) {
|
|
|
23350
23830
|
acornInjectPlugins: getAcornInjectPlugins(config),
|
|
23351
23831
|
cache: getCache(config),
|
|
23352
23832
|
context,
|
|
23353
|
-
experimentalCacheExpiry:
|
|
23833
|
+
experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
|
|
23354
23834
|
external: getIdMatcher(config.external),
|
|
23355
23835
|
inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
|
|
23356
23836
|
input: getInput(config),
|
|
23357
|
-
makeAbsoluteExternalsRelative:
|
|
23837
|
+
makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
|
|
23358
23838
|
manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
|
|
23359
23839
|
maxParallelFileOps,
|
|
23360
23840
|
maxParallelFileReads: maxParallelFileOps,
|
|
@@ -23362,7 +23842,7 @@ function normalizeInputOptions(config) {
|
|
|
23362
23842
|
onwarn,
|
|
23363
23843
|
perf: config.perf || false,
|
|
23364
23844
|
plugins: ensureArray(config.plugins),
|
|
23365
|
-
preserveEntrySignatures:
|
|
23845
|
+
preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
|
|
23366
23846
|
preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
|
|
23367
23847
|
preserveSymlinks: config.preserveSymlinks || false,
|
|
23368
23848
|
shimMissingExports: config.shimMissingExports || false,
|
|
@@ -23396,8 +23876,11 @@ const getAcorn = (config) => ({
|
|
|
23396
23876
|
sourceType: 'module',
|
|
23397
23877
|
...config.acorn
|
|
23398
23878
|
});
|
|
23399
|
-
const getAcornInjectPlugins = (config) =>
|
|
23400
|
-
|
|
23879
|
+
const getAcornInjectPlugins = (config) => [
|
|
23880
|
+
importAssertions_1,
|
|
23881
|
+
...ensureArray(config.acornInjectPlugins)
|
|
23882
|
+
];
|
|
23883
|
+
const getCache = (config) => config.cache?.cache || config.cache;
|
|
23401
23884
|
const getIdMatcher = (option) => {
|
|
23402
23885
|
if (option === true) {
|
|
23403
23886
|
return () => true;
|
|
@@ -23439,12 +23922,11 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
|
|
|
23439
23922
|
return configManualChunks;
|
|
23440
23923
|
};
|
|
23441
23924
|
const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
23442
|
-
var _a;
|
|
23443
23925
|
const maxParallelFileReads = config.maxParallelFileReads;
|
|
23444
23926
|
if (typeof maxParallelFileReads === 'number') {
|
|
23445
23927
|
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
|
|
23446
23928
|
}
|
|
23447
|
-
const maxParallelFileOps =
|
|
23929
|
+
const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
|
|
23448
23930
|
if (typeof maxParallelFileOps === 'number') {
|
|
23449
23931
|
if (maxParallelFileOps <= 0)
|
|
23450
23932
|
return Infinity;
|
|
@@ -23455,7 +23937,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
|
23455
23937
|
const getModuleContext = (config, context) => {
|
|
23456
23938
|
const configModuleContext = config.moduleContext;
|
|
23457
23939
|
if (typeof configModuleContext === 'function') {
|
|
23458
|
-
return id =>
|
|
23940
|
+
return id => configModuleContext(id) ?? context;
|
|
23459
23941
|
}
|
|
23460
23942
|
if (configModuleContext) {
|
|
23461
23943
|
const contextByModuleId = Object.create(null);
|
|
@@ -23533,7 +24015,6 @@ function isValidUrl(url) {
|
|
|
23533
24015
|
}
|
|
23534
24016
|
|
|
23535
24017
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
23536
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
23537
24018
|
// These are options that may trigger special warnings or behaviour later
|
|
23538
24019
|
// if the user did not select an explicit value
|
|
23539
24020
|
const unsetOptions = new Set(unsetInputOptions);
|
|
@@ -23546,24 +24027,26 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23546
24027
|
const generatedCode = getGeneratedCode(config, preferConst);
|
|
23547
24028
|
const outputOptions = {
|
|
23548
24029
|
amd: getAmd(config),
|
|
23549
|
-
assetFileNames:
|
|
24030
|
+
assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
|
|
23550
24031
|
banner: getAddon(config, 'banner'),
|
|
23551
|
-
chunkFileNames:
|
|
24032
|
+
chunkFileNames: config.chunkFileNames ?? '[name]-[hash].js',
|
|
23552
24033
|
compact,
|
|
23553
24034
|
dir: getDir(config, file),
|
|
23554
24035
|
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
24036
|
+
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
23555
24037
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23556
|
-
esModule:
|
|
24038
|
+
esModule: config.esModule ?? 'if-default-prop',
|
|
23557
24039
|
exports: getExports(config, unsetOptions),
|
|
23558
24040
|
extend: config.extend || false,
|
|
23559
|
-
|
|
24041
|
+
externalImportAssertions: config.externalImportAssertions ?? true,
|
|
24042
|
+
externalLiveBindings: config.externalLiveBindings ?? true,
|
|
23560
24043
|
file,
|
|
23561
24044
|
footer: getAddon(config, 'footer'),
|
|
23562
24045
|
format,
|
|
23563
|
-
freeze:
|
|
24046
|
+
freeze: config.freeze ?? true,
|
|
23564
24047
|
generatedCode,
|
|
23565
24048
|
globals: config.globals || {},
|
|
23566
|
-
hoistTransitiveImports:
|
|
24049
|
+
hoistTransitiveImports: config.hoistTransitiveImports ?? true,
|
|
23567
24050
|
indent: getIndent(config, compact),
|
|
23568
24051
|
inlineDynamicImports,
|
|
23569
24052
|
interop: getInterop(config),
|
|
@@ -23589,8 +24072,8 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23589
24072
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
23590
24073
|
sourcemapFile: config.sourcemapFile,
|
|
23591
24074
|
sourcemapPathTransform: config.sourcemapPathTransform,
|
|
23592
|
-
strict:
|
|
23593
|
-
systemNullSetters: config.systemNullSetters
|
|
24075
|
+
strict: config.strict ?? true,
|
|
24076
|
+
systemNullSetters: config.systemNullSetters ?? true,
|
|
23594
24077
|
validate: config.validate || false
|
|
23595
24078
|
};
|
|
23596
24079
|
warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
|
|
@@ -23633,8 +24116,7 @@ const getFormat = (config) => {
|
|
|
23633
24116
|
}
|
|
23634
24117
|
};
|
|
23635
24118
|
const getInlineDynamicImports = (config, inputOptions) => {
|
|
23636
|
-
|
|
23637
|
-
const inlineDynamicImports = ((_a = config.inlineDynamicImports) !== null && _a !== void 0 ? _a : inputOptions.inlineDynamicImports) || false;
|
|
24119
|
+
const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
|
|
23638
24120
|
const { input } = inputOptions;
|
|
23639
24121
|
if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
|
|
23640
24122
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
|
|
@@ -23642,8 +24124,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
|
|
|
23642
24124
|
return inlineDynamicImports;
|
|
23643
24125
|
};
|
|
23644
24126
|
const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
|
|
23645
|
-
|
|
23646
|
-
const preserveModules = ((_a = config.preserveModules) !== null && _a !== void 0 ? _a : inputOptions.preserveModules) || false;
|
|
24127
|
+
const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
|
|
23647
24128
|
if (preserveModules) {
|
|
23648
24129
|
if (inlineDynamicImports) {
|
|
23649
24130
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', `this option is not supported for "output.preserveModules"`));
|
|
@@ -23730,7 +24211,7 @@ const getEntryFileNames = (config, unsetOptions) => {
|
|
|
23730
24211
|
if (configEntryFileNames == null) {
|
|
23731
24212
|
unsetOptions.add('entryFileNames');
|
|
23732
24213
|
}
|
|
23733
|
-
return configEntryFileNames
|
|
24214
|
+
return configEntryFileNames ?? '[name].js';
|
|
23734
24215
|
};
|
|
23735
24216
|
function getExports(config, unsetOptions) {
|
|
23736
24217
|
const configExports = config.exports;
|
|
@@ -23757,7 +24238,7 @@ const getIndent = (config, compact) => {
|
|
|
23757
24238
|
return '';
|
|
23758
24239
|
}
|
|
23759
24240
|
const configIndent = config.indent;
|
|
23760
|
-
return configIndent === false ? '' : configIndent
|
|
24241
|
+
return configIndent === false ? '' : configIndent ?? true;
|
|
23761
24242
|
};
|
|
23762
24243
|
const ALLOWED_INTEROP_TYPES = new Set([
|
|
23763
24244
|
'compat',
|
|
@@ -23797,7 +24278,7 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
|
|
|
23797
24278
|
}
|
|
23798
24279
|
return configManualChunks || {};
|
|
23799
24280
|
};
|
|
23800
|
-
const getMinifyInternalExports = (config, format, compact) =>
|
|
24281
|
+
const getMinifyInternalExports = (config, format, compact) => config.minifyInternalExports ?? (compact || format === 'es' || format === 'system');
|
|
23801
24282
|
const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
23802
24283
|
const configNamespaceToStringTag = config.namespaceToStringTag;
|
|
23803
24284
|
if (configNamespaceToStringTag != null) {
|
|
@@ -23935,13 +24416,7 @@ function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, out
|
|
|
23935
24416
|
}
|
|
23936
24417
|
function createOutput(outputBundle) {
|
|
23937
24418
|
return {
|
|
23938
|
-
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) =>
|
|
23939
|
-
const fileTypeA = getSortingFileType(outputFileA);
|
|
23940
|
-
const fileTypeB = getSortingFileType(outputFileB);
|
|
23941
|
-
if (fileTypeA === fileTypeB)
|
|
23942
|
-
return 0;
|
|
23943
|
-
return fileTypeA < fileTypeB ? -1 : 1;
|
|
23944
|
-
})
|
|
24419
|
+
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => getSortingFileType(outputFileA) - getSortingFileType(outputFileB))
|
|
23945
24420
|
};
|
|
23946
24421
|
}
|
|
23947
24422
|
var SortingFileType;
|