rollup 3.0.0-7 → 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 +740 -267
- package/dist/es/shared/watch.js +7 -6
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +14 -3
- 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 +745 -283
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +3 -4
- package/package.json +22 -21
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.0.0-
|
|
4
|
-
|
|
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
|
}
|
|
@@ -14570,7 +14691,6 @@ class Chunk {
|
|
|
14570
14691
|
this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
|
|
14571
14692
|
}
|
|
14572
14693
|
generateFacades() {
|
|
14573
|
-
var _a;
|
|
14574
14694
|
const facades = [];
|
|
14575
14695
|
const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
|
|
14576
14696
|
const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
|
|
@@ -14627,7 +14747,7 @@ class Chunk {
|
|
|
14627
14747
|
this.canModuleBeFacade(module, exposedVariables)) {
|
|
14628
14748
|
this.strictFacade = true;
|
|
14629
14749
|
}
|
|
14630
|
-
else if (!
|
|
14750
|
+
else if (!this.facadeChunkByModule.get(module)?.strictFacade) {
|
|
14631
14751
|
this.includedNamespaces.add(module);
|
|
14632
14752
|
this.exports.add(module.namespace);
|
|
14633
14753
|
}
|
|
@@ -14656,22 +14776,18 @@ class Chunk {
|
|
|
14656
14776
|
};
|
|
14657
14777
|
}
|
|
14658
14778
|
getChunkName() {
|
|
14659
|
-
|
|
14660
|
-
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())));
|
|
14661
14780
|
}
|
|
14662
14781
|
getExportNames() {
|
|
14663
|
-
|
|
14664
|
-
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()));
|
|
14665
14783
|
}
|
|
14666
14784
|
getFileName() {
|
|
14667
|
-
|
|
14668
|
-
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14785
|
+
return this.preliminaryFileName?.fileName || this.getPreliminaryFileName().fileName;
|
|
14669
14786
|
}
|
|
14670
14787
|
getImportPath(importer) {
|
|
14671
14788
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
14672
14789
|
}
|
|
14673
14790
|
getPreliminaryFileName() {
|
|
14674
|
-
var _a;
|
|
14675
14791
|
if (this.preliminaryFileName) {
|
|
14676
14792
|
return this.preliminaryFileName;
|
|
14677
14793
|
}
|
|
@@ -14685,7 +14801,7 @@ class Chunk {
|
|
|
14685
14801
|
fileName = this.fileName;
|
|
14686
14802
|
}
|
|
14687
14803
|
else {
|
|
14688
|
-
const [pattern, patternName] = preserveModules ||
|
|
14804
|
+
const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
|
|
14689
14805
|
? [entryFileNames, 'output.entryFileNames']
|
|
14690
14806
|
: [chunkFileNames, 'output.chunkFileNames'];
|
|
14691
14807
|
fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
@@ -14750,7 +14866,7 @@ class Chunk {
|
|
|
14750
14866
|
let hasExports = renderedExports.length !== 0;
|
|
14751
14867
|
let hasDefaultExport = false;
|
|
14752
14868
|
for (const { reexports } of renderedDependencies) {
|
|
14753
|
-
if (reexports
|
|
14869
|
+
if (reexports?.length) {
|
|
14754
14870
|
hasExports = true;
|
|
14755
14871
|
if (reexports.some(reexport => reexport.reexported === 'default')) {
|
|
14756
14872
|
hasDefaultExport = true;
|
|
@@ -14972,6 +15088,16 @@ class Chunk {
|
|
|
14972
15088
|
.filter((resolution) => resolution !== this &&
|
|
14973
15089
|
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
14974
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
|
+
}
|
|
14975
15101
|
getFallbackChunkName() {
|
|
14976
15102
|
if (this.manualChunkAlias) {
|
|
14977
15103
|
return this.manualChunkAlias;
|
|
@@ -15049,7 +15175,7 @@ class Chunk {
|
|
|
15049
15175
|
exports: this.getExportNames(),
|
|
15050
15176
|
facadeModuleId: facadeModule && facadeModule.id,
|
|
15051
15177
|
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
15052
|
-
isEntry: !!
|
|
15178
|
+
isEntry: !!facadeModule?.info.isEntry,
|
|
15053
15179
|
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
15054
15180
|
moduleIds: this.orderedModules.map(({ id }) => id),
|
|
15055
15181
|
name: this.getChunkName(),
|
|
@@ -15148,6 +15274,7 @@ class Chunk {
|
|
|
15148
15274
|
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
15149
15275
|
const importPath = dep.getImportPath(fileName);
|
|
15150
15276
|
renderedDependencies.set(dep, {
|
|
15277
|
+
assertions: dep instanceof ExternalChunk ? dep.getImportAssertions(this.snippets) : null,
|
|
15151
15278
|
defaultVariableName: dep.defaultVariableName,
|
|
15152
15279
|
globalName: dep instanceof ExternalChunk &&
|
|
15153
15280
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
@@ -15231,8 +15358,7 @@ class Chunk {
|
|
|
15231
15358
|
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
15232
15359
|
renderedModules[module.id] = {
|
|
15233
15360
|
get code() {
|
|
15234
|
-
|
|
15235
|
-
return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
|
|
15361
|
+
return source?.toString() ?? null;
|
|
15236
15362
|
},
|
|
15237
15363
|
originalLength: module.originalCode.length,
|
|
15238
15364
|
removedExports,
|
|
@@ -15260,14 +15386,13 @@ class Chunk {
|
|
|
15260
15386
|
node.setInternalResolution(resolution.namespace);
|
|
15261
15387
|
}
|
|
15262
15388
|
else {
|
|
15263
|
-
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);
|
|
15264
15390
|
}
|
|
15265
15391
|
}
|
|
15266
15392
|
else {
|
|
15267
15393
|
const { resolution } = resolvedDynamicImport;
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
: resolution || '', false);
|
|
15394
|
+
const [resolutionString, assertions] = this.getDynamicImportStringAndAssertions(resolution, fileName);
|
|
15395
|
+
resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, assertions);
|
|
15271
15396
|
}
|
|
15272
15397
|
}
|
|
15273
15398
|
}
|
|
@@ -15376,12 +15501,10 @@ class Chunk {
|
|
|
15376
15501
|
}
|
|
15377
15502
|
}
|
|
15378
15503
|
function getChunkNameFromModule(module) {
|
|
15379
|
-
|
|
15380
|
-
return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
|
|
15504
|
+
return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
|
|
15381
15505
|
}
|
|
15382
15506
|
function getPredefinedChunkNameFromModule(module) {
|
|
15383
|
-
|
|
15384
|
-
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);
|
|
15385
15508
|
}
|
|
15386
15509
|
function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
|
|
15387
15510
|
const importedBindingsPerDependency = {};
|
|
@@ -17267,7 +17390,7 @@ pp$8.parseForStatement = function(node) {
|
|
|
17267
17390
|
|
|
17268
17391
|
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
17269
17392
|
this.next();
|
|
17270
|
-
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)
|
|
17271
17394
|
};
|
|
17272
17395
|
|
|
17273
17396
|
pp$8.parseIfStatement = function(node) {
|
|
@@ -17531,7 +17654,7 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
17531
17654
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
17532
17655
|
};
|
|
17533
17656
|
|
|
17534
|
-
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;
|
|
17535
17658
|
|
|
17536
17659
|
// Parse a function declaration or literal (depending on the
|
|
17537
17660
|
// `statement & FUNC_STATEMENT`).
|
|
@@ -17547,8 +17670,8 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17547
17670
|
if (this.options.ecmaVersion >= 8)
|
|
17548
17671
|
{ node.async = !!isAsync; }
|
|
17549
17672
|
|
|
17550
|
-
if (statement & FUNC_STATEMENT) {
|
|
17551
|
-
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();
|
|
17552
17675
|
if (node.id && !(statement & FUNC_HANGING_STATEMENT))
|
|
17553
17676
|
// If it is a regular function declaration in sloppy mode, then it is
|
|
17554
17677
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
|
@@ -17563,7 +17686,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17563
17686
|
this.awaitIdentPos = 0;
|
|
17564
17687
|
this.enterScope(functionFlags(node.async, node.generator));
|
|
17565
17688
|
|
|
17566
|
-
if (!(statement & FUNC_STATEMENT))
|
|
17689
|
+
if (!(statement & FUNC_STATEMENT$1))
|
|
17567
17690
|
{ node.id = this.type === types$1.name ? this.parseIdent() : null; }
|
|
17568
17691
|
|
|
17569
17692
|
this.parseFunctionParams(node);
|
|
@@ -17572,7 +17695,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17572
17695
|
this.yieldPos = oldYieldPos;
|
|
17573
17696
|
this.awaitPos = oldAwaitPos;
|
|
17574
17697
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
17575
|
-
return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17698
|
+
return this.finishNode(node, (statement & FUNC_STATEMENT$1) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17576
17699
|
};
|
|
17577
17700
|
|
|
17578
17701
|
pp$8.parseFunctionParams = function(node) {
|
|
@@ -17878,7 +18001,7 @@ pp$8.parseExport = function(node, exports) {
|
|
|
17878
18001
|
var fNode = this.startNode();
|
|
17879
18002
|
this.next();
|
|
17880
18003
|
if (isAsync) { this.next(); }
|
|
17881
|
-
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);
|
|
17882
18005
|
} else if (this.type === types$1._class) {
|
|
17883
18006
|
var cNode = this.startNode();
|
|
17884
18007
|
node.declaration = this.parseClass(cNode, "nullableID");
|
|
@@ -21763,7 +21886,59 @@ Parser.acorn = {
|
|
|
21763
21886
|
nonASCIIwhitespace: nonASCIIwhitespace
|
|
21764
21887
|
};
|
|
21765
21888
|
|
|
21766
|
-
|
|
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) {
|
|
21767
21942
|
let skipped = null;
|
|
21768
21943
|
let replaceContext = null;
|
|
21769
21944
|
if (skip) {
|
|
@@ -21775,16 +21950,16 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
21775
21950
|
}
|
|
21776
21951
|
replaceContext = (pluginContext, plugin) => ({
|
|
21777
21952
|
...pluginContext,
|
|
21778
|
-
resolve: (source, importer, { custom, isEntry, skipSelf } = BLANK) => {
|
|
21779
|
-
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);
|
|
21780
21955
|
}
|
|
21781
21956
|
});
|
|
21782
21957
|
}
|
|
21783
|
-
return pluginDriver.hookFirst('resolveId', [source, importer, { custom: customOptions, isEntry }], replaceContext, skipped);
|
|
21958
|
+
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
21784
21959
|
}
|
|
21785
21960
|
|
|
21786
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
|
|
21787
|
-
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);
|
|
21788
21963
|
if (pluginResult != null)
|
|
21789
21964
|
return pluginResult;
|
|
21790
21965
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
@@ -21798,8 +21973,9 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
21798
21973
|
return addJsExtensionIfNecessary(importer ? resolve(dirname(importer), source) : resolve(source), preserveSymlinks);
|
|
21799
21974
|
}
|
|
21800
21975
|
async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
21801
|
-
|
|
21802
|
-
|
|
21976
|
+
return ((await findFile(file, preserveSymlinks)) ??
|
|
21977
|
+
(await findFile(file + '.mjs', preserveSymlinks)) ??
|
|
21978
|
+
(await findFile(file + '.js', preserveSymlinks)));
|
|
21803
21979
|
}
|
|
21804
21980
|
async function findFile(file, preserveSymlinks) {
|
|
21805
21981
|
try {
|
|
@@ -22033,11 +22209,9 @@ class ModuleLoader {
|
|
|
22033
22209
|
this.modulesWithLoadedDependencies = new Set();
|
|
22034
22210
|
this.nextChunkNamePriority = 0;
|
|
22035
22211
|
this.nextEntryModuleIndex = 0;
|
|
22036
|
-
this.resolveId = async (source, importer, customOptions, isEntry, skip = null) =>
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer), importer, source));
|
|
22040
|
-
};
|
|
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);
|
|
22041
22215
|
this.hasModuleSideEffects = options.treeshake
|
|
22042
22216
|
? options.treeshake.moduleSideEffects
|
|
22043
22217
|
: () => true;
|
|
@@ -22095,7 +22269,7 @@ class ModuleLoader {
|
|
|
22095
22269
|
return module;
|
|
22096
22270
|
}
|
|
22097
22271
|
async preloadModule(resolvedId) {
|
|
22098
|
-
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);
|
|
22099
22273
|
return module.info;
|
|
22100
22274
|
}
|
|
22101
22275
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
@@ -22118,7 +22292,7 @@ class ModuleLoader {
|
|
|
22118
22292
|
async addModuleSource(id, importer, module) {
|
|
22119
22293
|
let source;
|
|
22120
22294
|
try {
|
|
22121
|
-
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')));
|
|
22122
22296
|
}
|
|
22123
22297
|
catch (err) {
|
|
22124
22298
|
let msg = `Could not load ${id}`;
|
|
@@ -22193,16 +22367,21 @@ class ModuleLoader {
|
|
|
22193
22367
|
}
|
|
22194
22368
|
}
|
|
22195
22369
|
}
|
|
22196
|
-
// If this is a preload, then this method always waits for the dependencies of
|
|
22197
|
-
//
|
|
22198
|
-
// Otherwise it
|
|
22199
|
-
|
|
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) {
|
|
22200
22376
|
const existingModule = this.modulesById.get(id);
|
|
22201
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
|
+
}
|
|
22202
22381
|
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
22203
22382
|
return existingModule;
|
|
22204
22383
|
}
|
|
22205
|
-
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);
|
|
22206
22385
|
this.modulesById.set(id, module);
|
|
22207
22386
|
this.graph.watchFiles[id] = true;
|
|
22208
22387
|
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
@@ -22239,14 +22418,18 @@ class ModuleLoader {
|
|
|
22239
22418
|
}
|
|
22240
22419
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
22241
22420
|
if (resolvedId.external) {
|
|
22242
|
-
const { external, id, moduleSideEffects, meta } = resolvedId;
|
|
22243
|
-
|
|
22244
|
-
|
|
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);
|
|
22245
22426
|
}
|
|
22246
|
-
|
|
22247
|
-
if (!(externalModule instanceof ExternalModule)) {
|
|
22427
|
+
else if (!(externalModule instanceof ExternalModule)) {
|
|
22248
22428
|
return error(errInternalIdCannotBeExternal(source, importer));
|
|
22249
22429
|
}
|
|
22430
|
+
else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
|
|
22431
|
+
this.options.onwarn(errInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
|
|
22432
|
+
}
|
|
22250
22433
|
return Promise.resolve(externalModule);
|
|
22251
22434
|
}
|
|
22252
22435
|
return this.fetchModule(resolvedId, importer, false, false);
|
|
@@ -22304,7 +22487,7 @@ class ModuleLoader {
|
|
|
22304
22487
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
22305
22488
|
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
22306
22489
|
? dynamicImport.argument
|
|
22307
|
-
: dynamicImport.argument.esTreeNode, module.id);
|
|
22490
|
+
: dynamicImport.argument.esTreeNode, module.id, getAssertionsFromImportExpression(dynamicImport.node));
|
|
22308
22491
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
22309
22492
|
dynamicImport.id = resolvedId.id;
|
|
22310
22493
|
}
|
|
@@ -22312,25 +22495,25 @@ class ModuleLoader {
|
|
|
22312
22495
|
});
|
|
22313
22496
|
}
|
|
22314
22497
|
getResolveStaticDependencyPromises(module) {
|
|
22315
|
-
return Array.from(module.
|
|
22498
|
+
return Array.from(module.sourcesWithAssertions, async ([source, assertions]) => [
|
|
22316
22499
|
source,
|
|
22317
22500
|
(module.resolvedIds[source] =
|
|
22318
22501
|
module.resolvedIds[source] ||
|
|
22319
|
-
this.
|
|
22502
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, assertions), source, module.id, assertions))
|
|
22320
22503
|
]);
|
|
22321
22504
|
}
|
|
22322
|
-
getResolvedIdWithDefaults(resolvedId) {
|
|
22323
|
-
var _a, _b;
|
|
22505
|
+
getResolvedIdWithDefaults(resolvedId, assertions) {
|
|
22324
22506
|
if (!resolvedId) {
|
|
22325
22507
|
return null;
|
|
22326
22508
|
}
|
|
22327
22509
|
const external = resolvedId.external || false;
|
|
22328
22510
|
return {
|
|
22511
|
+
assertions: resolvedId.assertions || assertions,
|
|
22329
22512
|
external,
|
|
22330
22513
|
id: resolvedId.id,
|
|
22331
22514
|
meta: resolvedId.meta || {},
|
|
22332
|
-
moduleSideEffects:
|
|
22333
|
-
syntheticNamedExports:
|
|
22515
|
+
moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
|
|
22516
|
+
syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
|
|
22334
22517
|
};
|
|
22335
22518
|
}
|
|
22336
22519
|
async handleExistingModule(module, isEntry, isPreload) {
|
|
@@ -22350,13 +22533,14 @@ class ModuleLoader {
|
|
|
22350
22533
|
}
|
|
22351
22534
|
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22352
22535
|
}
|
|
22353
|
-
|
|
22536
|
+
handleInvalidResolvedId(resolvedId, source, importer, assertions) {
|
|
22354
22537
|
if (resolvedId === null) {
|
|
22355
22538
|
if (isRelative(source)) {
|
|
22356
22539
|
return error(errUnresolvedImport(source, importer));
|
|
22357
22540
|
}
|
|
22358
22541
|
this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
22359
22542
|
return {
|
|
22543
|
+
assertions,
|
|
22360
22544
|
external: true,
|
|
22361
22545
|
id: source,
|
|
22362
22546
|
meta: {},
|
|
@@ -22370,7 +22554,7 @@ class ModuleLoader {
|
|
|
22370
22554
|
return resolvedId;
|
|
22371
22555
|
}
|
|
22372
22556
|
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
|
|
22373
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true);
|
|
22557
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
|
|
22374
22558
|
if (resolveIdResult == null) {
|
|
22375
22559
|
return error(implicitlyLoadedBefore === null
|
|
22376
22560
|
? errUnresolvedEntry(unresolvedId)
|
|
@@ -22384,14 +22568,13 @@ class ModuleLoader {
|
|
|
22384
22568
|
}
|
|
22385
22569
|
return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
|
|
22386
22570
|
? resolveIdResult
|
|
22387
|
-
: { id: resolveIdResult }), undefined, isEntry, false);
|
|
22571
|
+
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
22388
22572
|
}
|
|
22389
|
-
async resolveDynamicImport(module, specifier, importer) {
|
|
22390
|
-
var _a;
|
|
22391
|
-
var _b;
|
|
22573
|
+
async resolveDynamicImport(module, specifier, importer, assertions) {
|
|
22392
22574
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
22393
22575
|
specifier,
|
|
22394
|
-
importer
|
|
22576
|
+
importer,
|
|
22577
|
+
{ assertions }
|
|
22395
22578
|
]);
|
|
22396
22579
|
if (typeof specifier !== 'string') {
|
|
22397
22580
|
if (typeof resolution === 'string') {
|
|
@@ -22400,16 +22583,19 @@ class ModuleLoader {
|
|
|
22400
22583
|
if (!resolution) {
|
|
22401
22584
|
return null;
|
|
22402
22585
|
}
|
|
22403
|
-
return
|
|
22404
|
-
external: false,
|
|
22405
|
-
moduleSideEffects: true,
|
|
22406
|
-
...resolution
|
|
22407
|
-
};
|
|
22586
|
+
return this.getResolvedIdWithDefaults(resolution, assertions);
|
|
22408
22587
|
}
|
|
22409
22588
|
if (resolution == null) {
|
|
22410
|
-
|
|
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));
|
|
22411
22597
|
}
|
|
22412
|
-
return this.
|
|
22598
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), assertions), specifier, importer, assertions);
|
|
22413
22599
|
}
|
|
22414
22600
|
}
|
|
22415
22601
|
function normalizeRelativeExternalId(source, importer) {
|
|
@@ -22420,14 +22606,13 @@ function normalizeRelativeExternalId(source, importer) {
|
|
|
22420
22606
|
: source;
|
|
22421
22607
|
}
|
|
22422
22608
|
function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
|
|
22423
|
-
var _a;
|
|
22424
22609
|
if (fileName !== null) {
|
|
22425
22610
|
module.chunkFileNames.add(fileName);
|
|
22426
22611
|
}
|
|
22427
22612
|
else if (name !== null) {
|
|
22428
22613
|
// Always keep chunkNames sorted by priority
|
|
22429
22614
|
let namePosition = 0;
|
|
22430
|
-
while (
|
|
22615
|
+
while (module.chunkNames[namePosition]?.priority < priority)
|
|
22431
22616
|
namePosition++;
|
|
22432
22617
|
module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
|
|
22433
22618
|
}
|
|
@@ -22720,8 +22905,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22720
22905
|
return wrappedModuleIds();
|
|
22721
22906
|
},
|
|
22722
22907
|
parse: graph.contextParse.bind(graph),
|
|
22723
|
-
resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
|
|
22724
|
-
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);
|
|
22725
22910
|
},
|
|
22726
22911
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22727
22912
|
warn(warning) {
|
|
@@ -22896,7 +23081,7 @@ class PluginDriver {
|
|
|
22896
23081
|
}
|
|
22897
23082
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22898
23083
|
const hookResult = handler.apply(context, args);
|
|
22899
|
-
if (!
|
|
23084
|
+
if (!hookResult?.then) {
|
|
22900
23085
|
// short circuit for non-thenables and non-Promises
|
|
22901
23086
|
return hookResult;
|
|
22902
23087
|
}
|
|
@@ -23036,7 +23221,6 @@ function normalizeEntryModules(entryModules) {
|
|
|
23036
23221
|
}
|
|
23037
23222
|
class Graph {
|
|
23038
23223
|
constructor(options, watcher) {
|
|
23039
|
-
var _a, _b;
|
|
23040
23224
|
this.options = options;
|
|
23041
23225
|
this.cachedModules = new Map();
|
|
23042
23226
|
this.deoptimizationTracker = new PathTracker();
|
|
@@ -23057,11 +23241,11 @@ class Graph {
|
|
|
23057
23241
|
return foundModule.info;
|
|
23058
23242
|
};
|
|
23059
23243
|
if (options.cache !== false) {
|
|
23060
|
-
if (
|
|
23244
|
+
if (options.cache?.modules) {
|
|
23061
23245
|
for (const module of options.cache.modules)
|
|
23062
23246
|
this.cachedModules.set(module.id, module);
|
|
23063
23247
|
}
|
|
23064
|
-
this.pluginCache =
|
|
23248
|
+
this.pluginCache = options.cache?.plugins || Object.create(null);
|
|
23065
23249
|
// increment access counter
|
|
23066
23250
|
for (const name in this.pluginCache) {
|
|
23067
23251
|
const cache = this.pluginCache[name];
|
|
@@ -23268,6 +23452,295 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
23268
23452
|
return result;
|
|
23269
23453
|
}
|
|
23270
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
|
+
|
|
23271
23744
|
const defaultOnWarn = warning => console.warn(warning.message || warning);
|
|
23272
23745
|
function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
|
|
23273
23746
|
const validOptionSet = new Set(validOptions);
|
|
@@ -23330,7 +23803,7 @@ const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (v
|
|
|
23330
23803
|
return objectifyOption(value);
|
|
23331
23804
|
};
|
|
23332
23805
|
const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
23333
|
-
const presetName = value
|
|
23806
|
+
const presetName = value?.preset;
|
|
23334
23807
|
if (presetName) {
|
|
23335
23808
|
const preset = presets[presetName];
|
|
23336
23809
|
if (preset) {
|
|
@@ -23345,11 +23818,10 @@ const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
|
23345
23818
|
const getHashFromObjectOption = (optionName) => optionName.split('.').join('').toLowerCase();
|
|
23346
23819
|
|
|
23347
23820
|
function normalizeInputOptions(config) {
|
|
23348
|
-
var _a, _b, _c, _d;
|
|
23349
23821
|
// These are options that may trigger special warnings or behaviour later
|
|
23350
23822
|
// if the user did not select an explicit value
|
|
23351
23823
|
const unsetOptions = new Set();
|
|
23352
|
-
const context =
|
|
23824
|
+
const context = config.context ?? 'undefined';
|
|
23353
23825
|
const onwarn = getOnwarn(config);
|
|
23354
23826
|
const strictDeprecations = config.strictDeprecations || false;
|
|
23355
23827
|
const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
|
|
@@ -23358,11 +23830,11 @@ function normalizeInputOptions(config) {
|
|
|
23358
23830
|
acornInjectPlugins: getAcornInjectPlugins(config),
|
|
23359
23831
|
cache: getCache(config),
|
|
23360
23832
|
context,
|
|
23361
|
-
experimentalCacheExpiry:
|
|
23833
|
+
experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
|
|
23362
23834
|
external: getIdMatcher(config.external),
|
|
23363
23835
|
inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
|
|
23364
23836
|
input: getInput(config),
|
|
23365
|
-
makeAbsoluteExternalsRelative:
|
|
23837
|
+
makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
|
|
23366
23838
|
manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
|
|
23367
23839
|
maxParallelFileOps,
|
|
23368
23840
|
maxParallelFileReads: maxParallelFileOps,
|
|
@@ -23370,7 +23842,7 @@ function normalizeInputOptions(config) {
|
|
|
23370
23842
|
onwarn,
|
|
23371
23843
|
perf: config.perf || false,
|
|
23372
23844
|
plugins: ensureArray(config.plugins),
|
|
23373
|
-
preserveEntrySignatures:
|
|
23845
|
+
preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
|
|
23374
23846
|
preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
|
|
23375
23847
|
preserveSymlinks: config.preserveSymlinks || false,
|
|
23376
23848
|
shimMissingExports: config.shimMissingExports || false,
|
|
@@ -23404,8 +23876,11 @@ const getAcorn = (config) => ({
|
|
|
23404
23876
|
sourceType: 'module',
|
|
23405
23877
|
...config.acorn
|
|
23406
23878
|
});
|
|
23407
|
-
const getAcornInjectPlugins = (config) =>
|
|
23408
|
-
|
|
23879
|
+
const getAcornInjectPlugins = (config) => [
|
|
23880
|
+
importAssertions_1,
|
|
23881
|
+
...ensureArray(config.acornInjectPlugins)
|
|
23882
|
+
];
|
|
23883
|
+
const getCache = (config) => config.cache?.cache || config.cache;
|
|
23409
23884
|
const getIdMatcher = (option) => {
|
|
23410
23885
|
if (option === true) {
|
|
23411
23886
|
return () => true;
|
|
@@ -23447,12 +23922,11 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
|
|
|
23447
23922
|
return configManualChunks;
|
|
23448
23923
|
};
|
|
23449
23924
|
const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
23450
|
-
var _a;
|
|
23451
23925
|
const maxParallelFileReads = config.maxParallelFileReads;
|
|
23452
23926
|
if (typeof maxParallelFileReads === 'number') {
|
|
23453
23927
|
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
|
|
23454
23928
|
}
|
|
23455
|
-
const maxParallelFileOps =
|
|
23929
|
+
const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
|
|
23456
23930
|
if (typeof maxParallelFileOps === 'number') {
|
|
23457
23931
|
if (maxParallelFileOps <= 0)
|
|
23458
23932
|
return Infinity;
|
|
@@ -23463,7 +23937,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
|
23463
23937
|
const getModuleContext = (config, context) => {
|
|
23464
23938
|
const configModuleContext = config.moduleContext;
|
|
23465
23939
|
if (typeof configModuleContext === 'function') {
|
|
23466
|
-
return id =>
|
|
23940
|
+
return id => configModuleContext(id) ?? context;
|
|
23467
23941
|
}
|
|
23468
23942
|
if (configModuleContext) {
|
|
23469
23943
|
const contextByModuleId = Object.create(null);
|
|
@@ -23541,7 +24015,6 @@ function isValidUrl(url) {
|
|
|
23541
24015
|
}
|
|
23542
24016
|
|
|
23543
24017
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
23544
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
23545
24018
|
// These are options that may trigger special warnings or behaviour later
|
|
23546
24019
|
// if the user did not select an explicit value
|
|
23547
24020
|
const unsetOptions = new Set(unsetInputOptions);
|
|
@@ -23554,24 +24027,26 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23554
24027
|
const generatedCode = getGeneratedCode(config, preferConst);
|
|
23555
24028
|
const outputOptions = {
|
|
23556
24029
|
amd: getAmd(config),
|
|
23557
|
-
assetFileNames:
|
|
24030
|
+
assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
|
|
23558
24031
|
banner: getAddon(config, 'banner'),
|
|
23559
|
-
chunkFileNames:
|
|
24032
|
+
chunkFileNames: config.chunkFileNames ?? '[name]-[hash].js',
|
|
23560
24033
|
compact,
|
|
23561
24034
|
dir: getDir(config, file),
|
|
23562
24035
|
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
24036
|
+
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
23563
24037
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23564
|
-
esModule:
|
|
24038
|
+
esModule: config.esModule ?? 'if-default-prop',
|
|
23565
24039
|
exports: getExports(config, unsetOptions),
|
|
23566
24040
|
extend: config.extend || false,
|
|
23567
|
-
|
|
24041
|
+
externalImportAssertions: config.externalImportAssertions ?? true,
|
|
24042
|
+
externalLiveBindings: config.externalLiveBindings ?? true,
|
|
23568
24043
|
file,
|
|
23569
24044
|
footer: getAddon(config, 'footer'),
|
|
23570
24045
|
format,
|
|
23571
|
-
freeze:
|
|
24046
|
+
freeze: config.freeze ?? true,
|
|
23572
24047
|
generatedCode,
|
|
23573
24048
|
globals: config.globals || {},
|
|
23574
|
-
hoistTransitiveImports:
|
|
24049
|
+
hoistTransitiveImports: config.hoistTransitiveImports ?? true,
|
|
23575
24050
|
indent: getIndent(config, compact),
|
|
23576
24051
|
inlineDynamicImports,
|
|
23577
24052
|
interop: getInterop(config),
|
|
@@ -23597,8 +24072,8 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23597
24072
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
23598
24073
|
sourcemapFile: config.sourcemapFile,
|
|
23599
24074
|
sourcemapPathTransform: config.sourcemapPathTransform,
|
|
23600
|
-
strict:
|
|
23601
|
-
systemNullSetters: config.systemNullSetters
|
|
24075
|
+
strict: config.strict ?? true,
|
|
24076
|
+
systemNullSetters: config.systemNullSetters ?? true,
|
|
23602
24077
|
validate: config.validate || false
|
|
23603
24078
|
};
|
|
23604
24079
|
warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
|
|
@@ -23641,8 +24116,7 @@ const getFormat = (config) => {
|
|
|
23641
24116
|
}
|
|
23642
24117
|
};
|
|
23643
24118
|
const getInlineDynamicImports = (config, inputOptions) => {
|
|
23644
|
-
|
|
23645
|
-
const inlineDynamicImports = ((_a = config.inlineDynamicImports) !== null && _a !== void 0 ? _a : inputOptions.inlineDynamicImports) || false;
|
|
24119
|
+
const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
|
|
23646
24120
|
const { input } = inputOptions;
|
|
23647
24121
|
if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
|
|
23648
24122
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
|
|
@@ -23650,8 +24124,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
|
|
|
23650
24124
|
return inlineDynamicImports;
|
|
23651
24125
|
};
|
|
23652
24126
|
const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
|
|
23653
|
-
|
|
23654
|
-
const preserveModules = ((_a = config.preserveModules) !== null && _a !== void 0 ? _a : inputOptions.preserveModules) || false;
|
|
24127
|
+
const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
|
|
23655
24128
|
if (preserveModules) {
|
|
23656
24129
|
if (inlineDynamicImports) {
|
|
23657
24130
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', `this option is not supported for "output.preserveModules"`));
|
|
@@ -23738,7 +24211,7 @@ const getEntryFileNames = (config, unsetOptions) => {
|
|
|
23738
24211
|
if (configEntryFileNames == null) {
|
|
23739
24212
|
unsetOptions.add('entryFileNames');
|
|
23740
24213
|
}
|
|
23741
|
-
return configEntryFileNames
|
|
24214
|
+
return configEntryFileNames ?? '[name].js';
|
|
23742
24215
|
};
|
|
23743
24216
|
function getExports(config, unsetOptions) {
|
|
23744
24217
|
const configExports = config.exports;
|
|
@@ -23765,7 +24238,7 @@ const getIndent = (config, compact) => {
|
|
|
23765
24238
|
return '';
|
|
23766
24239
|
}
|
|
23767
24240
|
const configIndent = config.indent;
|
|
23768
|
-
return configIndent === false ? '' : configIndent
|
|
24241
|
+
return configIndent === false ? '' : configIndent ?? true;
|
|
23769
24242
|
};
|
|
23770
24243
|
const ALLOWED_INTEROP_TYPES = new Set([
|
|
23771
24244
|
'compat',
|
|
@@ -23805,7 +24278,7 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
|
|
|
23805
24278
|
}
|
|
23806
24279
|
return configManualChunks || {};
|
|
23807
24280
|
};
|
|
23808
|
-
const getMinifyInternalExports = (config, format, compact) =>
|
|
24281
|
+
const getMinifyInternalExports = (config, format, compact) => config.minifyInternalExports ?? (compact || format === 'es' || format === 'system');
|
|
23809
24282
|
const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
23810
24283
|
const configNamespaceToStringTag = config.namespaceToStringTag;
|
|
23811
24284
|
if (configNamespaceToStringTag != null) {
|