rollup 3.0.0-7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.0.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.0.0
|
|
4
|
+
Tue, 11 Oct 2022 13:39:18 GMT - commit 69fef3b3639afc1a0409a4ecf8d41944bef8aa34
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -10,25 +10,14 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
const node_path = require('node:path');
|
|
13
|
-
const require$$0 = require('path');
|
|
13
|
+
const require$$0$1 = require('path');
|
|
14
14
|
const process$1 = require('node:process');
|
|
15
15
|
const node_perf_hooks = require('node:perf_hooks');
|
|
16
16
|
const node_crypto = require('node:crypto');
|
|
17
17
|
const node_fs = require('node:fs');
|
|
18
18
|
const node_events = require('node:events');
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
22
|
-
if (e) {
|
|
23
|
-
for (const k in e) {
|
|
24
|
-
n[k] = e[k];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
n.default = e;
|
|
28
|
-
return n;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var version$1 = "3.0.0-6";
|
|
20
|
+
var version$1 = "3.0.0";
|
|
32
21
|
|
|
33
22
|
function ensureArray$1(items) {
|
|
34
23
|
if (Array.isArray(items)) {
|
|
@@ -218,7 +207,7 @@ function augmentCodeLocation(props, pos, source, id) {
|
|
|
218
207
|
}
|
|
219
208
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
220
209
|
// error code below
|
|
221
|
-
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
210
|
+
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
222
211
|
function errAddonNotGenerated(message, hook, plugin) {
|
|
223
212
|
return {
|
|
224
213
|
code: ADDON_ERROR,
|
|
@@ -397,6 +386,18 @@ function errIllegalImportReassignment(name, importingId) {
|
|
|
397
386
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
398
387
|
};
|
|
399
388
|
}
|
|
389
|
+
function errInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
|
|
390
|
+
return {
|
|
391
|
+
code: INCONSISTENT_IMPORT_ASSERTIONS,
|
|
392
|
+
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAssertions$1(newAssertions)} assertions, but it was already imported elsewhere with ${formatAssertions$1(existingAssertions)} assertions. Please ensure that import assertions for the same module are always consistent.`
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const formatAssertions$1 = (assertions) => {
|
|
396
|
+
const entries = Object.entries(assertions);
|
|
397
|
+
if (entries.length === 0)
|
|
398
|
+
return 'no';
|
|
399
|
+
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
400
|
+
};
|
|
400
401
|
function errInputHookInOutputPlugin(pluginName, hookName) {
|
|
401
402
|
return {
|
|
402
403
|
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
@@ -842,7 +843,7 @@ const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (v
|
|
|
842
843
|
return objectifyOption(value);
|
|
843
844
|
};
|
|
844
845
|
const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
|
|
845
|
-
const presetName = value
|
|
846
|
+
const presetName = value?.preset;
|
|
846
847
|
if (presetName) {
|
|
847
848
|
const preset = presets[presetName];
|
|
848
849
|
if (preset) {
|
|
@@ -860,7 +861,7 @@ let fsEvents;
|
|
|
860
861
|
let fsEventsImportError;
|
|
861
862
|
async function loadFsEvents() {
|
|
862
863
|
try {
|
|
863
|
-
({ default: fsEvents } = await
|
|
864
|
+
({ default: fsEvents } = await import('fsevents'));
|
|
864
865
|
}
|
|
865
866
|
catch (err) {
|
|
866
867
|
fsEventsImportError = err;
|
|
@@ -1028,11 +1029,10 @@ class Chunk$1 {
|
|
|
1028
1029
|
this.storeName = false;
|
|
1029
1030
|
this.edited = false;
|
|
1030
1031
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
});
|
|
1032
|
+
{
|
|
1033
|
+
this.previous = null;
|
|
1034
|
+
this.next = null;
|
|
1035
|
+
}
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
1038
|
appendLeft(content) {
|
|
@@ -1675,6 +1675,11 @@ class MagicString {
|
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
1677
|
overwrite(start, end, content, options) {
|
|
1678
|
+
options = options || {};
|
|
1679
|
+
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
update(start, end, content, options) {
|
|
1678
1683
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
1679
1684
|
|
|
1680
1685
|
while (start < 0) start += this.original.length;
|
|
@@ -1700,7 +1705,7 @@ class MagicString {
|
|
|
1700
1705
|
options = { storeName: true };
|
|
1701
1706
|
}
|
|
1702
1707
|
const storeName = options !== undefined ? options.storeName : false;
|
|
1703
|
-
const
|
|
1708
|
+
const overwrite = options !== undefined ? options.overwrite : false;
|
|
1704
1709
|
|
|
1705
1710
|
if (storeName) {
|
|
1706
1711
|
const original = this.original.slice(start, end);
|
|
@@ -1724,7 +1729,7 @@ class MagicString {
|
|
|
1724
1729
|
chunk.edit('', false);
|
|
1725
1730
|
}
|
|
1726
1731
|
|
|
1727
|
-
first.edit(content, storeName,
|
|
1732
|
+
first.edit(content, storeName, !overwrite);
|
|
1728
1733
|
} else {
|
|
1729
1734
|
// must be inserting at the end
|
|
1730
1735
|
const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
|
|
@@ -2043,7 +2048,7 @@ class MagicString {
|
|
|
2043
2048
|
return this.original !== this.toString();
|
|
2044
2049
|
}
|
|
2045
2050
|
|
|
2046
|
-
|
|
2051
|
+
_replaceRegexp(searchValue, replacement) {
|
|
2047
2052
|
function getReplacement(match, str) {
|
|
2048
2053
|
if (typeof replacement === 'string') {
|
|
2049
2054
|
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
@@ -2066,7 +2071,7 @@ class MagicString {
|
|
|
2066
2071
|
}
|
|
2067
2072
|
return matches;
|
|
2068
2073
|
}
|
|
2069
|
-
if (
|
|
2074
|
+
if (searchValue.global) {
|
|
2070
2075
|
const matches = matchAll(searchValue, this.original);
|
|
2071
2076
|
matches.forEach((match) => {
|
|
2072
2077
|
if (match.index != null)
|
|
@@ -2087,6 +2092,53 @@ class MagicString {
|
|
|
2087
2092
|
}
|
|
2088
2093
|
return this;
|
|
2089
2094
|
}
|
|
2095
|
+
|
|
2096
|
+
_replaceString(string, replacement) {
|
|
2097
|
+
const { original } = this;
|
|
2098
|
+
const index = original.indexOf(string);
|
|
2099
|
+
|
|
2100
|
+
if (index !== -1) {
|
|
2101
|
+
this.overwrite(index, index + string.length, replacement);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
return this;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
replace(searchValue, replacement) {
|
|
2108
|
+
if (typeof searchValue === 'string') {
|
|
2109
|
+
return this._replaceString(searchValue, replacement);
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
_replaceAllString(string, replacement) {
|
|
2116
|
+
const { original } = this;
|
|
2117
|
+
const stringLength = string.length;
|
|
2118
|
+
for (
|
|
2119
|
+
let index = original.indexOf(string);
|
|
2120
|
+
index !== -1;
|
|
2121
|
+
index = original.indexOf(string, index + stringLength)
|
|
2122
|
+
) {
|
|
2123
|
+
this.overwrite(index, index + stringLength, replacement);
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
return this;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
replaceAll(searchValue, replacement) {
|
|
2130
|
+
if (typeof searchValue === 'string') {
|
|
2131
|
+
return this._replaceAllString(searchValue, replacement);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
if (!searchValue.global) {
|
|
2135
|
+
throw new TypeError(
|
|
2136
|
+
'MagicString.prototype.replaceAll called with a non-global RegExp argument'
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
2141
|
+
}
|
|
2090
2142
|
}
|
|
2091
2143
|
|
|
2092
2144
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -2388,7 +2440,9 @@ class ExternalChunk {
|
|
|
2388
2440
|
this.namespaceVariableName = '';
|
|
2389
2441
|
this.variableName = '';
|
|
2390
2442
|
this.fileName = null;
|
|
2443
|
+
this.importAssertions = null;
|
|
2391
2444
|
this.id = module.id;
|
|
2445
|
+
this.moduleInfo = module.info;
|
|
2392
2446
|
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
2393
2447
|
this.suggestedVariableName = module.suggestedVariableName;
|
|
2394
2448
|
}
|
|
@@ -2401,12 +2455,27 @@ class ExternalChunk {
|
|
|
2401
2455
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
2402
2456
|
(this.renormalizeRenderPath ? normalize(node_path.relative(this.inputBase, this.id)) : this.id));
|
|
2403
2457
|
}
|
|
2458
|
+
getImportAssertions(snippets) {
|
|
2459
|
+
return (this.importAssertions || (this.importAssertions = formatAssertions(this.options.format === 'es' &&
|
|
2460
|
+
this.options.externalImportAssertions &&
|
|
2461
|
+
this.moduleInfo.assertions, snippets)));
|
|
2462
|
+
}
|
|
2404
2463
|
getImportPath(importer) {
|
|
2405
2464
|
return escapeId(this.renormalizeRenderPath
|
|
2406
2465
|
? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
|
|
2407
2466
|
: this.getFileName());
|
|
2408
2467
|
}
|
|
2409
2468
|
}
|
|
2469
|
+
function formatAssertions(assertions, { getObject }) {
|
|
2470
|
+
if (!assertions) {
|
|
2471
|
+
return null;
|
|
2472
|
+
}
|
|
2473
|
+
const assertionEntries = Object.entries(assertions).map(([key, value]) => [key, `'${value}'`]);
|
|
2474
|
+
if (assertionEntries.length) {
|
|
2475
|
+
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
2476
|
+
}
|
|
2477
|
+
return null;
|
|
2478
|
+
}
|
|
2410
2479
|
|
|
2411
2480
|
function getOrCreate(map, key, init) {
|
|
2412
2481
|
const existing = map.get(key);
|
|
@@ -2690,7 +2759,7 @@ function makeLegal(str) {
|
|
|
2690
2759
|
}
|
|
2691
2760
|
|
|
2692
2761
|
class ExternalModule {
|
|
2693
|
-
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath) {
|
|
2762
|
+
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, assertions) {
|
|
2694
2763
|
this.options = options;
|
|
2695
2764
|
this.id = id;
|
|
2696
2765
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
@@ -2706,6 +2775,7 @@ class ExternalModule {
|
|
|
2706
2775
|
this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
|
|
2707
2776
|
const { importers, dynamicImporters } = this;
|
|
2708
2777
|
const info = (this.info = {
|
|
2778
|
+
assertions,
|
|
2709
2779
|
ast: null,
|
|
2710
2780
|
code: null,
|
|
2711
2781
|
dynamicallyImportedIdResolutions: EMPTY_ARRAY,
|
|
@@ -2748,8 +2818,7 @@ class ExternalModule {
|
|
|
2748
2818
|
return [externalVariable];
|
|
2749
2819
|
}
|
|
2750
2820
|
suggestName(name) {
|
|
2751
|
-
|
|
2752
|
-
const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
2821
|
+
const value = (this.nameSuggestions.get(name) ?? 0) + 1;
|
|
2753
2822
|
this.nameSuggestions.set(name, value);
|
|
2754
2823
|
if (value > this.mostCommonSuggestion) {
|
|
2755
2824
|
this.mostCommonSuggestion = value;
|
|
@@ -2804,7 +2873,7 @@ var picomatch$1 = {exports: {}};
|
|
|
2804
2873
|
|
|
2805
2874
|
var utils$3 = {};
|
|
2806
2875
|
|
|
2807
|
-
const path$1 = require$$0;
|
|
2876
|
+
const path$1 = require$$0$1;
|
|
2808
2877
|
const WIN_SLASH = '\\\\/';
|
|
2809
2878
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2810
2879
|
|
|
@@ -2984,7 +3053,7 @@ var constants$2 = {
|
|
|
2984
3053
|
|
|
2985
3054
|
(function (exports) {
|
|
2986
3055
|
|
|
2987
|
-
const path = require$$0;
|
|
3056
|
+
const path = require$$0$1;
|
|
2988
3057
|
const win32 = process.platform === 'win32';
|
|
2989
3058
|
const {
|
|
2990
3059
|
REGEX_BACKSLASH,
|
|
@@ -3483,7 +3552,7 @@ const syntaxError = (type, char) => {
|
|
|
3483
3552
|
* @return {Object}
|
|
3484
3553
|
*/
|
|
3485
3554
|
|
|
3486
|
-
const parse$
|
|
3555
|
+
const parse$2 = (input, options) => {
|
|
3487
3556
|
if (typeof input !== 'string') {
|
|
3488
3557
|
throw new TypeError('Expected a string');
|
|
3489
3558
|
}
|
|
@@ -3686,7 +3755,7 @@ const parse$1 = (input, options) => {
|
|
|
3686
3755
|
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
3687
3756
|
//
|
|
3688
3757
|
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
3689
|
-
const expression = parse$
|
|
3758
|
+
const expression = parse$2(rest, { ...options, fastpaths: false }).output;
|
|
3690
3759
|
|
|
3691
3760
|
output = token.close = `)${expression})${extglobStar})`;
|
|
3692
3761
|
}
|
|
@@ -4432,7 +4501,7 @@ const parse$1 = (input, options) => {
|
|
|
4432
4501
|
* impact when none of the fast paths match.
|
|
4433
4502
|
*/
|
|
4434
4503
|
|
|
4435
|
-
parse$
|
|
4504
|
+
parse$2.fastpaths = (input, options) => {
|
|
4436
4505
|
const opts = { ...options };
|
|
4437
4506
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
4438
4507
|
const len = input.length;
|
|
@@ -4519,11 +4588,11 @@ parse$1.fastpaths = (input, options) => {
|
|
|
4519
4588
|
return source;
|
|
4520
4589
|
};
|
|
4521
4590
|
|
|
4522
|
-
var parse_1 = parse$
|
|
4591
|
+
var parse_1 = parse$2;
|
|
4523
4592
|
|
|
4524
|
-
const path = require$$0;
|
|
4593
|
+
const path = require$$0$1;
|
|
4525
4594
|
const scan = scan_1;
|
|
4526
|
-
const parse = parse_1;
|
|
4595
|
+
const parse$1 = parse_1;
|
|
4527
4596
|
const utils = utils$3;
|
|
4528
4597
|
const constants = constants$2;
|
|
4529
4598
|
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -4719,7 +4788,7 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
|
|
|
4719
4788
|
|
|
4720
4789
|
picomatch.parse = (pattern, options) => {
|
|
4721
4790
|
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
4722
|
-
return parse(pattern, { ...options, fastpaths: false });
|
|
4791
|
+
return parse$1(pattern, { ...options, fastpaths: false });
|
|
4723
4792
|
};
|
|
4724
4793
|
|
|
4725
4794
|
/**
|
|
@@ -4812,11 +4881,11 @@ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = fal
|
|
|
4812
4881
|
let parsed = { negated: false, fastpaths: true };
|
|
4813
4882
|
|
|
4814
4883
|
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
4815
|
-
parsed.output = parse.fastpaths(input, options);
|
|
4884
|
+
parsed.output = parse$1.fastpaths(input, options);
|
|
4816
4885
|
}
|
|
4817
4886
|
|
|
4818
4887
|
if (!parsed.output) {
|
|
4819
|
-
parsed = parse(input, options);
|
|
4888
|
+
parsed = parse$1(input, options);
|
|
4820
4889
|
}
|
|
4821
4890
|
|
|
4822
4891
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
@@ -4917,22 +4986,22 @@ function ensureArray(thing) {
|
|
|
4917
4986
|
}
|
|
4918
4987
|
|
|
4919
4988
|
const normalizePath = function normalizePath(filename) {
|
|
4920
|
-
return filename.split(require$$0.win32.sep).join(require$$0.posix.sep);
|
|
4989
|
+
return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
|
|
4921
4990
|
};
|
|
4922
4991
|
|
|
4923
4992
|
function getMatcherString(id, resolutionBase) {
|
|
4924
|
-
if (resolutionBase === false || require$$0.isAbsolute(id) || id.startsWith('*')) {
|
|
4993
|
+
if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('*')) {
|
|
4925
4994
|
return normalizePath(id);
|
|
4926
4995
|
}
|
|
4927
4996
|
// resolve('') is valid and will default to process.cwd()
|
|
4928
|
-
const basePath = normalizePath(require$$0.resolve(resolutionBase || ''))
|
|
4997
|
+
const basePath = normalizePath(require$$0$1.resolve(resolutionBase || ''))
|
|
4929
4998
|
// escape all possible (posix + win) path characters that might interfere with regex
|
|
4930
4999
|
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
|
4931
5000
|
// Note that we use posix.join because:
|
|
4932
5001
|
// 1. the basePath has been normalized to use /
|
|
4933
5002
|
// 2. the incoming glob (id) matcher, also uses /
|
|
4934
5003
|
// otherwise Node will force backslash (\) on windows
|
|
4935
|
-
return require$$0.posix.join(basePath, normalizePath(id));
|
|
5004
|
+
return require$$0$1.posix.join(basePath, normalizePath(id));
|
|
4936
5005
|
}
|
|
4937
5006
|
const createFilter = function createFilter(include, exclude, options) {
|
|
4938
5007
|
const resolutionBase = options && options.resolve;
|
|
@@ -5178,11 +5247,10 @@ function getLiteralMembersForValue(value) {
|
|
|
5178
5247
|
return Object.create(null);
|
|
5179
5248
|
}
|
|
5180
5249
|
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
5181
|
-
var _a, _b;
|
|
5182
5250
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
5183
5251
|
return true;
|
|
5184
5252
|
}
|
|
5185
|
-
return
|
|
5253
|
+
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
5186
5254
|
}
|
|
5187
5255
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
5188
5256
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
@@ -5609,6 +5677,9 @@ function annotateNode(node, comment, valid) {
|
|
|
5609
5677
|
}
|
|
5610
5678
|
|
|
5611
5679
|
const keys = {
|
|
5680
|
+
// TODO this should be removed once ImportExpression follows official ESTree
|
|
5681
|
+
// specs with "null" as default
|
|
5682
|
+
ImportExpression: ['arguments'],
|
|
5612
5683
|
Literal: [],
|
|
5613
5684
|
Program: ['body']
|
|
5614
5685
|
};
|
|
@@ -5646,14 +5717,12 @@ class NodeBase extends ExpressionEntity {
|
|
|
5646
5717
|
bind() {
|
|
5647
5718
|
for (const key of this.keys) {
|
|
5648
5719
|
const value = this[key];
|
|
5649
|
-
if (value === null)
|
|
5650
|
-
continue;
|
|
5651
5720
|
if (Array.isArray(value)) {
|
|
5652
5721
|
for (const child of value) {
|
|
5653
|
-
child
|
|
5722
|
+
child?.bind();
|
|
5654
5723
|
}
|
|
5655
5724
|
}
|
|
5656
|
-
else {
|
|
5725
|
+
else if (value) {
|
|
5657
5726
|
value.bind();
|
|
5658
5727
|
}
|
|
5659
5728
|
}
|
|
@@ -5673,7 +5742,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5673
5742
|
continue;
|
|
5674
5743
|
if (Array.isArray(value)) {
|
|
5675
5744
|
for (const child of value) {
|
|
5676
|
-
if (child
|
|
5745
|
+
if (child?.hasEffects(context))
|
|
5677
5746
|
return true;
|
|
5678
5747
|
}
|
|
5679
5748
|
}
|
|
@@ -5696,7 +5765,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5696
5765
|
continue;
|
|
5697
5766
|
if (Array.isArray(value)) {
|
|
5698
5767
|
for (const child of value) {
|
|
5699
|
-
child
|
|
5768
|
+
child?.include(context, includeChildrenRecursively);
|
|
5700
5769
|
}
|
|
5701
5770
|
}
|
|
5702
5771
|
else {
|
|
@@ -5753,7 +5822,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5753
5822
|
continue;
|
|
5754
5823
|
if (Array.isArray(value)) {
|
|
5755
5824
|
for (const child of value) {
|
|
5756
|
-
child
|
|
5825
|
+
child?.render(code, options);
|
|
5757
5826
|
}
|
|
5758
5827
|
}
|
|
5759
5828
|
else {
|
|
@@ -5780,7 +5849,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5780
5849
|
continue;
|
|
5781
5850
|
if (Array.isArray(value)) {
|
|
5782
5851
|
for (const child of value) {
|
|
5783
|
-
child
|
|
5852
|
+
child?.deoptimizePath(UNKNOWN_PATH);
|
|
5784
5853
|
}
|
|
5785
5854
|
}
|
|
5786
5855
|
else {
|
|
@@ -5836,19 +5905,18 @@ class Method extends ExpressionEntity {
|
|
|
5836
5905
|
: this.description.returns()));
|
|
5837
5906
|
}
|
|
5838
5907
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5839
|
-
var _a, _b;
|
|
5840
5908
|
const { type } = interaction;
|
|
5841
5909
|
if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
|
|
5842
5910
|
return true;
|
|
5843
5911
|
}
|
|
5844
5912
|
if (type === INTERACTION_CALLED) {
|
|
5845
5913
|
if (this.description.mutatesSelfAsArray === true &&
|
|
5846
|
-
|
|
5914
|
+
interaction.thisArg?.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)) {
|
|
5847
5915
|
return true;
|
|
5848
5916
|
}
|
|
5849
5917
|
if (this.description.callsArgs) {
|
|
5850
5918
|
for (const argIndex of this.description.callsArgs) {
|
|
5851
|
-
if (
|
|
5919
|
+
if (interaction.args[argIndex]?.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5852
5920
|
return true;
|
|
5853
5921
|
}
|
|
5854
5922
|
}
|
|
@@ -5924,7 +5992,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5924
5992
|
}
|
|
5925
5993
|
}
|
|
5926
5994
|
deoptimizeAllProperties(noAccessors) {
|
|
5927
|
-
var _a;
|
|
5928
5995
|
const isDeoptimized = this.hasLostTrack || this.hasUnknownDeoptimizedProperty;
|
|
5929
5996
|
if (noAccessors) {
|
|
5930
5997
|
this.hasUnknownDeoptimizedProperty = true;
|
|
@@ -5941,7 +6008,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5941
6008
|
}
|
|
5942
6009
|
}
|
|
5943
6010
|
// While the prototype itself cannot be mutated, each property can
|
|
5944
|
-
|
|
6011
|
+
this.prototypeExpression?.deoptimizePath([UnknownKey, UnknownKey]);
|
|
5945
6012
|
this.deoptimizeCachedEntities();
|
|
5946
6013
|
}
|
|
5947
6014
|
deoptimizeIntegerProperties() {
|
|
@@ -5962,7 +6029,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5962
6029
|
}
|
|
5963
6030
|
// Assumption: If only a specific path is deoptimized, no accessors are created
|
|
5964
6031
|
deoptimizePath(path) {
|
|
5965
|
-
var _a;
|
|
5966
6032
|
if (this.hasLostTrack || this.immutable) {
|
|
5967
6033
|
return;
|
|
5968
6034
|
}
|
|
@@ -5992,10 +6058,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5992
6058
|
: this.allProperties) {
|
|
5993
6059
|
property.deoptimizePath(subPath);
|
|
5994
6060
|
}
|
|
5995
|
-
|
|
6061
|
+
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
|
|
5996
6062
|
}
|
|
5997
6063
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5998
|
-
var _a;
|
|
5999
6064
|
const [key, ...subPath] = path;
|
|
6000
6065
|
if (this.hasLostTrack ||
|
|
6001
6066
|
// single paths that are deoptimized will not become getters or setters
|
|
@@ -6051,7 +6116,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6051
6116
|
if (!this.immutable) {
|
|
6052
6117
|
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
6053
6118
|
}
|
|
6054
|
-
|
|
6119
|
+
this.prototypeExpression?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6055
6120
|
}
|
|
6056
6121
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6057
6122
|
if (path.length === 0) {
|
|
@@ -6208,7 +6273,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6208
6273
|
return UNKNOWN_EXPRESSION;
|
|
6209
6274
|
}
|
|
6210
6275
|
const properties = this.propertiesAndGettersByKey[key];
|
|
6211
|
-
if (
|
|
6276
|
+
if (properties?.length === 1) {
|
|
6212
6277
|
return properties[0];
|
|
6213
6278
|
}
|
|
6214
6279
|
if (properties ||
|
|
@@ -6460,7 +6525,7 @@ class ArrayExpression extends NodeBase {
|
|
|
6460
6525
|
class ArrayPattern extends NodeBase {
|
|
6461
6526
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6462
6527
|
for (const element of this.elements) {
|
|
6463
|
-
element
|
|
6528
|
+
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
6464
6529
|
}
|
|
6465
6530
|
}
|
|
6466
6531
|
declare(kind) {
|
|
@@ -6475,20 +6540,20 @@ class ArrayPattern extends NodeBase {
|
|
|
6475
6540
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
6476
6541
|
deoptimizePath() {
|
|
6477
6542
|
for (const element of this.elements) {
|
|
6478
|
-
element
|
|
6543
|
+
element?.deoptimizePath(EMPTY_PATH);
|
|
6479
6544
|
}
|
|
6480
6545
|
}
|
|
6481
6546
|
// Patterns are only checked at the emtpy path at the moment
|
|
6482
6547
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
6483
6548
|
for (const element of this.elements) {
|
|
6484
|
-
if (element
|
|
6549
|
+
if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
6485
6550
|
return true;
|
|
6486
6551
|
}
|
|
6487
6552
|
return false;
|
|
6488
6553
|
}
|
|
6489
6554
|
markDeclarationReached() {
|
|
6490
6555
|
for (const element of this.elements) {
|
|
6491
|
-
element
|
|
6556
|
+
element?.markDeclarationReached();
|
|
6492
6557
|
}
|
|
6493
6558
|
}
|
|
6494
6559
|
}
|
|
@@ -6520,7 +6585,6 @@ class LocalVariable extends Variable {
|
|
|
6520
6585
|
}
|
|
6521
6586
|
}
|
|
6522
6587
|
deoptimizePath(path) {
|
|
6523
|
-
var _a, _b;
|
|
6524
6588
|
if (this.isReassigned ||
|
|
6525
6589
|
this.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
6526
6590
|
return;
|
|
@@ -6533,11 +6597,11 @@ class LocalVariable extends Variable {
|
|
|
6533
6597
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6534
6598
|
expression.deoptimizeCache();
|
|
6535
6599
|
}
|
|
6536
|
-
|
|
6600
|
+
this.init?.deoptimizePath(UNKNOWN_PATH);
|
|
6537
6601
|
}
|
|
6538
6602
|
}
|
|
6539
6603
|
else {
|
|
6540
|
-
|
|
6604
|
+
this.init?.deoptimizePath(path);
|
|
6541
6605
|
}
|
|
6542
6606
|
}
|
|
6543
6607
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -7872,13 +7936,12 @@ class Identifier extends NodeBase {
|
|
|
7872
7936
|
return [(this.variable = variable)];
|
|
7873
7937
|
}
|
|
7874
7938
|
deoptimizePath(path) {
|
|
7875
|
-
var _a;
|
|
7876
7939
|
if (path.length === 0 && !this.scope.contains(this.name)) {
|
|
7877
7940
|
this.disallowImportReassignment();
|
|
7878
7941
|
}
|
|
7879
7942
|
// We keep conditional chaining because an unknown Node could have an
|
|
7880
7943
|
// Identifier as property that might be deoptimized by default
|
|
7881
|
-
|
|
7944
|
+
this.variable?.deoptimizePath(path);
|
|
7882
7945
|
}
|
|
7883
7946
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7884
7947
|
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -8702,10 +8765,9 @@ class FunctionNode extends FunctionBase {
|
|
|
8702
8765
|
}
|
|
8703
8766
|
}
|
|
8704
8767
|
hasEffects(context) {
|
|
8705
|
-
var _a;
|
|
8706
8768
|
if (!this.deoptimized)
|
|
8707
8769
|
this.applyDeoptimizations();
|
|
8708
|
-
return !!
|
|
8770
|
+
return !!this.id?.hasEffects(context);
|
|
8709
8771
|
}
|
|
8710
8772
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8711
8773
|
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
@@ -8736,9 +8798,8 @@ class FunctionNode extends FunctionBase {
|
|
|
8736
8798
|
return false;
|
|
8737
8799
|
}
|
|
8738
8800
|
include(context, includeChildrenRecursively) {
|
|
8739
|
-
var _a;
|
|
8740
8801
|
super.include(context, includeChildrenRecursively);
|
|
8741
|
-
|
|
8802
|
+
this.id?.include();
|
|
8742
8803
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
8743
8804
|
for (const param of this.params) {
|
|
8744
8805
|
if (!(param instanceof Identifier) || hasArguments) {
|
|
@@ -8747,9 +8808,8 @@ class FunctionNode extends FunctionBase {
|
|
|
8747
8808
|
}
|
|
8748
8809
|
}
|
|
8749
8810
|
initialise() {
|
|
8750
|
-
var _a;
|
|
8751
8811
|
super.initialise();
|
|
8752
|
-
|
|
8812
|
+
this.id?.declare('function', this);
|
|
8753
8813
|
}
|
|
8754
8814
|
getObjectEntity() {
|
|
8755
8815
|
if (this.objectEntity !== null) {
|
|
@@ -9594,20 +9654,18 @@ class ClassNode extends NodeBase {
|
|
|
9594
9654
|
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9595
9655
|
}
|
|
9596
9656
|
hasEffects(context) {
|
|
9597
|
-
var _a, _b;
|
|
9598
9657
|
if (!this.deoptimized)
|
|
9599
9658
|
this.applyDeoptimizations();
|
|
9600
|
-
const initEffect =
|
|
9601
|
-
|
|
9659
|
+
const initEffect = this.superClass?.hasEffects(context) || this.body.hasEffects(context);
|
|
9660
|
+
this.id?.markDeclarationReached();
|
|
9602
9661
|
return initEffect || super.hasEffects(context);
|
|
9603
9662
|
}
|
|
9604
9663
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9605
|
-
var _a;
|
|
9606
9664
|
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
9607
9665
|
return (!interaction.withNew ||
|
|
9608
9666
|
(this.classConstructor !== null
|
|
9609
9667
|
? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
9610
|
-
:
|
|
9668
|
+
: this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
9611
9669
|
false);
|
|
9612
9670
|
}
|
|
9613
9671
|
else {
|
|
@@ -9615,11 +9673,10 @@ class ClassNode extends NodeBase {
|
|
|
9615
9673
|
}
|
|
9616
9674
|
}
|
|
9617
9675
|
include(context, includeChildrenRecursively) {
|
|
9618
|
-
var _a;
|
|
9619
9676
|
if (!this.deoptimized)
|
|
9620
9677
|
this.applyDeoptimizations();
|
|
9621
9678
|
this.included = true;
|
|
9622
|
-
|
|
9679
|
+
this.superClass?.include(context, includeChildrenRecursively);
|
|
9623
9680
|
this.body.include(context, includeChildrenRecursively);
|
|
9624
9681
|
if (this.id) {
|
|
9625
9682
|
this.id.markDeclarationReached();
|
|
@@ -9627,8 +9684,7 @@ class ClassNode extends NodeBase {
|
|
|
9627
9684
|
}
|
|
9628
9685
|
}
|
|
9629
9686
|
initialise() {
|
|
9630
|
-
|
|
9631
|
-
(_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('class', this);
|
|
9687
|
+
this.id?.declare('class', this);
|
|
9632
9688
|
for (const method of this.body.body) {
|
|
9633
9689
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
9634
9690
|
this.classConstructor = method;
|
|
@@ -10044,13 +10100,11 @@ ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
|
10044
10100
|
|
|
10045
10101
|
class ExportNamedDeclaration extends NodeBase {
|
|
10046
10102
|
bind() {
|
|
10047
|
-
var _a;
|
|
10048
10103
|
// Do not bind specifiers
|
|
10049
|
-
|
|
10104
|
+
this.declaration?.bind();
|
|
10050
10105
|
}
|
|
10051
10106
|
hasEffects(context) {
|
|
10052
|
-
|
|
10053
|
-
return !!((_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
|
|
10107
|
+
return !!this.declaration?.hasEffects(context);
|
|
10054
10108
|
}
|
|
10055
10109
|
initialise() {
|
|
10056
10110
|
this.context.addExport(this);
|
|
@@ -10168,10 +10222,9 @@ class ForStatement extends NodeBase {
|
|
|
10168
10222
|
this.scope = new BlockScope(parentScope);
|
|
10169
10223
|
}
|
|
10170
10224
|
hasEffects(context) {
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
((_c = this.update) === null || _c === void 0 ? void 0 : _c.hasEffects(context)))
|
|
10225
|
+
if (this.init?.hasEffects(context) ||
|
|
10226
|
+
this.test?.hasEffects(context) ||
|
|
10227
|
+
this.update?.hasEffects(context))
|
|
10175
10228
|
return true;
|
|
10176
10229
|
const { brokenFlow, ignore: { breaks, continues } } = context;
|
|
10177
10230
|
context.ignore.breaks = true;
|
|
@@ -10184,20 +10237,18 @@ class ForStatement extends NodeBase {
|
|
|
10184
10237
|
return false;
|
|
10185
10238
|
}
|
|
10186
10239
|
include(context, includeChildrenRecursively) {
|
|
10187
|
-
var _a, _b, _c;
|
|
10188
10240
|
this.included = true;
|
|
10189
|
-
|
|
10190
|
-
|
|
10241
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10242
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
10191
10243
|
const { brokenFlow } = context;
|
|
10192
|
-
|
|
10244
|
+
this.update?.include(context, includeChildrenRecursively);
|
|
10193
10245
|
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10194
10246
|
context.brokenFlow = brokenFlow;
|
|
10195
10247
|
}
|
|
10196
10248
|
render(code, options) {
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
(_c = this.update) === null || _c === void 0 ? void 0 : _c.render(code, options, NO_SEMICOLON);
|
|
10249
|
+
this.init?.render(code, options, NO_SEMICOLON);
|
|
10250
|
+
this.test?.render(code, options, NO_SEMICOLON);
|
|
10251
|
+
this.update?.render(code, options, NO_SEMICOLON);
|
|
10201
10252
|
this.body.render(code, options);
|
|
10202
10253
|
}
|
|
10203
10254
|
}
|
|
@@ -10233,7 +10284,6 @@ class IfStatement extends NodeBase {
|
|
|
10233
10284
|
this.testValue = UnknownValue;
|
|
10234
10285
|
}
|
|
10235
10286
|
hasEffects(context) {
|
|
10236
|
-
var _a;
|
|
10237
10287
|
if (this.test.hasEffects(context)) {
|
|
10238
10288
|
return true;
|
|
10239
10289
|
}
|
|
@@ -10252,7 +10302,7 @@ class IfStatement extends NodeBase {
|
|
|
10252
10302
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
10253
10303
|
return false;
|
|
10254
10304
|
}
|
|
10255
|
-
return testValue ? this.consequent.hasEffects(context) : !!
|
|
10305
|
+
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
10256
10306
|
}
|
|
10257
10307
|
include(context, includeChildrenRecursively) {
|
|
10258
10308
|
this.included = true;
|
|
@@ -10330,25 +10380,22 @@ class IfStatement extends NodeBase {
|
|
|
10330
10380
|
return this.testValue;
|
|
10331
10381
|
}
|
|
10332
10382
|
includeKnownTest(context, testValue) {
|
|
10333
|
-
var _a;
|
|
10334
10383
|
if (this.test.shouldBeIncluded(context)) {
|
|
10335
10384
|
this.test.include(context, false);
|
|
10336
10385
|
}
|
|
10337
10386
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
10338
10387
|
this.consequent.include(context, false, { asSingleStatement: true });
|
|
10339
10388
|
}
|
|
10340
|
-
if (!testValue &&
|
|
10389
|
+
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
10341
10390
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
10342
10391
|
}
|
|
10343
10392
|
}
|
|
10344
10393
|
includeRecursively(includeChildrenRecursively, context) {
|
|
10345
|
-
var _a;
|
|
10346
10394
|
this.test.include(context, includeChildrenRecursively);
|
|
10347
10395
|
this.consequent.include(context, includeChildrenRecursively);
|
|
10348
|
-
|
|
10396
|
+
this.alternate?.include(context, includeChildrenRecursively);
|
|
10349
10397
|
}
|
|
10350
10398
|
includeUnknownTest(context) {
|
|
10351
|
-
var _a;
|
|
10352
10399
|
this.test.include(context, false);
|
|
10353
10400
|
const { brokenFlow } = context;
|
|
10354
10401
|
let consequentBrokenFlow = BROKEN_FLOW_NONE;
|
|
@@ -10357,7 +10404,7 @@ class IfStatement extends NodeBase {
|
|
|
10357
10404
|
consequentBrokenFlow = context.brokenFlow;
|
|
10358
10405
|
context.brokenFlow = brokenFlow;
|
|
10359
10406
|
}
|
|
10360
|
-
if (
|
|
10407
|
+
if (this.alternate?.shouldBeIncluded(context)) {
|
|
10361
10408
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
10362
10409
|
context.brokenFlow =
|
|
10363
10410
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
@@ -10396,8 +10443,11 @@ class IfStatement extends NodeBase {
|
|
|
10396
10443
|
}
|
|
10397
10444
|
}
|
|
10398
10445
|
|
|
10446
|
+
class ImportAttribute extends NodeBase {
|
|
10447
|
+
}
|
|
10448
|
+
|
|
10399
10449
|
class ImportDeclaration extends NodeBase {
|
|
10400
|
-
// Do not bind specifiers
|
|
10450
|
+
// Do not bind specifiers or assertions
|
|
10401
10451
|
bind() { }
|
|
10402
10452
|
hasEffects() {
|
|
10403
10453
|
return false;
|
|
@@ -10621,15 +10671,22 @@ function getToStringTagValue(getObject) {
|
|
|
10621
10671
|
});
|
|
10622
10672
|
}
|
|
10623
10673
|
|
|
10674
|
+
// TODO once ImportExpression follows official ESTree specs with "null" as
|
|
10675
|
+
// default, keys.ts should be updated
|
|
10624
10676
|
class ImportExpression extends NodeBase {
|
|
10625
10677
|
constructor() {
|
|
10626
10678
|
super(...arguments);
|
|
10627
10679
|
this.inlineNamespace = null;
|
|
10680
|
+
this.assertions = null;
|
|
10628
10681
|
this.mechanism = null;
|
|
10629
10682
|
this.namespaceExportName = undefined;
|
|
10630
10683
|
this.resolution = null;
|
|
10631
10684
|
this.resolutionString = null;
|
|
10632
10685
|
}
|
|
10686
|
+
// Do not bind assertions
|
|
10687
|
+
bind() {
|
|
10688
|
+
this.source.bind();
|
|
10689
|
+
}
|
|
10633
10690
|
hasEffects() {
|
|
10634
10691
|
return true;
|
|
10635
10692
|
}
|
|
@@ -10645,19 +10702,19 @@ class ImportExpression extends NodeBase {
|
|
|
10645
10702
|
this.context.addDynamicImport(this);
|
|
10646
10703
|
}
|
|
10647
10704
|
render(code, options) {
|
|
10648
|
-
const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
|
|
10705
|
+
const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
|
|
10649
10706
|
if (this.inlineNamespace) {
|
|
10650
10707
|
const [left, right] = getDirectReturnFunction([], {
|
|
10651
10708
|
functionReturn: true,
|
|
10652
10709
|
lineBreakIndent: null,
|
|
10653
10710
|
name: null
|
|
10654
10711
|
});
|
|
10655
|
-
code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})
|
|
10712
|
+
code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})`);
|
|
10656
10713
|
return;
|
|
10657
10714
|
}
|
|
10658
10715
|
if (this.mechanism) {
|
|
10659
|
-
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left
|
|
10660
|
-
code.overwrite(this.end - 1, this.end, this.mechanism.right
|
|
10716
|
+
code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
|
|
10717
|
+
code.overwrite(this.end - 1, this.end, this.mechanism.right);
|
|
10661
10718
|
}
|
|
10662
10719
|
if (this.resolutionString) {
|
|
10663
10720
|
code.overwrite(this.source.start, this.source.end, this.resolutionString);
|
|
@@ -10673,13 +10730,24 @@ class ImportExpression extends NodeBase {
|
|
|
10673
10730
|
else {
|
|
10674
10731
|
this.source.render(code, options);
|
|
10675
10732
|
}
|
|
10733
|
+
if (this.assertions !== true) {
|
|
10734
|
+
if (this.arguments) {
|
|
10735
|
+
code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true });
|
|
10736
|
+
}
|
|
10737
|
+
if (this.assertions) {
|
|
10738
|
+
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.assertions]], {
|
|
10739
|
+
lineBreakIndent: null
|
|
10740
|
+
})}`);
|
|
10741
|
+
}
|
|
10742
|
+
}
|
|
10676
10743
|
}
|
|
10677
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
|
|
10744
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, assertions) {
|
|
10678
10745
|
const { format } = options;
|
|
10679
10746
|
this.inlineNamespace = null;
|
|
10680
10747
|
this.resolution = resolution;
|
|
10681
10748
|
this.resolutionString = resolutionString;
|
|
10682
10749
|
this.namespaceExportName = namespaceExportName;
|
|
10750
|
+
this.assertions = assertions;
|
|
10683
10751
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
10684
10752
|
let helper;
|
|
10685
10753
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -10694,7 +10762,7 @@ class ImportExpression extends NodeBase {
|
|
|
10694
10762
|
this.inlineNamespace = inlineNamespace;
|
|
10695
10763
|
}
|
|
10696
10764
|
applyDeoptimizations() { }
|
|
10697
|
-
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
10765
|
+
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
10698
10766
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
10699
10767
|
{
|
|
10700
10768
|
customResolution: typeof this.resolution === 'string' ? this.resolution : null,
|
|
@@ -10709,6 +10777,10 @@ class ImportExpression extends NodeBase {
|
|
|
10709
10777
|
const hasDynamicTarget = !this.resolution || typeof this.resolution === 'string';
|
|
10710
10778
|
switch (format) {
|
|
10711
10779
|
case 'cjs': {
|
|
10780
|
+
if (dynamicImportInCjs &&
|
|
10781
|
+
(!resolution || typeof resolution === 'string' || resolution instanceof ExternalModule)) {
|
|
10782
|
+
return { helper: null, mechanism: null };
|
|
10783
|
+
}
|
|
10712
10784
|
const helper = getInteropHelper(resolution, exportMode, interop);
|
|
10713
10785
|
let left = `require(`;
|
|
10714
10786
|
let right = `)`;
|
|
@@ -10984,7 +11056,7 @@ class MetaProperty extends NodeBase {
|
|
|
10984
11056
|
}
|
|
10985
11057
|
getReferencedFileName(outputPluginDriver) {
|
|
10986
11058
|
const { metaProperty } = this;
|
|
10987
|
-
if (metaProperty
|
|
11059
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
10988
11060
|
return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
|
|
10989
11061
|
}
|
|
10990
11062
|
return null;
|
|
@@ -11005,14 +11077,13 @@ class MetaProperty extends NodeBase {
|
|
|
11005
11077
|
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
11006
11078
|
? parent.propertyKey
|
|
11007
11079
|
: null);
|
|
11008
|
-
if (metaProperty
|
|
11080
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
11009
11081
|
this.referenceId = metaProperty.substring(FILE_PREFIX.length);
|
|
11010
11082
|
}
|
|
11011
11083
|
}
|
|
11012
11084
|
}
|
|
11013
11085
|
}
|
|
11014
11086
|
render(code, { format, pluginDriver, snippets }) {
|
|
11015
|
-
var _a;
|
|
11016
11087
|
const { metaProperty, parent, referenceId } = this;
|
|
11017
11088
|
const chunkId = this.preliminaryChunkId;
|
|
11018
11089
|
if (referenceId) {
|
|
@@ -11038,7 +11109,7 @@ class MetaProperty extends NodeBase {
|
|
|
11038
11109
|
format,
|
|
11039
11110
|
moduleId: this.context.module.id
|
|
11040
11111
|
}
|
|
11041
|
-
]) ||
|
|
11112
|
+
]) || importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
11042
11113
|
if (typeof replacement === 'string') {
|
|
11043
11114
|
if (parent instanceof MemberExpression) {
|
|
11044
11115
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
@@ -11049,9 +11120,8 @@ class MetaProperty extends NodeBase {
|
|
|
11049
11120
|
}
|
|
11050
11121
|
}
|
|
11051
11122
|
setResolution(format, accessedGlobalsByScope, preliminaryChunkId) {
|
|
11052
|
-
var _a;
|
|
11053
11123
|
this.preliminaryChunkId = preliminaryChunkId;
|
|
11054
|
-
const accessedGlobals = (
|
|
11124
|
+
const accessedGlobals = (this.metaProperty?.startsWith(FILE_PREFIX) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
|
|
11055
11125
|
if (accessedGlobals.length > 0) {
|
|
11056
11126
|
this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
|
|
11057
11127
|
}
|
|
@@ -11309,12 +11379,10 @@ class Property extends MethodBase {
|
|
|
11309
11379
|
|
|
11310
11380
|
class PropertyDefinition extends NodeBase {
|
|
11311
11381
|
deoptimizePath(path) {
|
|
11312
|
-
|
|
11313
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
11382
|
+
this.value?.deoptimizePath(path);
|
|
11314
11383
|
}
|
|
11315
11384
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11316
|
-
|
|
11317
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11385
|
+
this.value?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11318
11386
|
}
|
|
11319
11387
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11320
11388
|
return this.value
|
|
@@ -11327,8 +11395,7 @@ class PropertyDefinition extends NodeBase {
|
|
|
11327
11395
|
: UNKNOWN_EXPRESSION;
|
|
11328
11396
|
}
|
|
11329
11397
|
hasEffects(context) {
|
|
11330
|
-
|
|
11331
|
-
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
11398
|
+
return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
|
|
11332
11399
|
}
|
|
11333
11400
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11334
11401
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -11338,16 +11405,14 @@ class PropertyDefinition extends NodeBase {
|
|
|
11338
11405
|
|
|
11339
11406
|
class ReturnStatement extends NodeBase {
|
|
11340
11407
|
hasEffects(context) {
|
|
11341
|
-
|
|
11342
|
-
if (!context.ignore.returnYield || ((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)))
|
|
11408
|
+
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
11343
11409
|
return true;
|
|
11344
11410
|
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
11345
11411
|
return false;
|
|
11346
11412
|
}
|
|
11347
11413
|
include(context, includeChildrenRecursively) {
|
|
11348
|
-
var _a;
|
|
11349
11414
|
this.included = true;
|
|
11350
|
-
|
|
11415
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
11351
11416
|
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
11352
11417
|
}
|
|
11353
11418
|
initialise() {
|
|
@@ -11473,8 +11538,7 @@ class Super extends NodeBase {
|
|
|
11473
11538
|
|
|
11474
11539
|
class SwitchCase extends NodeBase {
|
|
11475
11540
|
hasEffects(context) {
|
|
11476
|
-
|
|
11477
|
-
if ((_a = this.test) === null || _a === void 0 ? void 0 : _a.hasEffects(context))
|
|
11541
|
+
if (this.test?.hasEffects(context))
|
|
11478
11542
|
return true;
|
|
11479
11543
|
for (const node of this.consequent) {
|
|
11480
11544
|
if (context.brokenFlow)
|
|
@@ -11485,9 +11549,8 @@ class SwitchCase extends NodeBase {
|
|
|
11485
11549
|
return false;
|
|
11486
11550
|
}
|
|
11487
11551
|
include(context, includeChildrenRecursively) {
|
|
11488
|
-
var _a;
|
|
11489
11552
|
this.included = true;
|
|
11490
|
-
|
|
11553
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
11491
11554
|
for (const node of this.consequent) {
|
|
11492
11555
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
11493
11556
|
node.include(context, includeChildrenRecursively);
|
|
@@ -11874,14 +11937,13 @@ class TryStatement extends NodeBase {
|
|
|
11874
11937
|
this.includedLabelsAfterBlock = null;
|
|
11875
11938
|
}
|
|
11876
11939
|
hasEffects(context) {
|
|
11877
|
-
var _a;
|
|
11878
11940
|
return ((this.context.options.treeshake.tryCatchDeoptimization
|
|
11879
11941
|
? this.block.body.length > 0
|
|
11880
|
-
: this.block.hasEffects(context)) || !!
|
|
11942
|
+
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
11881
11943
|
}
|
|
11882
11944
|
include(context, includeChildrenRecursively) {
|
|
11883
|
-
|
|
11884
|
-
|
|
11945
|
+
const tryCatchDeoptimization = this.context.options.treeshake
|
|
11946
|
+
?.tryCatchDeoptimization;
|
|
11885
11947
|
const { brokenFlow } = context;
|
|
11886
11948
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
11887
11949
|
this.included = true;
|
|
@@ -11901,7 +11963,7 @@ class TryStatement extends NodeBase {
|
|
|
11901
11963
|
this.handler.include(context, includeChildrenRecursively);
|
|
11902
11964
|
context.brokenFlow = brokenFlow;
|
|
11903
11965
|
}
|
|
11904
|
-
|
|
11966
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
11905
11967
|
}
|
|
11906
11968
|
}
|
|
11907
11969
|
|
|
@@ -12153,14 +12215,13 @@ class VariableDeclaration extends NodeBase {
|
|
|
12153
12215
|
}
|
|
12154
12216
|
}
|
|
12155
12217
|
function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
|
|
12156
|
-
var _a;
|
|
12157
12218
|
let singleSystemExport = null;
|
|
12158
12219
|
if (options.format === 'system') {
|
|
12159
12220
|
for (const { node } of separatedNodes) {
|
|
12160
12221
|
if (node.id instanceof Identifier &&
|
|
12161
12222
|
node.init &&
|
|
12162
12223
|
aggregatedSystemExports.length === 0 &&
|
|
12163
|
-
|
|
12224
|
+
options.exportNamesByVariable.get(node.id.variable)?.length === 1) {
|
|
12164
12225
|
singleSystemExport = node.id.variable;
|
|
12165
12226
|
aggregatedSystemExports.push(singleSystemExport);
|
|
12166
12227
|
}
|
|
@@ -12186,15 +12247,13 @@ class VariableDeclarator extends NodeBase {
|
|
|
12186
12247
|
this.id.deoptimizePath(path);
|
|
12187
12248
|
}
|
|
12188
12249
|
hasEffects(context) {
|
|
12189
|
-
|
|
12190
|
-
const initEffect = (_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
|
|
12250
|
+
const initEffect = this.init?.hasEffects(context);
|
|
12191
12251
|
this.id.markDeclarationReached();
|
|
12192
12252
|
return initEffect || this.id.hasEffects(context);
|
|
12193
12253
|
}
|
|
12194
12254
|
include(context, includeChildrenRecursively) {
|
|
12195
|
-
var _a;
|
|
12196
12255
|
this.included = true;
|
|
12197
|
-
|
|
12256
|
+
this.init?.include(context, includeChildrenRecursively);
|
|
12198
12257
|
this.id.markDeclarationReached();
|
|
12199
12258
|
if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
|
|
12200
12259
|
this.id.include(context, includeChildrenRecursively);
|
|
@@ -12246,10 +12305,9 @@ class WhileStatement extends NodeBase {
|
|
|
12246
12305
|
|
|
12247
12306
|
class YieldExpression extends NodeBase {
|
|
12248
12307
|
hasEffects(context) {
|
|
12249
|
-
var _a;
|
|
12250
12308
|
if (!this.deoptimized)
|
|
12251
12309
|
this.applyDeoptimizations();
|
|
12252
|
-
return !(context.ignore.returnYield && !
|
|
12310
|
+
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
12253
12311
|
}
|
|
12254
12312
|
render(code, options) {
|
|
12255
12313
|
if (this.argument) {
|
|
@@ -12293,6 +12351,7 @@ const nodeConstructors = {
|
|
|
12293
12351
|
FunctionExpression,
|
|
12294
12352
|
Identifier,
|
|
12295
12353
|
IfStatement,
|
|
12354
|
+
ImportAttribute,
|
|
12296
12355
|
ImportDeclaration,
|
|
12297
12356
|
ImportDefaultSpecifier,
|
|
12298
12357
|
ImportExpression,
|
|
@@ -12517,6 +12576,41 @@ function getOriginalLocation(sourcemapChain, location) {
|
|
|
12517
12576
|
return location;
|
|
12518
12577
|
}
|
|
12519
12578
|
|
|
12579
|
+
function getAssertionsFromImportExpression(node) {
|
|
12580
|
+
const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
|
|
12581
|
+
if (!assertProperty) {
|
|
12582
|
+
return EMPTY_OBJECT;
|
|
12583
|
+
}
|
|
12584
|
+
const assertFields = assertProperty.properties
|
|
12585
|
+
.map(property => {
|
|
12586
|
+
const key = getPropertyKey(property);
|
|
12587
|
+
if (typeof key === 'string' &&
|
|
12588
|
+
typeof property.value.value === 'string') {
|
|
12589
|
+
return [key, property.value.value];
|
|
12590
|
+
}
|
|
12591
|
+
return null;
|
|
12592
|
+
})
|
|
12593
|
+
.filter((property) => !!property);
|
|
12594
|
+
if (assertFields.length > 0) {
|
|
12595
|
+
return Object.fromEntries(assertFields);
|
|
12596
|
+
}
|
|
12597
|
+
return EMPTY_OBJECT;
|
|
12598
|
+
}
|
|
12599
|
+
const getPropertyKey = (property) => {
|
|
12600
|
+
const key = property.key;
|
|
12601
|
+
return key && (key.name || key.value);
|
|
12602
|
+
};
|
|
12603
|
+
function getAssertionsFromImportExportDeclaration(assertions) {
|
|
12604
|
+
return assertions?.length
|
|
12605
|
+
? Object.fromEntries(assertions.map(assertion => [getPropertyKey(assertion), assertion.value.value]))
|
|
12606
|
+
: EMPTY_OBJECT;
|
|
12607
|
+
}
|
|
12608
|
+
function doAssertionsDiffer(assertionA, assertionB) {
|
|
12609
|
+
const keysA = Object.keys(assertionA);
|
|
12610
|
+
return (keysA.length !== Object.keys(assertionB).length ||
|
|
12611
|
+
keysA.some(key => assertionA[key] !== assertionB[key]));
|
|
12612
|
+
}
|
|
12613
|
+
|
|
12520
12614
|
const NOOP = () => { };
|
|
12521
12615
|
let timers = new Map();
|
|
12522
12616
|
function getPersistedLabel(label, level) {
|
|
@@ -12687,7 +12781,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
12687
12781
|
return sideEffectModules;
|
|
12688
12782
|
}
|
|
12689
12783
|
class Module {
|
|
12690
|
-
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta) {
|
|
12784
|
+
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions) {
|
|
12691
12785
|
this.graph = graph;
|
|
12692
12786
|
this.id = id;
|
|
12693
12787
|
this.options = options;
|
|
@@ -12712,7 +12806,7 @@ class Module {
|
|
|
12712
12806
|
this.isUserDefinedEntryPoint = false;
|
|
12713
12807
|
this.needsExportShim = false;
|
|
12714
12808
|
this.sideEffectDependenciesByVariable = new Map();
|
|
12715
|
-
this.
|
|
12809
|
+
this.sourcesWithAssertions = new Map();
|
|
12716
12810
|
this.allExportNames = null;
|
|
12717
12811
|
this.ast = null;
|
|
12718
12812
|
this.exportAllModules = [];
|
|
@@ -12732,8 +12826,9 @@ class Module {
|
|
|
12732
12826
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
12733
12827
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
12734
12828
|
const module = this;
|
|
12735
|
-
const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions,
|
|
12829
|
+
const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAssertions } = this;
|
|
12736
12830
|
this.info = {
|
|
12831
|
+
assertions,
|
|
12737
12832
|
ast: null,
|
|
12738
12833
|
code: null,
|
|
12739
12834
|
get dynamicallyImportedIdResolutions() {
|
|
@@ -12768,12 +12863,12 @@ class Module {
|
|
|
12768
12863
|
return Array.from(implicitlyLoadedBefore, getId).sort();
|
|
12769
12864
|
},
|
|
12770
12865
|
get importedIdResolutions() {
|
|
12771
|
-
return Array.from(
|
|
12866
|
+
return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]).filter(Boolean);
|
|
12772
12867
|
},
|
|
12773
12868
|
get importedIds() {
|
|
12774
12869
|
// We cannot use this.dependencies because this is needed before
|
|
12775
12870
|
// dependencies are populated
|
|
12776
|
-
return Array.from(
|
|
12871
|
+
return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]?.id).filter(Boolean);
|
|
12777
12872
|
},
|
|
12778
12873
|
get importers() {
|
|
12779
12874
|
return importers.sort();
|
|
@@ -12945,7 +13040,6 @@ class Module {
|
|
|
12945
13040
|
return this.syntheticNamespace;
|
|
12946
13041
|
}
|
|
12947
13042
|
getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, onlyExplicit, searchedNamesAndModules } = EMPTY_OBJECT) {
|
|
12948
|
-
var _a;
|
|
12949
13043
|
if (name[0] === '*') {
|
|
12950
13044
|
if (name.length === 1) {
|
|
12951
13045
|
// export * from './other'
|
|
@@ -12987,7 +13081,8 @@ class Module {
|
|
|
12987
13081
|
return [null];
|
|
12988
13082
|
}
|
|
12989
13083
|
if (name !== 'default') {
|
|
12990
|
-
const foundNamespaceReexport =
|
|
13084
|
+
const foundNamespaceReexport = this.namespaceReexportsByName.get(name) ??
|
|
13085
|
+
this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
|
|
12991
13086
|
this.namespaceReexportsByName.set(name, foundNamespaceReexport);
|
|
12992
13087
|
if (foundNamespaceReexport[0]) {
|
|
12993
13088
|
return foundNamespaceReexport;
|
|
@@ -13139,6 +13234,7 @@ class Module {
|
|
|
13139
13234
|
}
|
|
13140
13235
|
toJSON() {
|
|
13141
13236
|
return {
|
|
13237
|
+
assertions: this.info.assertions,
|
|
13142
13238
|
ast: this.ast.esTreeNode,
|
|
13143
13239
|
code: this.info.code,
|
|
13144
13240
|
customTransformCache: this.customTransformCache,
|
|
@@ -13219,7 +13315,7 @@ class Module {
|
|
|
13219
13315
|
}
|
|
13220
13316
|
else if (node instanceof ExportAllDeclaration) {
|
|
13221
13317
|
const source = node.source.value;
|
|
13222
|
-
this.
|
|
13318
|
+
this.addSource(source, node);
|
|
13223
13319
|
if (node.exported) {
|
|
13224
13320
|
// export * as name from './other'
|
|
13225
13321
|
const name = node.exported.name;
|
|
@@ -13238,7 +13334,7 @@ class Module {
|
|
|
13238
13334
|
else if (node.source instanceof Literal) {
|
|
13239
13335
|
// export { name } from './other'
|
|
13240
13336
|
const source = node.source.value;
|
|
13241
|
-
this.
|
|
13337
|
+
this.addSource(source, node);
|
|
13242
13338
|
for (const specifier of node.specifiers) {
|
|
13243
13339
|
const name = specifier.exported.name;
|
|
13244
13340
|
this.reexportDescriptions.set(name, {
|
|
@@ -13277,7 +13373,7 @@ class Module {
|
|
|
13277
13373
|
}
|
|
13278
13374
|
addImport(node) {
|
|
13279
13375
|
const source = node.source.value;
|
|
13280
|
-
this.
|
|
13376
|
+
this.addSource(source, node);
|
|
13281
13377
|
for (const specifier of node.specifiers) {
|
|
13282
13378
|
const isDefault = specifier.type === ImportDefaultSpecifier$1;
|
|
13283
13379
|
const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
|
|
@@ -13341,6 +13437,18 @@ class Module {
|
|
|
13341
13437
|
addSideEffectDependencies(this.dependencies);
|
|
13342
13438
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
13343
13439
|
}
|
|
13440
|
+
addSource(source, declaration) {
|
|
13441
|
+
const parsedAssertions = getAssertionsFromImportExportDeclaration(declaration.assertions);
|
|
13442
|
+
const existingAssertions = this.sourcesWithAssertions.get(source);
|
|
13443
|
+
if (existingAssertions) {
|
|
13444
|
+
if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
|
|
13445
|
+
this.warn(errInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
|
|
13446
|
+
}
|
|
13447
|
+
}
|
|
13448
|
+
else {
|
|
13449
|
+
this.sourcesWithAssertions.set(source, parsedAssertions);
|
|
13450
|
+
}
|
|
13451
|
+
}
|
|
13344
13452
|
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
|
|
13345
13453
|
let foundSyntheticDeclaration = null;
|
|
13346
13454
|
const foundInternalDeclarations = new Map();
|
|
@@ -13792,8 +13900,8 @@ function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
|
13792
13900
|
}
|
|
13793
13901
|
|
|
13794
13902
|
function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }, { externalLiveBindings, freeze, namespaceToStringTag }) {
|
|
13795
|
-
const {
|
|
13796
|
-
const importBlock = getImportBlock(dependencies,
|
|
13903
|
+
const { n } = snippets;
|
|
13904
|
+
const importBlock = getImportBlock(dependencies, snippets);
|
|
13797
13905
|
if (importBlock.length > 0)
|
|
13798
13906
|
intro += importBlock.join(n) + n + n;
|
|
13799
13907
|
intro += getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, namespaceToStringTag);
|
|
@@ -13806,11 +13914,13 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
13806
13914
|
magicString.append(outro);
|
|
13807
13915
|
magicString.trim();
|
|
13808
13916
|
}
|
|
13809
|
-
function getImportBlock(dependencies, _) {
|
|
13917
|
+
function getImportBlock(dependencies, { _ }) {
|
|
13810
13918
|
const importBlock = [];
|
|
13811
|
-
for (const { importPath, reexports, imports, name } of dependencies) {
|
|
13919
|
+
for (const { importPath, reexports, imports, name, assertions } of dependencies) {
|
|
13920
|
+
const assertion = assertions ? `${_}assert${_}${assertions}` : '';
|
|
13921
|
+
const pathWithAssertion = `'${importPath}'${assertion};`;
|
|
13812
13922
|
if (!reexports && !imports) {
|
|
13813
|
-
importBlock.push(`import${_}
|
|
13923
|
+
importBlock.push(`import${_}${pathWithAssertion}`);
|
|
13814
13924
|
continue;
|
|
13815
13925
|
}
|
|
13816
13926
|
if (imports) {
|
|
@@ -13829,10 +13939,10 @@ function getImportBlock(dependencies, _) {
|
|
|
13829
13939
|
}
|
|
13830
13940
|
}
|
|
13831
13941
|
if (starImport) {
|
|
13832
|
-
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}
|
|
13942
|
+
importBlock.push(`import${_}*${_}as ${starImport.local} from${_}${pathWithAssertion}`);
|
|
13833
13943
|
}
|
|
13834
13944
|
if (defaultImport && importedNames.length === 0) {
|
|
13835
|
-
importBlock.push(`import ${defaultImport.local} from${_}
|
|
13945
|
+
importBlock.push(`import ${defaultImport.local} from${_}${pathWithAssertion}`);
|
|
13836
13946
|
}
|
|
13837
13947
|
else if (importedNames.length > 0) {
|
|
13838
13948
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
@@ -13844,7 +13954,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13844
13954
|
return `${specifier.imported} as ${specifier.local}`;
|
|
13845
13955
|
}
|
|
13846
13956
|
})
|
|
13847
|
-
.join(`,${_}`)}${_}}${_}from${_}
|
|
13957
|
+
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13848
13958
|
}
|
|
13849
13959
|
}
|
|
13850
13960
|
if (reexports) {
|
|
@@ -13863,12 +13973,12 @@ function getImportBlock(dependencies, _) {
|
|
|
13863
13973
|
}
|
|
13864
13974
|
}
|
|
13865
13975
|
if (starExport) {
|
|
13866
|
-
importBlock.push(`export${_}*${_}from${_}
|
|
13976
|
+
importBlock.push(`export${_}*${_}from${_}${pathWithAssertion}`);
|
|
13867
13977
|
}
|
|
13868
13978
|
if (namespaceReexports.length > 0) {
|
|
13869
13979
|
if (!imports ||
|
|
13870
13980
|
!imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
|
|
13871
|
-
importBlock.push(`import${_}*${_}as ${name} from${_}
|
|
13981
|
+
importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
|
|
13872
13982
|
}
|
|
13873
13983
|
for (const specifier of namespaceReexports) {
|
|
13874
13984
|
importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
|
|
@@ -13884,7 +13994,7 @@ function getImportBlock(dependencies, _) {
|
|
|
13884
13994
|
return `${specifier.imported} as ${specifier.reexported}`;
|
|
13885
13995
|
}
|
|
13886
13996
|
})
|
|
13887
|
-
.join(`,${_}`)}${_}}${_}from${_}
|
|
13997
|
+
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13888
13998
|
}
|
|
13889
13999
|
}
|
|
13890
14000
|
}
|
|
@@ -14752,7 +14862,6 @@ class Chunk {
|
|
|
14752
14862
|
this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
|
|
14753
14863
|
}
|
|
14754
14864
|
generateFacades() {
|
|
14755
|
-
var _a;
|
|
14756
14865
|
const facades = [];
|
|
14757
14866
|
const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
|
|
14758
14867
|
const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
|
|
@@ -14809,7 +14918,7 @@ class Chunk {
|
|
|
14809
14918
|
this.canModuleBeFacade(module, exposedVariables)) {
|
|
14810
14919
|
this.strictFacade = true;
|
|
14811
14920
|
}
|
|
14812
|
-
else if (!
|
|
14921
|
+
else if (!this.facadeChunkByModule.get(module)?.strictFacade) {
|
|
14813
14922
|
this.includedNamespaces.add(module);
|
|
14814
14923
|
this.exports.add(module.namespace);
|
|
14815
14924
|
}
|
|
@@ -14838,22 +14947,18 @@ class Chunk {
|
|
|
14838
14947
|
};
|
|
14839
14948
|
}
|
|
14840
14949
|
getChunkName() {
|
|
14841
|
-
|
|
14842
|
-
return ((_a = this.name) !== null && _a !== void 0 ? _a : (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14950
|
+
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14843
14951
|
}
|
|
14844
14952
|
getExportNames() {
|
|
14845
|
-
|
|
14846
|
-
return ((_a = this.sortedExportNames) !== null && _a !== void 0 ? _a : (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14953
|
+
return (this.sortedExportNames ?? (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
|
|
14847
14954
|
}
|
|
14848
14955
|
getFileName() {
|
|
14849
|
-
|
|
14850
|
-
return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
|
|
14956
|
+
return this.preliminaryFileName?.fileName || this.getPreliminaryFileName().fileName;
|
|
14851
14957
|
}
|
|
14852
14958
|
getImportPath(importer) {
|
|
14853
14959
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
14854
14960
|
}
|
|
14855
14961
|
getPreliminaryFileName() {
|
|
14856
|
-
var _a;
|
|
14857
14962
|
if (this.preliminaryFileName) {
|
|
14858
14963
|
return this.preliminaryFileName;
|
|
14859
14964
|
}
|
|
@@ -14867,7 +14972,7 @@ class Chunk {
|
|
|
14867
14972
|
fileName = this.fileName;
|
|
14868
14973
|
}
|
|
14869
14974
|
else {
|
|
14870
|
-
const [pattern, patternName] = preserveModules ||
|
|
14975
|
+
const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
|
|
14871
14976
|
? [entryFileNames, 'output.entryFileNames']
|
|
14872
14977
|
: [chunkFileNames, 'output.chunkFileNames'];
|
|
14873
14978
|
fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
@@ -14932,7 +15037,7 @@ class Chunk {
|
|
|
14932
15037
|
let hasExports = renderedExports.length !== 0;
|
|
14933
15038
|
let hasDefaultExport = false;
|
|
14934
15039
|
for (const { reexports } of renderedDependencies) {
|
|
14935
|
-
if (reexports
|
|
15040
|
+
if (reexports?.length) {
|
|
14936
15041
|
hasExports = true;
|
|
14937
15042
|
if (reexports.some(reexport => reexport.reexported === 'default')) {
|
|
14938
15043
|
hasDefaultExport = true;
|
|
@@ -15154,6 +15259,16 @@ class Chunk {
|
|
|
15154
15259
|
.filter((resolution) => resolution !== this &&
|
|
15155
15260
|
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
15156
15261
|
}
|
|
15262
|
+
getDynamicImportStringAndAssertions(resolution, fileName) {
|
|
15263
|
+
if (resolution instanceof ExternalModule) {
|
|
15264
|
+
const chunk = this.externalChunkByModule.get(resolution);
|
|
15265
|
+
return [`'${chunk.getImportPath(fileName)}'`, chunk.getImportAssertions(this.snippets)];
|
|
15266
|
+
}
|
|
15267
|
+
return [
|
|
15268
|
+
resolution || '',
|
|
15269
|
+
(this.outputOptions.format === 'es' && this.outputOptions.externalImportAssertions) || null
|
|
15270
|
+
];
|
|
15271
|
+
}
|
|
15157
15272
|
getFallbackChunkName() {
|
|
15158
15273
|
if (this.manualChunkAlias) {
|
|
15159
15274
|
return this.manualChunkAlias;
|
|
@@ -15231,7 +15346,7 @@ class Chunk {
|
|
|
15231
15346
|
exports: this.getExportNames(),
|
|
15232
15347
|
facadeModuleId: facadeModule && facadeModule.id,
|
|
15233
15348
|
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
15234
|
-
isEntry: !!
|
|
15349
|
+
isEntry: !!facadeModule?.info.isEntry,
|
|
15235
15350
|
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
15236
15351
|
moduleIds: this.orderedModules.map(({ id }) => id),
|
|
15237
15352
|
name: this.getChunkName(),
|
|
@@ -15330,6 +15445,7 @@ class Chunk {
|
|
|
15330
15445
|
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
15331
15446
|
const importPath = dep.getImportPath(fileName);
|
|
15332
15447
|
renderedDependencies.set(dep, {
|
|
15448
|
+
assertions: dep instanceof ExternalChunk ? dep.getImportAssertions(this.snippets) : null,
|
|
15333
15449
|
defaultVariableName: dep.defaultVariableName,
|
|
15334
15450
|
globalName: dep instanceof ExternalChunk &&
|
|
15335
15451
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
@@ -15413,8 +15529,7 @@ class Chunk {
|
|
|
15413
15529
|
const { renderedExports, removedExports } = module.getRenderedExports();
|
|
15414
15530
|
renderedModules[module.id] = {
|
|
15415
15531
|
get code() {
|
|
15416
|
-
|
|
15417
|
-
return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
|
|
15532
|
+
return source?.toString() ?? null;
|
|
15418
15533
|
},
|
|
15419
15534
|
originalLength: module.originalCode.length,
|
|
15420
15535
|
removedExports,
|
|
@@ -15442,14 +15557,13 @@ class Chunk {
|
|
|
15442
15557
|
node.setInternalResolution(resolution.namespace);
|
|
15443
15558
|
}
|
|
15444
15559
|
else {
|
|
15445
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !
|
|
15560
|
+
node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null);
|
|
15446
15561
|
}
|
|
15447
15562
|
}
|
|
15448
15563
|
else {
|
|
15449
15564
|
const { resolution } = resolvedDynamicImport;
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
: resolution || '', false);
|
|
15565
|
+
const [resolutionString, assertions] = this.getDynamicImportStringAndAssertions(resolution, fileName);
|
|
15566
|
+
resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, assertions);
|
|
15453
15567
|
}
|
|
15454
15568
|
}
|
|
15455
15569
|
}
|
|
@@ -15558,12 +15672,10 @@ class Chunk {
|
|
|
15558
15672
|
}
|
|
15559
15673
|
}
|
|
15560
15674
|
function getChunkNameFromModule(module) {
|
|
15561
|
-
|
|
15562
|
-
return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
|
|
15675
|
+
return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
|
|
15563
15676
|
}
|
|
15564
15677
|
function getPredefinedChunkNameFromModule(module) {
|
|
15565
|
-
|
|
15566
|
-
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);
|
|
15678
|
+
return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
|
|
15567
15679
|
}
|
|
15568
15680
|
function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
|
|
15569
15681
|
const importedBindingsPerDependency = {};
|
|
@@ -17449,7 +17561,7 @@ pp$8.parseForStatement = function(node) {
|
|
|
17449
17561
|
|
|
17450
17562
|
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
17451
17563
|
this.next();
|
|
17452
|
-
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
17564
|
+
return this.parseFunction(node, FUNC_STATEMENT$1 | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
17453
17565
|
};
|
|
17454
17566
|
|
|
17455
17567
|
pp$8.parseIfStatement = function(node) {
|
|
@@ -17713,7 +17825,7 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
17713
17825
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
17714
17826
|
};
|
|
17715
17827
|
|
|
17716
|
-
var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
|
|
17828
|
+
var FUNC_STATEMENT$1 = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID$1 = 4;
|
|
17717
17829
|
|
|
17718
17830
|
// Parse a function declaration or literal (depending on the
|
|
17719
17831
|
// `statement & FUNC_STATEMENT`).
|
|
@@ -17729,8 +17841,8 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17729
17841
|
if (this.options.ecmaVersion >= 8)
|
|
17730
17842
|
{ node.async = !!isAsync; }
|
|
17731
17843
|
|
|
17732
|
-
if (statement & FUNC_STATEMENT) {
|
|
17733
|
-
node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
|
|
17844
|
+
if (statement & FUNC_STATEMENT$1) {
|
|
17845
|
+
node.id = (statement & FUNC_NULLABLE_ID$1) && this.type !== types$1.name ? null : this.parseIdent();
|
|
17734
17846
|
if (node.id && !(statement & FUNC_HANGING_STATEMENT))
|
|
17735
17847
|
// If it is a regular function declaration in sloppy mode, then it is
|
|
17736
17848
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
|
@@ -17745,7 +17857,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17745
17857
|
this.awaitIdentPos = 0;
|
|
17746
17858
|
this.enterScope(functionFlags(node.async, node.generator));
|
|
17747
17859
|
|
|
17748
|
-
if (!(statement & FUNC_STATEMENT))
|
|
17860
|
+
if (!(statement & FUNC_STATEMENT$1))
|
|
17749
17861
|
{ node.id = this.type === types$1.name ? this.parseIdent() : null; }
|
|
17750
17862
|
|
|
17751
17863
|
this.parseFunctionParams(node);
|
|
@@ -17754,7 +17866,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
17754
17866
|
this.yieldPos = oldYieldPos;
|
|
17755
17867
|
this.awaitPos = oldAwaitPos;
|
|
17756
17868
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
17757
|
-
return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17869
|
+
return this.finishNode(node, (statement & FUNC_STATEMENT$1) ? "FunctionDeclaration" : "FunctionExpression")
|
|
17758
17870
|
};
|
|
17759
17871
|
|
|
17760
17872
|
pp$8.parseFunctionParams = function(node) {
|
|
@@ -18060,7 +18172,7 @@ pp$8.parseExport = function(node, exports) {
|
|
|
18060
18172
|
var fNode = this.startNode();
|
|
18061
18173
|
this.next();
|
|
18062
18174
|
if (isAsync) { this.next(); }
|
|
18063
|
-
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
18175
|
+
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync);
|
|
18064
18176
|
} else if (this.type === types$1._class) {
|
|
18065
18177
|
var cNode = this.startNode();
|
|
18066
18178
|
node.declaration = this.parseClass(cNode, "nullableID");
|
|
@@ -21945,7 +22057,59 @@ Parser.acorn = {
|
|
|
21945
22057
|
nonASCIIwhitespace: nonASCIIwhitespace
|
|
21946
22058
|
};
|
|
21947
22059
|
|
|
21948
|
-
|
|
22060
|
+
// The main exported interface (under `self.acorn` when in the
|
|
22061
|
+
// browser) is a `parse` function that takes a code string and
|
|
22062
|
+
// returns an abstract syntax tree as specified by [Mozilla parser
|
|
22063
|
+
// API][api].
|
|
22064
|
+
//
|
|
22065
|
+
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
|
|
22066
|
+
|
|
22067
|
+
function parse(input, options) {
|
|
22068
|
+
return Parser.parse(input, options)
|
|
22069
|
+
}
|
|
22070
|
+
|
|
22071
|
+
// This function tries to parse a single expression at a given
|
|
22072
|
+
// offset in a string. Useful for parsing mixed-language formats
|
|
22073
|
+
// that embed JavaScript expressions.
|
|
22074
|
+
|
|
22075
|
+
function parseExpressionAt(input, pos, options) {
|
|
22076
|
+
return Parser.parseExpressionAt(input, pos, options)
|
|
22077
|
+
}
|
|
22078
|
+
|
|
22079
|
+
// Acorn is organized as a tokenizer and a recursive-descent parser.
|
|
22080
|
+
// The `tokenizer` export provides an interface to the tokenizer.
|
|
22081
|
+
|
|
22082
|
+
function tokenizer(input, options) {
|
|
22083
|
+
return Parser.tokenizer(input, options)
|
|
22084
|
+
}
|
|
22085
|
+
|
|
22086
|
+
const acorn = /*#__PURE__*/Object.defineProperty({
|
|
22087
|
+
__proto__: null,
|
|
22088
|
+
Node,
|
|
22089
|
+
Parser,
|
|
22090
|
+
Position,
|
|
22091
|
+
SourceLocation,
|
|
22092
|
+
TokContext,
|
|
22093
|
+
Token,
|
|
22094
|
+
TokenType,
|
|
22095
|
+
defaultOptions,
|
|
22096
|
+
getLineInfo,
|
|
22097
|
+
isIdentifierChar,
|
|
22098
|
+
isIdentifierStart,
|
|
22099
|
+
isNewLine,
|
|
22100
|
+
keywordTypes: keywords,
|
|
22101
|
+
lineBreak,
|
|
22102
|
+
lineBreakG,
|
|
22103
|
+
nonASCIIwhitespace,
|
|
22104
|
+
parse,
|
|
22105
|
+
parseExpressionAt,
|
|
22106
|
+
tokContexts: types,
|
|
22107
|
+
tokTypes: types$1,
|
|
22108
|
+
tokenizer,
|
|
22109
|
+
version
|
|
22110
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
22111
|
+
|
|
22112
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
|
|
21949
22113
|
let skipped = null;
|
|
21950
22114
|
let replaceContext = null;
|
|
21951
22115
|
if (skip) {
|
|
@@ -21957,16 +22121,16 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
21957
22121
|
}
|
|
21958
22122
|
replaceContext = (pluginContext, plugin) => ({
|
|
21959
22123
|
...pluginContext,
|
|
21960
|
-
resolve: (source, importer, { custom, isEntry, skipSelf } = BLANK) => {
|
|
21961
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22124
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
22125
|
+
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
21962
22126
|
}
|
|
21963
22127
|
});
|
|
21964
22128
|
}
|
|
21965
|
-
return pluginDriver.hookFirst('resolveId', [source, importer, { custom: customOptions, isEntry }], replaceContext, skipped);
|
|
22129
|
+
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
21966
22130
|
}
|
|
21967
22131
|
|
|
21968
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
|
|
21969
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry);
|
|
22132
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
|
|
22133
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions);
|
|
21970
22134
|
if (pluginResult != null)
|
|
21971
22135
|
return pluginResult;
|
|
21972
22136
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
@@ -21980,8 +22144,9 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
21980
22144
|
return addJsExtensionIfNecessary(importer ? node_path.resolve(node_path.dirname(importer), source) : node_path.resolve(source), preserveSymlinks);
|
|
21981
22145
|
}
|
|
21982
22146
|
async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
21983
|
-
|
|
21984
|
-
|
|
22147
|
+
return ((await findFile(file, preserveSymlinks)) ??
|
|
22148
|
+
(await findFile(file + '.mjs', preserveSymlinks)) ??
|
|
22149
|
+
(await findFile(file + '.js', preserveSymlinks)));
|
|
21985
22150
|
}
|
|
21986
22151
|
async function findFile(file, preserveSymlinks) {
|
|
21987
22152
|
try {
|
|
@@ -22215,11 +22380,9 @@ class ModuleLoader {
|
|
|
22215
22380
|
this.modulesWithLoadedDependencies = new Set();
|
|
22216
22381
|
this.nextChunkNamePriority = 0;
|
|
22217
22382
|
this.nextEntryModuleIndex = 0;
|
|
22218
|
-
this.resolveId = async (source, importer, customOptions, isEntry, skip = null) =>
|
|
22219
|
-
|
|
22220
|
-
|
|
22221
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer), importer, source));
|
|
22222
|
-
};
|
|
22383
|
+
this.resolveId = async (source, importer, customOptions, isEntry, assertions, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
22384
|
+
? false
|
|
22385
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, assertions), importer, source), assertions);
|
|
22223
22386
|
this.hasModuleSideEffects = options.treeshake
|
|
22224
22387
|
? options.treeshake.moduleSideEffects
|
|
22225
22388
|
: () => true;
|
|
@@ -22277,7 +22440,7 @@ class ModuleLoader {
|
|
|
22277
22440
|
return module;
|
|
22278
22441
|
}
|
|
22279
22442
|
async preloadModule(resolvedId) {
|
|
22280
|
-
const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
|
|
22443
|
+
const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId, EMPTY_OBJECT), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
|
|
22281
22444
|
return module.info;
|
|
22282
22445
|
}
|
|
22283
22446
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
@@ -22300,7 +22463,7 @@ class ModuleLoader {
|
|
|
22300
22463
|
async addModuleSource(id, importer, module) {
|
|
22301
22464
|
let source;
|
|
22302
22465
|
try {
|
|
22303
|
-
source = await this.graph.fileOperationQueue.run(async () =>
|
|
22466
|
+
source = await this.graph.fileOperationQueue.run(async () => (await this.pluginDriver.hookFirst('load', [id])) ?? (await node_fs.promises.readFile(id, 'utf8')));
|
|
22304
22467
|
}
|
|
22305
22468
|
catch (err) {
|
|
22306
22469
|
let msg = `Could not load ${id}`;
|
|
@@ -22375,16 +22538,21 @@ class ModuleLoader {
|
|
|
22375
22538
|
}
|
|
22376
22539
|
}
|
|
22377
22540
|
}
|
|
22378
|
-
// If this is a preload, then this method always waits for the dependencies of
|
|
22379
|
-
//
|
|
22380
|
-
// Otherwise it
|
|
22381
|
-
|
|
22541
|
+
// If this is a preload, then this method always waits for the dependencies of
|
|
22542
|
+
// the module to be resolved.
|
|
22543
|
+
// Otherwise, if the module does not exist, it waits for the module and all
|
|
22544
|
+
// its dependencies to be loaded.
|
|
22545
|
+
// Otherwise, it returns immediately.
|
|
22546
|
+
async fetchModule({ assertions, id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
|
|
22382
22547
|
const existingModule = this.modulesById.get(id);
|
|
22383
22548
|
if (existingModule instanceof Module) {
|
|
22549
|
+
if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
|
|
22550
|
+
this.options.onwarn(errInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
|
|
22551
|
+
}
|
|
22384
22552
|
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
22385
22553
|
return existingModule;
|
|
22386
22554
|
}
|
|
22387
|
-
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta);
|
|
22555
|
+
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions);
|
|
22388
22556
|
this.modulesById.set(id, module);
|
|
22389
22557
|
this.graph.watchFiles[id] = true;
|
|
22390
22558
|
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
@@ -22421,14 +22589,18 @@ class ModuleLoader {
|
|
|
22421
22589
|
}
|
|
22422
22590
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
22423
22591
|
if (resolvedId.external) {
|
|
22424
|
-
const { external, id, moduleSideEffects, meta } = resolvedId;
|
|
22425
|
-
|
|
22426
|
-
|
|
22592
|
+
const { assertions, external, id, moduleSideEffects, meta } = resolvedId;
|
|
22593
|
+
let externalModule = this.modulesById.get(id);
|
|
22594
|
+
if (!externalModule) {
|
|
22595
|
+
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id), assertions);
|
|
22596
|
+
this.modulesById.set(id, externalModule);
|
|
22427
22597
|
}
|
|
22428
|
-
|
|
22429
|
-
if (!(externalModule instanceof ExternalModule)) {
|
|
22598
|
+
else if (!(externalModule instanceof ExternalModule)) {
|
|
22430
22599
|
return error(errInternalIdCannotBeExternal(source, importer));
|
|
22431
22600
|
}
|
|
22601
|
+
else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
|
|
22602
|
+
this.options.onwarn(errInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
|
|
22603
|
+
}
|
|
22432
22604
|
return Promise.resolve(externalModule);
|
|
22433
22605
|
}
|
|
22434
22606
|
return this.fetchModule(resolvedId, importer, false, false);
|
|
@@ -22486,7 +22658,7 @@ class ModuleLoader {
|
|
|
22486
22658
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
22487
22659
|
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
22488
22660
|
? dynamicImport.argument
|
|
22489
|
-
: dynamicImport.argument.esTreeNode, module.id);
|
|
22661
|
+
: dynamicImport.argument.esTreeNode, module.id, getAssertionsFromImportExpression(dynamicImport.node));
|
|
22490
22662
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
22491
22663
|
dynamicImport.id = resolvedId.id;
|
|
22492
22664
|
}
|
|
@@ -22494,25 +22666,25 @@ class ModuleLoader {
|
|
|
22494
22666
|
});
|
|
22495
22667
|
}
|
|
22496
22668
|
getResolveStaticDependencyPromises(module) {
|
|
22497
|
-
return Array.from(module.
|
|
22669
|
+
return Array.from(module.sourcesWithAssertions, async ([source, assertions]) => [
|
|
22498
22670
|
source,
|
|
22499
22671
|
(module.resolvedIds[source] =
|
|
22500
22672
|
module.resolvedIds[source] ||
|
|
22501
|
-
this.
|
|
22673
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, assertions), source, module.id, assertions))
|
|
22502
22674
|
]);
|
|
22503
22675
|
}
|
|
22504
|
-
getResolvedIdWithDefaults(resolvedId) {
|
|
22505
|
-
var _a, _b;
|
|
22676
|
+
getResolvedIdWithDefaults(resolvedId, assertions) {
|
|
22506
22677
|
if (!resolvedId) {
|
|
22507
22678
|
return null;
|
|
22508
22679
|
}
|
|
22509
22680
|
const external = resolvedId.external || false;
|
|
22510
22681
|
return {
|
|
22682
|
+
assertions: resolvedId.assertions || assertions,
|
|
22511
22683
|
external,
|
|
22512
22684
|
id: resolvedId.id,
|
|
22513
22685
|
meta: resolvedId.meta || {},
|
|
22514
|
-
moduleSideEffects:
|
|
22515
|
-
syntheticNamedExports:
|
|
22686
|
+
moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
|
|
22687
|
+
syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
|
|
22516
22688
|
};
|
|
22517
22689
|
}
|
|
22518
22690
|
async handleExistingModule(module, isEntry, isPreload) {
|
|
@@ -22532,13 +22704,14 @@ class ModuleLoader {
|
|
|
22532
22704
|
}
|
|
22533
22705
|
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22534
22706
|
}
|
|
22535
|
-
|
|
22707
|
+
handleInvalidResolvedId(resolvedId, source, importer, assertions) {
|
|
22536
22708
|
if (resolvedId === null) {
|
|
22537
22709
|
if (isRelative(source)) {
|
|
22538
22710
|
return error(errUnresolvedImport(source, importer));
|
|
22539
22711
|
}
|
|
22540
22712
|
this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
22541
22713
|
return {
|
|
22714
|
+
assertions,
|
|
22542
22715
|
external: true,
|
|
22543
22716
|
id: source,
|
|
22544
22717
|
meta: {},
|
|
@@ -22552,7 +22725,7 @@ class ModuleLoader {
|
|
|
22552
22725
|
return resolvedId;
|
|
22553
22726
|
}
|
|
22554
22727
|
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
|
|
22555
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true);
|
|
22728
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
|
|
22556
22729
|
if (resolveIdResult == null) {
|
|
22557
22730
|
return error(implicitlyLoadedBefore === null
|
|
22558
22731
|
? errUnresolvedEntry(unresolvedId)
|
|
@@ -22566,14 +22739,13 @@ class ModuleLoader {
|
|
|
22566
22739
|
}
|
|
22567
22740
|
return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
|
|
22568
22741
|
? resolveIdResult
|
|
22569
|
-
: { id: resolveIdResult }), undefined, isEntry, false);
|
|
22742
|
+
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
22570
22743
|
}
|
|
22571
|
-
async resolveDynamicImport(module, specifier, importer) {
|
|
22572
|
-
var _a;
|
|
22573
|
-
var _b;
|
|
22744
|
+
async resolveDynamicImport(module, specifier, importer, assertions) {
|
|
22574
22745
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
22575
22746
|
specifier,
|
|
22576
|
-
importer
|
|
22747
|
+
importer,
|
|
22748
|
+
{ assertions }
|
|
22577
22749
|
]);
|
|
22578
22750
|
if (typeof specifier !== 'string') {
|
|
22579
22751
|
if (typeof resolution === 'string') {
|
|
@@ -22582,16 +22754,19 @@ class ModuleLoader {
|
|
|
22582
22754
|
if (!resolution) {
|
|
22583
22755
|
return null;
|
|
22584
22756
|
}
|
|
22585
|
-
return
|
|
22586
|
-
external: false,
|
|
22587
|
-
moduleSideEffects: true,
|
|
22588
|
-
...resolution
|
|
22589
|
-
};
|
|
22757
|
+
return this.getResolvedIdWithDefaults(resolution, assertions);
|
|
22590
22758
|
}
|
|
22591
22759
|
if (resolution == null) {
|
|
22592
|
-
|
|
22760
|
+
const existingResolution = module.resolvedIds[specifier];
|
|
22761
|
+
if (existingResolution) {
|
|
22762
|
+
if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
|
|
22763
|
+
this.options.onwarn(errInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
|
|
22764
|
+
}
|
|
22765
|
+
return existingResolution;
|
|
22766
|
+
}
|
|
22767
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, assertions), specifier, module.id, assertions));
|
|
22593
22768
|
}
|
|
22594
|
-
return this.
|
|
22769
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), assertions), specifier, importer, assertions);
|
|
22595
22770
|
}
|
|
22596
22771
|
}
|
|
22597
22772
|
function normalizeRelativeExternalId(source, importer) {
|
|
@@ -22602,14 +22777,13 @@ function normalizeRelativeExternalId(source, importer) {
|
|
|
22602
22777
|
: source;
|
|
22603
22778
|
}
|
|
22604
22779
|
function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
|
|
22605
|
-
var _a;
|
|
22606
22780
|
if (fileName !== null) {
|
|
22607
22781
|
module.chunkFileNames.add(fileName);
|
|
22608
22782
|
}
|
|
22609
22783
|
else if (name !== null) {
|
|
22610
22784
|
// Always keep chunkNames sorted by priority
|
|
22611
22785
|
let namePosition = 0;
|
|
22612
|
-
while (
|
|
22786
|
+
while (module.chunkNames[namePosition]?.priority < priority)
|
|
22613
22787
|
namePosition++;
|
|
22614
22788
|
module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
|
|
22615
22789
|
}
|
|
@@ -22902,8 +23076,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22902
23076
|
return wrappedModuleIds();
|
|
22903
23077
|
},
|
|
22904
23078
|
parse: graph.contextParse.bind(graph),
|
|
22905
|
-
resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
|
|
22906
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, skipSelf ? [{ importer, plugin, source }] : null);
|
|
23079
|
+
resolve(source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) {
|
|
23080
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22907
23081
|
},
|
|
22908
23082
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22909
23083
|
warn(warning) {
|
|
@@ -23078,7 +23252,7 @@ class PluginDriver {
|
|
|
23078
23252
|
}
|
|
23079
23253
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
23080
23254
|
const hookResult = handler.apply(context, args);
|
|
23081
|
-
if (!
|
|
23255
|
+
if (!hookResult?.then) {
|
|
23082
23256
|
// short circuit for non-thenables and non-Promises
|
|
23083
23257
|
return hookResult;
|
|
23084
23258
|
}
|
|
@@ -23218,7 +23392,6 @@ function normalizeEntryModules(entryModules) {
|
|
|
23218
23392
|
}
|
|
23219
23393
|
class Graph {
|
|
23220
23394
|
constructor(options, watcher) {
|
|
23221
|
-
var _a, _b;
|
|
23222
23395
|
this.options = options;
|
|
23223
23396
|
this.cachedModules = new Map();
|
|
23224
23397
|
this.deoptimizationTracker = new PathTracker();
|
|
@@ -23239,11 +23412,11 @@ class Graph {
|
|
|
23239
23412
|
return foundModule.info;
|
|
23240
23413
|
};
|
|
23241
23414
|
if (options.cache !== false) {
|
|
23242
|
-
if (
|
|
23415
|
+
if (options.cache?.modules) {
|
|
23243
23416
|
for (const module of options.cache.modules)
|
|
23244
23417
|
this.cachedModules.set(module.id, module);
|
|
23245
23418
|
}
|
|
23246
|
-
this.pluginCache =
|
|
23419
|
+
this.pluginCache = options.cache?.plugins || Object.create(null);
|
|
23247
23420
|
// increment access counter
|
|
23248
23421
|
for (const name in this.pluginCache) {
|
|
23249
23422
|
const cache = this.pluginCache[name];
|
|
@@ -23440,12 +23613,300 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
23440
23613
|
return result;
|
|
23441
23614
|
}
|
|
23442
23615
|
|
|
23616
|
+
var lib = {};
|
|
23617
|
+
|
|
23618
|
+
const require$$0 = /*@__PURE__*/getAugmentedNamespace(acorn);
|
|
23619
|
+
|
|
23620
|
+
Object.defineProperty(lib, "__esModule", {
|
|
23621
|
+
value: true
|
|
23622
|
+
});
|
|
23623
|
+
var importAssertions_1 = lib.importAssertions = importAssertions;
|
|
23624
|
+
|
|
23625
|
+
var _acorn = _interopRequireWildcard(require$$0);
|
|
23626
|
+
|
|
23627
|
+
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); }
|
|
23628
|
+
|
|
23629
|
+
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; }
|
|
23630
|
+
|
|
23631
|
+
const leftCurlyBrace = "{".charCodeAt(0);
|
|
23632
|
+
const space = " ".charCodeAt(0);
|
|
23633
|
+
const keyword = "assert";
|
|
23634
|
+
const FUNC_STATEMENT = 1,
|
|
23635
|
+
FUNC_NULLABLE_ID = 4;
|
|
23636
|
+
|
|
23637
|
+
function importAssertions(Parser) {
|
|
23638
|
+
// Use supplied version acorn version if present, to avoid
|
|
23639
|
+
// reference mismatches due to different acorn versions. This
|
|
23640
|
+
// allows this plugin to be used with Rollup which supplies
|
|
23641
|
+
// its own internal version of acorn and thereby sidesteps
|
|
23642
|
+
// the package manager.
|
|
23643
|
+
const acorn = Parser.acorn || _acorn;
|
|
23644
|
+
const {
|
|
23645
|
+
tokTypes: tt,
|
|
23646
|
+
TokenType
|
|
23647
|
+
} = acorn;
|
|
23648
|
+
return class extends Parser {
|
|
23649
|
+
constructor(...args) {
|
|
23650
|
+
super(...args);
|
|
23651
|
+
this.assertToken = new TokenType(keyword);
|
|
23652
|
+
}
|
|
23653
|
+
|
|
23654
|
+
_codeAt(i) {
|
|
23655
|
+
return this.input.charCodeAt(i);
|
|
23656
|
+
}
|
|
23657
|
+
|
|
23658
|
+
_eat(t) {
|
|
23659
|
+
if (this.type !== t) {
|
|
23660
|
+
this.unexpected();
|
|
23661
|
+
}
|
|
23662
|
+
|
|
23663
|
+
this.next();
|
|
23664
|
+
}
|
|
23665
|
+
|
|
23666
|
+
readToken(code) {
|
|
23667
|
+
let i = 0;
|
|
23668
|
+
|
|
23669
|
+
for (; i < keyword.length; i++) {
|
|
23670
|
+
if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
|
|
23671
|
+
return super.readToken(code);
|
|
23672
|
+
}
|
|
23673
|
+
} // ensure that the keyword is at the correct location
|
|
23674
|
+
// ie `assert{...` or `assert {...`
|
|
23675
|
+
|
|
23676
|
+
|
|
23677
|
+
for (;; i++) {
|
|
23678
|
+
if (this._codeAt(this.pos + i) === leftCurlyBrace) {
|
|
23679
|
+
// Found '{'
|
|
23680
|
+
break;
|
|
23681
|
+
} else if (this._codeAt(this.pos + i) === space) {
|
|
23682
|
+
// white space is allowed between `assert` and `{`, so continue.
|
|
23683
|
+
continue;
|
|
23684
|
+
} else {
|
|
23685
|
+
return super.readToken(code);
|
|
23686
|
+
}
|
|
23687
|
+
} // If we're inside a dynamic import expression we'll parse
|
|
23688
|
+
// the `assert` keyword as a standard object property name
|
|
23689
|
+
// ie `import(""./foo.json", { assert: { type: "json" } })`
|
|
23690
|
+
|
|
23691
|
+
|
|
23692
|
+
if (this.type.label === "{") {
|
|
23693
|
+
return super.readToken(code);
|
|
23694
|
+
}
|
|
23695
|
+
|
|
23696
|
+
this.pos += keyword.length;
|
|
23697
|
+
return this.finishToken(this.assertToken);
|
|
23698
|
+
}
|
|
23699
|
+
|
|
23700
|
+
parseDynamicImport(node) {
|
|
23701
|
+
this.next(); // skip `(`
|
|
23702
|
+
// Parse node.source.
|
|
23703
|
+
|
|
23704
|
+
node.source = this.parseMaybeAssign();
|
|
23705
|
+
|
|
23706
|
+
if (this.eat(tt.comma)) {
|
|
23707
|
+
const obj = this.parseObj(false);
|
|
23708
|
+
node.arguments = [obj];
|
|
23709
|
+
}
|
|
23710
|
+
|
|
23711
|
+
this._eat(tt.parenR);
|
|
23712
|
+
|
|
23713
|
+
return this.finishNode(node, "ImportExpression");
|
|
23714
|
+
} // ported from acorn/src/statement.js pp.parseExport
|
|
23715
|
+
|
|
23716
|
+
|
|
23717
|
+
parseExport(node, exports) {
|
|
23718
|
+
this.next(); // export * from '...'
|
|
23719
|
+
|
|
23720
|
+
if (this.eat(tt.star)) {
|
|
23721
|
+
if (this.options.ecmaVersion >= 11) {
|
|
23722
|
+
if (this.eatContextual("as")) {
|
|
23723
|
+
node.exported = this.parseIdent(true);
|
|
23724
|
+
this.checkExport(exports, node.exported.name, this.lastTokStart);
|
|
23725
|
+
} else {
|
|
23726
|
+
node.exported = null;
|
|
23727
|
+
}
|
|
23728
|
+
}
|
|
23729
|
+
|
|
23730
|
+
this.expectContextual("from");
|
|
23731
|
+
|
|
23732
|
+
if (this.type !== tt.string) {
|
|
23733
|
+
this.unexpected();
|
|
23734
|
+
}
|
|
23735
|
+
|
|
23736
|
+
node.source = this.parseExprAtom();
|
|
23737
|
+
|
|
23738
|
+
if (this.type === this.assertToken) {
|
|
23739
|
+
this.next();
|
|
23740
|
+
const assertions = this.parseImportAssertions();
|
|
23741
|
+
|
|
23742
|
+
if (assertions) {
|
|
23743
|
+
node.assertions = assertions;
|
|
23744
|
+
}
|
|
23745
|
+
}
|
|
23746
|
+
|
|
23747
|
+
this.semicolon();
|
|
23748
|
+
return this.finishNode(node, "ExportAllDeclaration");
|
|
23749
|
+
}
|
|
23750
|
+
|
|
23751
|
+
if (this.eat(tt._default)) {
|
|
23752
|
+
// export default ...
|
|
23753
|
+
this.checkExport(exports, "default", this.lastTokStart);
|
|
23754
|
+
var isAsync;
|
|
23755
|
+
|
|
23756
|
+
if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
|
|
23757
|
+
var fNode = this.startNode();
|
|
23758
|
+
this.next();
|
|
23759
|
+
|
|
23760
|
+
if (isAsync) {
|
|
23761
|
+
this.next();
|
|
23762
|
+
}
|
|
23763
|
+
|
|
23764
|
+
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
23765
|
+
} else if (this.type === tt._class) {
|
|
23766
|
+
var cNode = this.startNode();
|
|
23767
|
+
node.declaration = this.parseClass(cNode, "nullableID");
|
|
23768
|
+
} else {
|
|
23769
|
+
node.declaration = this.parseMaybeAssign();
|
|
23770
|
+
this.semicolon();
|
|
23771
|
+
}
|
|
23772
|
+
|
|
23773
|
+
return this.finishNode(node, "ExportDefaultDeclaration");
|
|
23774
|
+
} // export var|const|let|function|class ...
|
|
23775
|
+
|
|
23776
|
+
|
|
23777
|
+
if (this.shouldParseExportStatement()) {
|
|
23778
|
+
node.declaration = this.parseStatement(null);
|
|
23779
|
+
|
|
23780
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
23781
|
+
this.checkVariableExport(exports, node.declaration.declarations);
|
|
23782
|
+
} else {
|
|
23783
|
+
this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
|
|
23784
|
+
}
|
|
23785
|
+
|
|
23786
|
+
node.specifiers = [];
|
|
23787
|
+
node.source = null;
|
|
23788
|
+
} else {
|
|
23789
|
+
// export { x, y as z } [from '...']
|
|
23790
|
+
node.declaration = null;
|
|
23791
|
+
node.specifiers = this.parseExportSpecifiers(exports);
|
|
23792
|
+
|
|
23793
|
+
if (this.eatContextual("from")) {
|
|
23794
|
+
if (this.type !== tt.string) {
|
|
23795
|
+
this.unexpected();
|
|
23796
|
+
}
|
|
23797
|
+
|
|
23798
|
+
node.source = this.parseExprAtom();
|
|
23799
|
+
|
|
23800
|
+
if (this.type === this.assertToken) {
|
|
23801
|
+
this.next();
|
|
23802
|
+
const assertions = this.parseImportAssertions();
|
|
23803
|
+
|
|
23804
|
+
if (assertions) {
|
|
23805
|
+
node.assertions = assertions;
|
|
23806
|
+
}
|
|
23807
|
+
}
|
|
23808
|
+
} else {
|
|
23809
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
23810
|
+
// check for keywords used as local names
|
|
23811
|
+
var spec = list[i];
|
|
23812
|
+
this.checkUnreserved(spec.local); // check if export is defined
|
|
23813
|
+
|
|
23814
|
+
this.checkLocalExport(spec.local);
|
|
23815
|
+
}
|
|
23816
|
+
|
|
23817
|
+
node.source = null;
|
|
23818
|
+
}
|
|
23819
|
+
|
|
23820
|
+
this.semicolon();
|
|
23821
|
+
}
|
|
23822
|
+
|
|
23823
|
+
return this.finishNode(node, "ExportNamedDeclaration");
|
|
23824
|
+
}
|
|
23825
|
+
|
|
23826
|
+
parseImport(node) {
|
|
23827
|
+
this.next(); // import '...'
|
|
23828
|
+
|
|
23829
|
+
if (this.type === tt.string) {
|
|
23830
|
+
node.specifiers = [];
|
|
23831
|
+
node.source = this.parseExprAtom();
|
|
23832
|
+
} else {
|
|
23833
|
+
node.specifiers = this.parseImportSpecifiers();
|
|
23834
|
+
this.expectContextual("from");
|
|
23835
|
+
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
|
23836
|
+
}
|
|
23837
|
+
|
|
23838
|
+
if (this.type === this.assertToken) {
|
|
23839
|
+
this.next();
|
|
23840
|
+
const assertions = this.parseImportAssertions();
|
|
23841
|
+
|
|
23842
|
+
if (assertions) {
|
|
23843
|
+
node.assertions = assertions;
|
|
23844
|
+
}
|
|
23845
|
+
}
|
|
23846
|
+
|
|
23847
|
+
this.semicolon();
|
|
23848
|
+
return this.finishNode(node, "ImportDeclaration");
|
|
23849
|
+
}
|
|
23850
|
+
|
|
23851
|
+
parseImportAssertions() {
|
|
23852
|
+
this._eat(tt.braceL);
|
|
23853
|
+
|
|
23854
|
+
const attrs = this.parseAssertEntries();
|
|
23855
|
+
|
|
23856
|
+
this._eat(tt.braceR);
|
|
23857
|
+
|
|
23858
|
+
return attrs;
|
|
23859
|
+
}
|
|
23860
|
+
|
|
23861
|
+
parseAssertEntries() {
|
|
23862
|
+
const attrs = [];
|
|
23863
|
+
const attrNames = new Set();
|
|
23864
|
+
|
|
23865
|
+
do {
|
|
23866
|
+
if (this.type === tt.braceR) {
|
|
23867
|
+
break;
|
|
23868
|
+
}
|
|
23869
|
+
|
|
23870
|
+
const node = this.startNode(); // parse AssertionKey : IdentifierName, StringLiteral
|
|
23871
|
+
|
|
23872
|
+
let assertionKeyNode;
|
|
23873
|
+
|
|
23874
|
+
if (this.type === tt.string) {
|
|
23875
|
+
assertionKeyNode = this.parseLiteral(this.value);
|
|
23876
|
+
} else {
|
|
23877
|
+
assertionKeyNode = this.parseIdent(true);
|
|
23878
|
+
}
|
|
23879
|
+
|
|
23880
|
+
this.next();
|
|
23881
|
+
node.key = assertionKeyNode; // check if we already have an entry for an attribute
|
|
23882
|
+
// if a duplicate entry is found, throw an error
|
|
23883
|
+
// for now this logic will come into play only when someone declares `type` twice
|
|
23884
|
+
|
|
23885
|
+
if (attrNames.has(node.key.name)) {
|
|
23886
|
+
this.raise(this.pos, "Duplicated key in assertions");
|
|
23887
|
+
}
|
|
23888
|
+
|
|
23889
|
+
attrNames.add(node.key.name);
|
|
23890
|
+
|
|
23891
|
+
if (this.type !== tt.string) {
|
|
23892
|
+
this.raise(this.pos, "Only string is supported as an assertion value");
|
|
23893
|
+
}
|
|
23894
|
+
|
|
23895
|
+
node.value = this.parseLiteral(this.value);
|
|
23896
|
+
attrs.push(this.finishNode(node, "ImportAttribute"));
|
|
23897
|
+
} while (this.eat(tt.comma));
|
|
23898
|
+
|
|
23899
|
+
return attrs;
|
|
23900
|
+
}
|
|
23901
|
+
|
|
23902
|
+
};
|
|
23903
|
+
}
|
|
23904
|
+
|
|
23443
23905
|
function normalizeInputOptions(config) {
|
|
23444
|
-
var _a, _b, _c, _d;
|
|
23445
23906
|
// These are options that may trigger special warnings or behaviour later
|
|
23446
23907
|
// if the user did not select an explicit value
|
|
23447
23908
|
const unsetOptions = new Set();
|
|
23448
|
-
const context =
|
|
23909
|
+
const context = config.context ?? 'undefined';
|
|
23449
23910
|
const onwarn = getOnwarn(config);
|
|
23450
23911
|
const strictDeprecations = config.strictDeprecations || false;
|
|
23451
23912
|
const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
|
|
@@ -23454,11 +23915,11 @@ function normalizeInputOptions(config) {
|
|
|
23454
23915
|
acornInjectPlugins: getAcornInjectPlugins(config),
|
|
23455
23916
|
cache: getCache(config),
|
|
23456
23917
|
context,
|
|
23457
|
-
experimentalCacheExpiry:
|
|
23918
|
+
experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
|
|
23458
23919
|
external: getIdMatcher(config.external),
|
|
23459
23920
|
inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
|
|
23460
23921
|
input: getInput(config),
|
|
23461
|
-
makeAbsoluteExternalsRelative:
|
|
23922
|
+
makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
|
|
23462
23923
|
manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
|
|
23463
23924
|
maxParallelFileOps,
|
|
23464
23925
|
maxParallelFileReads: maxParallelFileOps,
|
|
@@ -23466,7 +23927,7 @@ function normalizeInputOptions(config) {
|
|
|
23466
23927
|
onwarn,
|
|
23467
23928
|
perf: config.perf || false,
|
|
23468
23929
|
plugins: ensureArray$1(config.plugins),
|
|
23469
|
-
preserveEntrySignatures:
|
|
23930
|
+
preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
|
|
23470
23931
|
preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
|
|
23471
23932
|
preserveSymlinks: config.preserveSymlinks || false,
|
|
23472
23933
|
shimMissingExports: config.shimMissingExports || false,
|
|
@@ -23500,8 +23961,11 @@ const getAcorn = (config) => ({
|
|
|
23500
23961
|
sourceType: 'module',
|
|
23501
23962
|
...config.acorn
|
|
23502
23963
|
});
|
|
23503
|
-
const getAcornInjectPlugins = (config) =>
|
|
23504
|
-
|
|
23964
|
+
const getAcornInjectPlugins = (config) => [
|
|
23965
|
+
importAssertions_1,
|
|
23966
|
+
...ensureArray$1(config.acornInjectPlugins)
|
|
23967
|
+
];
|
|
23968
|
+
const getCache = (config) => config.cache?.cache || config.cache;
|
|
23505
23969
|
const getIdMatcher = (option) => {
|
|
23506
23970
|
if (option === true) {
|
|
23507
23971
|
return () => true;
|
|
@@ -23543,12 +24007,11 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
|
|
|
23543
24007
|
return configManualChunks;
|
|
23544
24008
|
};
|
|
23545
24009
|
const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
23546
|
-
var _a;
|
|
23547
24010
|
const maxParallelFileReads = config.maxParallelFileReads;
|
|
23548
24011
|
if (typeof maxParallelFileReads === 'number') {
|
|
23549
24012
|
warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
|
|
23550
24013
|
}
|
|
23551
|
-
const maxParallelFileOps =
|
|
24014
|
+
const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
|
|
23552
24015
|
if (typeof maxParallelFileOps === 'number') {
|
|
23553
24016
|
if (maxParallelFileOps <= 0)
|
|
23554
24017
|
return Infinity;
|
|
@@ -23559,7 +24022,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
|
|
|
23559
24022
|
const getModuleContext = (config, context) => {
|
|
23560
24023
|
const configModuleContext = config.moduleContext;
|
|
23561
24024
|
if (typeof configModuleContext === 'function') {
|
|
23562
|
-
return id =>
|
|
24025
|
+
return id => configModuleContext(id) ?? context;
|
|
23563
24026
|
}
|
|
23564
24027
|
if (configModuleContext) {
|
|
23565
24028
|
const contextByModuleId = Object.create(null);
|
|
@@ -23637,7 +24100,6 @@ function isValidUrl(url) {
|
|
|
23637
24100
|
}
|
|
23638
24101
|
|
|
23639
24102
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
23640
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
23641
24103
|
// These are options that may trigger special warnings or behaviour later
|
|
23642
24104
|
// if the user did not select an explicit value
|
|
23643
24105
|
const unsetOptions = new Set(unsetInputOptions);
|
|
@@ -23650,24 +24112,26 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23650
24112
|
const generatedCode = getGeneratedCode(config, preferConst);
|
|
23651
24113
|
const outputOptions = {
|
|
23652
24114
|
amd: getAmd(config),
|
|
23653
|
-
assetFileNames:
|
|
24115
|
+
assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
|
|
23654
24116
|
banner: getAddon(config, 'banner'),
|
|
23655
|
-
chunkFileNames:
|
|
24117
|
+
chunkFileNames: config.chunkFileNames ?? '[name]-[hash].js',
|
|
23656
24118
|
compact,
|
|
23657
24119
|
dir: getDir(config, file),
|
|
23658
24120
|
dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
|
|
24121
|
+
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
23659
24122
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
23660
|
-
esModule:
|
|
24123
|
+
esModule: config.esModule ?? 'if-default-prop',
|
|
23661
24124
|
exports: getExports(config, unsetOptions),
|
|
23662
24125
|
extend: config.extend || false,
|
|
23663
|
-
|
|
24126
|
+
externalImportAssertions: config.externalImportAssertions ?? true,
|
|
24127
|
+
externalLiveBindings: config.externalLiveBindings ?? true,
|
|
23664
24128
|
file,
|
|
23665
24129
|
footer: getAddon(config, 'footer'),
|
|
23666
24130
|
format,
|
|
23667
|
-
freeze:
|
|
24131
|
+
freeze: config.freeze ?? true,
|
|
23668
24132
|
generatedCode,
|
|
23669
24133
|
globals: config.globals || {},
|
|
23670
|
-
hoistTransitiveImports:
|
|
24134
|
+
hoistTransitiveImports: config.hoistTransitiveImports ?? true,
|
|
23671
24135
|
indent: getIndent(config, compact),
|
|
23672
24136
|
inlineDynamicImports,
|
|
23673
24137
|
interop: getInterop(config),
|
|
@@ -23693,8 +24157,8 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23693
24157
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
23694
24158
|
sourcemapFile: config.sourcemapFile,
|
|
23695
24159
|
sourcemapPathTransform: config.sourcemapPathTransform,
|
|
23696
|
-
strict:
|
|
23697
|
-
systemNullSetters: config.systemNullSetters
|
|
24160
|
+
strict: config.strict ?? true,
|
|
24161
|
+
systemNullSetters: config.systemNullSetters ?? true,
|
|
23698
24162
|
validate: config.validate || false
|
|
23699
24163
|
};
|
|
23700
24164
|
warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
|
|
@@ -23737,8 +24201,7 @@ const getFormat = (config) => {
|
|
|
23737
24201
|
}
|
|
23738
24202
|
};
|
|
23739
24203
|
const getInlineDynamicImports = (config, inputOptions) => {
|
|
23740
|
-
|
|
23741
|
-
const inlineDynamicImports = ((_a = config.inlineDynamicImports) !== null && _a !== void 0 ? _a : inputOptions.inlineDynamicImports) || false;
|
|
24204
|
+
const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
|
|
23742
24205
|
const { input } = inputOptions;
|
|
23743
24206
|
if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
|
|
23744
24207
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
|
|
@@ -23746,8 +24209,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
|
|
|
23746
24209
|
return inlineDynamicImports;
|
|
23747
24210
|
};
|
|
23748
24211
|
const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
|
|
23749
|
-
|
|
23750
|
-
const preserveModules = ((_a = config.preserveModules) !== null && _a !== void 0 ? _a : inputOptions.preserveModules) || false;
|
|
24212
|
+
const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
|
|
23751
24213
|
if (preserveModules) {
|
|
23752
24214
|
if (inlineDynamicImports) {
|
|
23753
24215
|
return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', `this option is not supported for "output.preserveModules"`));
|
|
@@ -23834,7 +24296,7 @@ const getEntryFileNames = (config, unsetOptions) => {
|
|
|
23834
24296
|
if (configEntryFileNames == null) {
|
|
23835
24297
|
unsetOptions.add('entryFileNames');
|
|
23836
24298
|
}
|
|
23837
|
-
return configEntryFileNames
|
|
24299
|
+
return configEntryFileNames ?? '[name].js';
|
|
23838
24300
|
};
|
|
23839
24301
|
function getExports(config, unsetOptions) {
|
|
23840
24302
|
const configExports = config.exports;
|
|
@@ -23861,7 +24323,7 @@ const getIndent = (config, compact) => {
|
|
|
23861
24323
|
return '';
|
|
23862
24324
|
}
|
|
23863
24325
|
const configIndent = config.indent;
|
|
23864
|
-
return configIndent === false ? '' : configIndent
|
|
24326
|
+
return configIndent === false ? '' : configIndent ?? true;
|
|
23865
24327
|
};
|
|
23866
24328
|
const ALLOWED_INTEROP_TYPES = new Set([
|
|
23867
24329
|
'compat',
|
|
@@ -23901,7 +24363,7 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
|
|
|
23901
24363
|
}
|
|
23902
24364
|
return configManualChunks || {};
|
|
23903
24365
|
};
|
|
23904
|
-
const getMinifyInternalExports = (config, format, compact) =>
|
|
24366
|
+
const getMinifyInternalExports = (config, format, compact) => config.minifyInternalExports ?? (compact || format === 'es' || format === 'system');
|
|
23905
24367
|
const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
23906
24368
|
const configNamespaceToStringTag = config.namespaceToStringTag;
|
|
23907
24369
|
if (configNamespaceToStringTag != null) {
|