@rollup/wasm-node 4.67.4 → 4.68.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/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +299 -247
- package/dist/es/shared/parseAst.js +11 -3
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/node-entry.js +2 -2
- package/dist/shared/parseAst.js +11 -2
- package/dist/shared/rollup.js +286 -234
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm.js +37 -55
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +15 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.68.0
|
|
4
|
+
Fri, 06 Nov 2026 16:52:39 GMT - commit b93d9a40e1eed7a78069a58ca191260f5c094727
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, isAbsolute as isAbsolute$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logErrorInHook, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
10
|
+
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, isAbsolute as isAbsolute$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, getDynamicAliasName, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logErrorInHook, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1, join } from 'node:path';
|
|
12
12
|
import { isAbsolute, posix, win32, resolve } from 'path';
|
|
13
13
|
import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.
|
|
30
|
+
var version = "4.68.0";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -2086,6 +2086,109 @@ var Bundle$1 = class Bundle {
|
|
|
2086
2086
|
}
|
|
2087
2087
|
};
|
|
2088
2088
|
|
|
2089
|
+
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
|
2090
|
+
const base = 64;
|
|
2091
|
+
function toBase64(value) {
|
|
2092
|
+
let outString = '';
|
|
2093
|
+
do {
|
|
2094
|
+
const currentDigit = value % base;
|
|
2095
|
+
value = (value / base) | 0;
|
|
2096
|
+
outString = chars[currentDigit] + outString;
|
|
2097
|
+
} while (value !== 0);
|
|
2098
|
+
return outString;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
const RESERVED_NAMES = new Set([
|
|
2102
|
+
'await',
|
|
2103
|
+
'break',
|
|
2104
|
+
'case',
|
|
2105
|
+
'catch',
|
|
2106
|
+
'class',
|
|
2107
|
+
'const',
|
|
2108
|
+
'continue',
|
|
2109
|
+
'debugger',
|
|
2110
|
+
'default',
|
|
2111
|
+
'delete',
|
|
2112
|
+
'do',
|
|
2113
|
+
'else',
|
|
2114
|
+
'enum',
|
|
2115
|
+
'eval',
|
|
2116
|
+
'export',
|
|
2117
|
+
'extends',
|
|
2118
|
+
'false',
|
|
2119
|
+
'finally',
|
|
2120
|
+
'for',
|
|
2121
|
+
'function',
|
|
2122
|
+
'if',
|
|
2123
|
+
'implements',
|
|
2124
|
+
'import',
|
|
2125
|
+
'in',
|
|
2126
|
+
'instanceof',
|
|
2127
|
+
'interface',
|
|
2128
|
+
'let',
|
|
2129
|
+
'NaN',
|
|
2130
|
+
'new',
|
|
2131
|
+
'null',
|
|
2132
|
+
'package',
|
|
2133
|
+
'private',
|
|
2134
|
+
'protected',
|
|
2135
|
+
'public',
|
|
2136
|
+
'return',
|
|
2137
|
+
'static',
|
|
2138
|
+
'super',
|
|
2139
|
+
'switch',
|
|
2140
|
+
'this',
|
|
2141
|
+
'throw',
|
|
2142
|
+
'true',
|
|
2143
|
+
'try',
|
|
2144
|
+
'typeof',
|
|
2145
|
+
'undefined',
|
|
2146
|
+
'var',
|
|
2147
|
+
'void',
|
|
2148
|
+
'while',
|
|
2149
|
+
'with',
|
|
2150
|
+
'yield'
|
|
2151
|
+
]);
|
|
2152
|
+
|
|
2153
|
+
function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
|
|
2154
|
+
let nameIndex = 0;
|
|
2155
|
+
for (const variable of exports) {
|
|
2156
|
+
let [exportName] = variable.name;
|
|
2157
|
+
if (exportsByName.has(exportName)) {
|
|
2158
|
+
do {
|
|
2159
|
+
exportName = toBase64(++nameIndex);
|
|
2160
|
+
// skip past leading number identifiers
|
|
2161
|
+
if (exportName.charCodeAt(0) === 49 /* '1' */) {
|
|
2162
|
+
nameIndex += 9 * 64 ** (exportName.length - 1);
|
|
2163
|
+
exportName = toBase64(nameIndex);
|
|
2164
|
+
}
|
|
2165
|
+
} while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
|
|
2166
|
+
}
|
|
2167
|
+
exportsByName.set(exportName, variable);
|
|
2168
|
+
exportNamesByVariable.set(variable, [exportName]);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
|
|
2172
|
+
for (const variable of exports) {
|
|
2173
|
+
let nameIndex = 0;
|
|
2174
|
+
let exportName = variable.name;
|
|
2175
|
+
while (exportsByName.has(exportName)) {
|
|
2176
|
+
exportName = variable.name + '$' + ++nameIndex;
|
|
2177
|
+
}
|
|
2178
|
+
exportsByName.set(exportName, variable);
|
|
2179
|
+
exportNamesByVariable.set(variable, [exportName]);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
// Names starting with "*" are used internally, e.g. "*" for namespaces and "*"
|
|
2183
|
+
// followed by an id for namespaces reexported from external modules. To avoid
|
|
2184
|
+
// conflicts, actual export names starting with "*" get an additional "*", and
|
|
2185
|
+
// external ids starting with "*" or "\0" are prefixed with "\0".
|
|
2186
|
+
const escapeExportName = (name) => (name[0] === '*' ? `*${name}` : name);
|
|
2187
|
+
const unescapeExportName = (name) => name.startsWith('**') ? name.slice(1) : name;
|
|
2188
|
+
const isNamespaceExportName = (name) => name[0] === '*' && name[1] !== '*';
|
|
2189
|
+
const getExternalNamespaceExportName = (id) => id[0] === '*' || id[0] === '\0' ? `*\0${id}` : `*${id}`;
|
|
2190
|
+
const getExternalNamespaceId = (exportName) => exportName.slice(exportName[1] === '\0' ? 2 : 1);
|
|
2191
|
+
|
|
2089
2192
|
function treeshakeNode(node, code, start, end) {
|
|
2090
2193
|
code.remove(start, end);
|
|
2091
2194
|
node.removeAnnotations(code);
|
|
@@ -2252,13 +2355,16 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
|
|
|
2252
2355
|
if (exportedVariables.length === 1 &&
|
|
2253
2356
|
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
2254
2357
|
const variable = exportedVariables[0];
|
|
2255
|
-
return `exports(${JSON.stringify(exportNamesByVariable.get(variable)[0])},${_}${variable.getName(getPropertyAccess)}${modifier})`;
|
|
2358
|
+
return `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(variable)[0]))},${_}${variable.getName(getPropertyAccess)}${modifier})`;
|
|
2256
2359
|
}
|
|
2257
2360
|
else {
|
|
2258
2361
|
const fields = [];
|
|
2259
2362
|
for (const variable of exportedVariables) {
|
|
2260
2363
|
for (const exportName of exportNamesByVariable.get(variable)) {
|
|
2261
|
-
fields.push([
|
|
2364
|
+
fields.push([
|
|
2365
|
+
unescapeExportName(exportName),
|
|
2366
|
+
variable.getName(getPropertyAccess) + modifier
|
|
2367
|
+
]);
|
|
2262
2368
|
}
|
|
2263
2369
|
}
|
|
2264
2370
|
return `exports(${getObject(fields, { lineBreakIndent: null })})`;
|
|
@@ -2266,7 +2372,7 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
|
|
|
2266
2372
|
}
|
|
2267
2373
|
// This is only invoked if there is exactly one export name
|
|
2268
2374
|
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
|
|
2269
|
-
code.prependRight(expressionStart, `exports(${JSON.stringify(exportNamesByVariable.get(exportedVariable)[0])},${_}`);
|
|
2375
|
+
code.prependRight(expressionStart, `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(exportedVariable)[0]))},${_}`);
|
|
2270
2376
|
code.appendLeft(expressionEnd, ')');
|
|
2271
2377
|
}
|
|
2272
2378
|
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
@@ -2843,58 +2949,6 @@ function cacheObjectGetters(object, getterProperties) {
|
|
|
2843
2949
|
}
|
|
2844
2950
|
}
|
|
2845
2951
|
|
|
2846
|
-
const RESERVED_NAMES = new Set([
|
|
2847
|
-
'await',
|
|
2848
|
-
'break',
|
|
2849
|
-
'case',
|
|
2850
|
-
'catch',
|
|
2851
|
-
'class',
|
|
2852
|
-
'const',
|
|
2853
|
-
'continue',
|
|
2854
|
-
'debugger',
|
|
2855
|
-
'default',
|
|
2856
|
-
'delete',
|
|
2857
|
-
'do',
|
|
2858
|
-
'else',
|
|
2859
|
-
'enum',
|
|
2860
|
-
'eval',
|
|
2861
|
-
'export',
|
|
2862
|
-
'extends',
|
|
2863
|
-
'false',
|
|
2864
|
-
'finally',
|
|
2865
|
-
'for',
|
|
2866
|
-
'function',
|
|
2867
|
-
'if',
|
|
2868
|
-
'implements',
|
|
2869
|
-
'import',
|
|
2870
|
-
'in',
|
|
2871
|
-
'instanceof',
|
|
2872
|
-
'interface',
|
|
2873
|
-
'let',
|
|
2874
|
-
'NaN',
|
|
2875
|
-
'new',
|
|
2876
|
-
'null',
|
|
2877
|
-
'package',
|
|
2878
|
-
'private',
|
|
2879
|
-
'protected',
|
|
2880
|
-
'public',
|
|
2881
|
-
'return',
|
|
2882
|
-
'static',
|
|
2883
|
-
'super',
|
|
2884
|
-
'switch',
|
|
2885
|
-
'this',
|
|
2886
|
-
'throw',
|
|
2887
|
-
'true',
|
|
2888
|
-
'try',
|
|
2889
|
-
'typeof',
|
|
2890
|
-
'undefined',
|
|
2891
|
-
'var',
|
|
2892
|
-
'void',
|
|
2893
|
-
'while',
|
|
2894
|
-
'with',
|
|
2895
|
-
'yield'
|
|
2896
|
-
]);
|
|
2897
|
-
|
|
2898
2952
|
const illegalCharacters = /[^\w$]/g;
|
|
2899
2953
|
const illegalCharacter = /[^\w$]/;
|
|
2900
2954
|
const startsWithDigit = (value) => /\d/.test(value[0]);
|
|
@@ -3016,7 +3070,7 @@ class ExternalModule {
|
|
|
3016
3070
|
}
|
|
3017
3071
|
}
|
|
3018
3072
|
const importersArray = [...importersSet];
|
|
3019
|
-
this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused, importersArray));
|
|
3073
|
+
this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused.map(unescapeExportName), importersArray));
|
|
3020
3074
|
}
|
|
3021
3075
|
}
|
|
3022
3076
|
|
|
@@ -5974,18 +6028,6 @@ class Identifier extends IdentifierBase {
|
|
|
5974
6028
|
}
|
|
5975
6029
|
}
|
|
5976
6030
|
|
|
5977
|
-
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
|
5978
|
-
const base = 64;
|
|
5979
|
-
function toBase64(value) {
|
|
5980
|
-
let outString = '';
|
|
5981
|
-
do {
|
|
5982
|
-
const currentDigit = value % base;
|
|
5983
|
-
value = (value / base) | 0;
|
|
5984
|
-
outString = chars[currentDigit] + outString;
|
|
5985
|
-
} while (value !== 0);
|
|
5986
|
-
return outString;
|
|
5987
|
-
}
|
|
5988
|
-
|
|
5989
6031
|
function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
5990
6032
|
let safeName = baseName;
|
|
5991
6033
|
let count = 1;
|
|
@@ -7633,7 +7675,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
7633
7675
|
const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/
|
|
7634
7676
|
const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable);
|
|
7635
7677
|
if (systemExportNames) {
|
|
7636
|
-
code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(systemExportNames[0])}, `);
|
|
7678
|
+
code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(unescapeExportName(systemExportNames[0]))}, `);
|
|
7637
7679
|
code.appendRight(hasTrailingSemicolon ? this.end - 1 : this.end, ')' + (hasTrailingSemicolon ? '' : ';'));
|
|
7638
7680
|
return false;
|
|
7639
7681
|
}
|
|
@@ -7868,6 +7910,111 @@ function getToStringTagValue(getObject) {
|
|
|
7868
7910
|
});
|
|
7869
7911
|
}
|
|
7870
7912
|
|
|
7913
|
+
class UndefinedVariable extends Variable {
|
|
7914
|
+
constructor() {
|
|
7915
|
+
super('undefined');
|
|
7916
|
+
}
|
|
7917
|
+
getLiteralValueAtPath() {
|
|
7918
|
+
return undefined;
|
|
7919
|
+
}
|
|
7920
|
+
}
|
|
7921
|
+
|
|
7922
|
+
class ExportDefaultVariable extends LocalVariable {
|
|
7923
|
+
constructor(exportDefaultDeclaration, context) {
|
|
7924
|
+
super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
|
|
7925
|
+
this.hasId = false;
|
|
7926
|
+
this.originalId = null;
|
|
7927
|
+
this.originalVariable = null;
|
|
7928
|
+
const declaration = exportDefaultDeclaration.declaration;
|
|
7929
|
+
if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
|
|
7930
|
+
declaration.id) {
|
|
7931
|
+
this.hasId = true;
|
|
7932
|
+
this.originalId = declaration.id;
|
|
7933
|
+
}
|
|
7934
|
+
else if (declaration instanceof Identifier) {
|
|
7935
|
+
this.originalId = declaration;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
addReference(identifier) {
|
|
7939
|
+
if (!this.hasId) {
|
|
7940
|
+
this.name = identifier.name;
|
|
7941
|
+
}
|
|
7942
|
+
}
|
|
7943
|
+
addUsedPlace(usedPlace) {
|
|
7944
|
+
const original = this.getOriginalVariable();
|
|
7945
|
+
if (original === this) {
|
|
7946
|
+
super.addUsedPlace(usedPlace);
|
|
7947
|
+
}
|
|
7948
|
+
else {
|
|
7949
|
+
original.addUsedPlace(usedPlace);
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
forbidName(name) {
|
|
7953
|
+
const original = this.getOriginalVariable();
|
|
7954
|
+
if (original === this) {
|
|
7955
|
+
super.forbidName(name);
|
|
7956
|
+
}
|
|
7957
|
+
else {
|
|
7958
|
+
original.forbidName(name);
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
getAssignedVariableName() {
|
|
7962
|
+
return (this.originalId && this.originalId.name) || null;
|
|
7963
|
+
}
|
|
7964
|
+
getBaseVariableName() {
|
|
7965
|
+
const original = this.getOriginalVariable();
|
|
7966
|
+
return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
|
|
7967
|
+
}
|
|
7968
|
+
getDirectOriginalVariable() {
|
|
7969
|
+
return this.originalId &&
|
|
7970
|
+
(this.hasId ||
|
|
7971
|
+
!(this.originalId.isPossibleTDZ() ||
|
|
7972
|
+
this.originalId.variable.isReassigned ||
|
|
7973
|
+
this.originalId.variable instanceof UndefinedVariable ||
|
|
7974
|
+
// this avoids a circular dependency
|
|
7975
|
+
'syntheticNamespace' in this.originalId.variable))
|
|
7976
|
+
? this.originalId.variable
|
|
7977
|
+
: null;
|
|
7978
|
+
}
|
|
7979
|
+
/**
|
|
7980
|
+
* Returns the namespace if this default export is just a re-export of a
|
|
7981
|
+
* namespace import. Namespace variables can neither be reassigned nor be
|
|
7982
|
+
* accessed in their TDZ, so this is safe to call while binding.
|
|
7983
|
+
*/
|
|
7984
|
+
getOriginalNamespaceVariable() {
|
|
7985
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
7986
|
+
let current = this;
|
|
7987
|
+
const checkedVariables = new Set();
|
|
7988
|
+
while (current instanceof ExportDefaultVariable && !checkedVariables.has(current)) {
|
|
7989
|
+
checkedVariables.add(current);
|
|
7990
|
+
if (current.hasId || !current.originalId)
|
|
7991
|
+
return null;
|
|
7992
|
+
current = current.originalId.variable;
|
|
7993
|
+
}
|
|
7994
|
+
return current?.isNamespace ? current : null;
|
|
7995
|
+
}
|
|
7996
|
+
getName(getPropertyAccess) {
|
|
7997
|
+
const original = this.getOriginalVariable();
|
|
7998
|
+
return original === this
|
|
7999
|
+
? super.getName(getPropertyAccess)
|
|
8000
|
+
: original.getName(getPropertyAccess);
|
|
8001
|
+
}
|
|
8002
|
+
getOriginalVariable() {
|
|
8003
|
+
if (this.originalVariable)
|
|
8004
|
+
return this.originalVariable;
|
|
8005
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8006
|
+
let original = this;
|
|
8007
|
+
let currentVariable;
|
|
8008
|
+
const checkedVariables = new Set();
|
|
8009
|
+
do {
|
|
8010
|
+
checkedVariables.add(original);
|
|
8011
|
+
currentVariable = original;
|
|
8012
|
+
original = currentVariable.getDirectOriginalVariable();
|
|
8013
|
+
} while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
|
|
8014
|
+
return (this.originalVariable = original || currentVariable);
|
|
8015
|
+
}
|
|
8016
|
+
}
|
|
8017
|
+
|
|
7871
8018
|
class Literal extends NodeBase {
|
|
7872
8019
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
7873
8020
|
getLiteralValueAtPath(path) {
|
|
@@ -8011,7 +8158,10 @@ class MemberExpression extends NodeBase {
|
|
|
8011
8158
|
bind() {
|
|
8012
8159
|
this.bound = true;
|
|
8013
8160
|
const path = getPathIfNotComputed(this);
|
|
8014
|
-
|
|
8161
|
+
let baseVariable = path && this.scope.findVariable(path[0].key);
|
|
8162
|
+
if (baseVariable instanceof ExportDefaultVariable) {
|
|
8163
|
+
baseVariable = baseVariable.getOriginalNamespaceVariable() || baseVariable;
|
|
8164
|
+
}
|
|
8015
8165
|
if (baseVariable?.isNamespace) {
|
|
8016
8166
|
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.scope.context);
|
|
8017
8167
|
if (!resolvedVariable) {
|
|
@@ -8517,94 +8667,6 @@ const importMetaMechanisms = {
|
|
|
8517
8667
|
umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})`)
|
|
8518
8668
|
};
|
|
8519
8669
|
|
|
8520
|
-
class UndefinedVariable extends Variable {
|
|
8521
|
-
constructor() {
|
|
8522
|
-
super('undefined');
|
|
8523
|
-
}
|
|
8524
|
-
getLiteralValueAtPath() {
|
|
8525
|
-
return undefined;
|
|
8526
|
-
}
|
|
8527
|
-
}
|
|
8528
|
-
|
|
8529
|
-
class ExportDefaultVariable extends LocalVariable {
|
|
8530
|
-
constructor(exportDefaultDeclaration, context) {
|
|
8531
|
-
super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
|
|
8532
|
-
this.hasId = false;
|
|
8533
|
-
this.originalId = null;
|
|
8534
|
-
this.originalVariable = null;
|
|
8535
|
-
const declaration = exportDefaultDeclaration.declaration;
|
|
8536
|
-
if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
|
|
8537
|
-
declaration.id) {
|
|
8538
|
-
this.hasId = true;
|
|
8539
|
-
this.originalId = declaration.id;
|
|
8540
|
-
}
|
|
8541
|
-
else if (declaration instanceof Identifier) {
|
|
8542
|
-
this.originalId = declaration;
|
|
8543
|
-
}
|
|
8544
|
-
}
|
|
8545
|
-
addReference(identifier) {
|
|
8546
|
-
if (!this.hasId) {
|
|
8547
|
-
this.name = identifier.name;
|
|
8548
|
-
}
|
|
8549
|
-
}
|
|
8550
|
-
addUsedPlace(usedPlace) {
|
|
8551
|
-
const original = this.getOriginalVariable();
|
|
8552
|
-
if (original === this) {
|
|
8553
|
-
super.addUsedPlace(usedPlace);
|
|
8554
|
-
}
|
|
8555
|
-
else {
|
|
8556
|
-
original.addUsedPlace(usedPlace);
|
|
8557
|
-
}
|
|
8558
|
-
}
|
|
8559
|
-
forbidName(name) {
|
|
8560
|
-
const original = this.getOriginalVariable();
|
|
8561
|
-
if (original === this) {
|
|
8562
|
-
super.forbidName(name);
|
|
8563
|
-
}
|
|
8564
|
-
else {
|
|
8565
|
-
original.forbidName(name);
|
|
8566
|
-
}
|
|
8567
|
-
}
|
|
8568
|
-
getAssignedVariableName() {
|
|
8569
|
-
return (this.originalId && this.originalId.name) || null;
|
|
8570
|
-
}
|
|
8571
|
-
getBaseVariableName() {
|
|
8572
|
-
const original = this.getOriginalVariable();
|
|
8573
|
-
return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
|
|
8574
|
-
}
|
|
8575
|
-
getDirectOriginalVariable() {
|
|
8576
|
-
return this.originalId &&
|
|
8577
|
-
(this.hasId ||
|
|
8578
|
-
!(this.originalId.isPossibleTDZ() ||
|
|
8579
|
-
this.originalId.variable.isReassigned ||
|
|
8580
|
-
this.originalId.variable instanceof UndefinedVariable ||
|
|
8581
|
-
// this avoids a circular dependency
|
|
8582
|
-
'syntheticNamespace' in this.originalId.variable))
|
|
8583
|
-
? this.originalId.variable
|
|
8584
|
-
: null;
|
|
8585
|
-
}
|
|
8586
|
-
getName(getPropertyAccess) {
|
|
8587
|
-
const original = this.getOriginalVariable();
|
|
8588
|
-
return original === this
|
|
8589
|
-
? super.getName(getPropertyAccess)
|
|
8590
|
-
: original.getName(getPropertyAccess);
|
|
8591
|
-
}
|
|
8592
|
-
getOriginalVariable() {
|
|
8593
|
-
if (this.originalVariable)
|
|
8594
|
-
return this.originalVariable;
|
|
8595
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8596
|
-
let original = this;
|
|
8597
|
-
let currentVariable;
|
|
8598
|
-
const checkedVariables = new Set();
|
|
8599
|
-
do {
|
|
8600
|
-
checkedVariables.add(original);
|
|
8601
|
-
currentVariable = original;
|
|
8602
|
-
original = currentVariable.getDirectOriginalVariable();
|
|
8603
|
-
} while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
|
|
8604
|
-
return (this.originalVariable = original || currentVariable);
|
|
8605
|
-
}
|
|
8606
|
-
}
|
|
8607
|
-
|
|
8608
8670
|
class NamespaceVariable extends Variable {
|
|
8609
8671
|
constructor(context) {
|
|
8610
8672
|
super(context.getModuleName());
|
|
@@ -8624,10 +8686,7 @@ class NamespaceVariable extends Variable {
|
|
|
8624
8686
|
if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
|
|
8625
8687
|
const key = path[0];
|
|
8626
8688
|
if (typeof key === 'string') {
|
|
8627
|
-
this.
|
|
8628
|
-
.getExportedVariablesByName()
|
|
8629
|
-
.get(key)
|
|
8630
|
-
?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
|
|
8689
|
+
this.getMemberVariable(key)?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
|
|
8631
8690
|
}
|
|
8632
8691
|
else {
|
|
8633
8692
|
deoptimizeInteraction(interaction);
|
|
@@ -8638,7 +8697,7 @@ class NamespaceVariable extends Variable {
|
|
|
8638
8697
|
if (path.length > 1) {
|
|
8639
8698
|
const key = path[0];
|
|
8640
8699
|
if (typeof key === 'string') {
|
|
8641
|
-
this.
|
|
8700
|
+
this.getMemberVariable(key)?.deoptimizePath(path.slice(1));
|
|
8642
8701
|
}
|
|
8643
8702
|
else if (!this.areAllMembersDeoptimized) {
|
|
8644
8703
|
this.areAllMembersDeoptimized = true;
|
|
@@ -8667,7 +8726,7 @@ class NamespaceVariable extends Variable {
|
|
|
8667
8726
|
if (typeof key !== 'string') {
|
|
8668
8727
|
return true;
|
|
8669
8728
|
}
|
|
8670
|
-
const memberVariable = this.
|
|
8729
|
+
const memberVariable = this.getMemberVariable(key);
|
|
8671
8730
|
return (!memberVariable ||
|
|
8672
8731
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
8673
8732
|
}
|
|
@@ -8679,7 +8738,7 @@ class NamespaceVariable extends Variable {
|
|
|
8679
8738
|
if (path.length > 0) {
|
|
8680
8739
|
const [name, ...remainingPath] = path;
|
|
8681
8740
|
if (typeof name === 'string') {
|
|
8682
|
-
const variable = this.
|
|
8741
|
+
const variable = this.getMemberVariable(name);
|
|
8683
8742
|
if (variable) {
|
|
8684
8743
|
this.context.includeVariableInModule(variable, remainingPath, context);
|
|
8685
8744
|
}
|
|
@@ -8702,15 +8761,16 @@ class NamespaceVariable extends Variable {
|
|
|
8702
8761
|
const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
|
|
8703
8762
|
const memberVariables = this.module.getExportedVariablesByName();
|
|
8704
8763
|
const members = [...memberVariables.entries()]
|
|
8705
|
-
.filter(([name, variable]) => !name
|
|
8764
|
+
.filter(([name, variable]) => !isNamespaceExportName(name) && variable.included)
|
|
8706
8765
|
.map(([name, variable]) => {
|
|
8766
|
+
const key = unescapeExportName(name);
|
|
8707
8767
|
if (this.referencedEarly || variable.isReassigned || variable === this) {
|
|
8708
8768
|
return [
|
|
8709
8769
|
null,
|
|
8710
|
-
`get ${stringifyObjectKeyIfNeeded(
|
|
8770
|
+
`get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
|
|
8711
8771
|
];
|
|
8712
8772
|
}
|
|
8713
|
-
return [
|
|
8773
|
+
return [key, variable.getName(getPropertyAccess)];
|
|
8714
8774
|
});
|
|
8715
8775
|
members.unshift([null, `__proto__:${_}null`]);
|
|
8716
8776
|
let output = getObject(members, { lineBreakIndent: { base: '', t } });
|
|
@@ -8748,6 +8808,9 @@ class NamespaceVariable extends Variable {
|
|
|
8748
8808
|
}
|
|
8749
8809
|
}
|
|
8750
8810
|
}
|
|
8811
|
+
getMemberVariable(name) {
|
|
8812
|
+
return this.module.getExportedVariablesByName().get(escapeExportName(name));
|
|
8813
|
+
}
|
|
8751
8814
|
includeNonExplicitNamespaces() {
|
|
8752
8815
|
if (!this.nonExplicitNamespacesIncluded) {
|
|
8753
8816
|
this.nonExplicitNamespacesIncluded = true;
|
|
@@ -8882,7 +8945,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
8882
8945
|
if (exportBlock)
|
|
8883
8946
|
exportBlock += n;
|
|
8884
8947
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
8885
|
-
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}${getGetter(importName, false, t, snippets)});`;
|
|
8948
|
+
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
|
|
8886
8949
|
}
|
|
8887
8950
|
else if (specifier.reexported === '__proto__') {
|
|
8888
8951
|
exportBlock +=
|
|
@@ -8891,20 +8954,20 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
8891
8954
|
`${t}value:${_}${importName}${n}});`;
|
|
8892
8955
|
}
|
|
8893
8956
|
else {
|
|
8894
|
-
exportBlock += `exports${getPropertyAccess(specifier.reexported)}${_}=${_}${importName};`;
|
|
8957
|
+
exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
|
|
8895
8958
|
}
|
|
8896
8959
|
}
|
|
8897
8960
|
}
|
|
8898
8961
|
}
|
|
8899
8962
|
}
|
|
8900
8963
|
for (const { exported, local, needsLiveBinding } of exports) {
|
|
8901
|
-
const lhs = `exports${getPropertyAccess(exported)}`;
|
|
8964
|
+
const lhs = `exports${getPropertyAccess(unescapeExportName(exported))}`;
|
|
8902
8965
|
const rhs = local;
|
|
8903
8966
|
if (lhs !== rhs) {
|
|
8904
8967
|
if (exportBlock)
|
|
8905
8968
|
exportBlock += n;
|
|
8906
8969
|
if (needsLiveBinding) {
|
|
8907
|
-
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(exported)},${_}${getGetter(rhs, true, t, snippets)});`;
|
|
8970
|
+
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(exported))},${_}${getGetter(rhs, true, t, snippets)});`;
|
|
8908
8971
|
continue;
|
|
8909
8972
|
}
|
|
8910
8973
|
exportBlock +=
|
|
@@ -8982,7 +9045,7 @@ function getReexportedImportName(moduleVariableName, imported, dependencyNamedEx
|
|
|
8982
9045
|
? namespaceVariableName
|
|
8983
9046
|
: moduleVariableName;
|
|
8984
9047
|
}
|
|
8985
|
-
return `${moduleVariableName}${getPropertyAccess(imported)}`;
|
|
9048
|
+
return `${moduleVariableName}${getPropertyAccess(unescapeExportName(imported))}`;
|
|
8986
9049
|
}
|
|
8987
9050
|
function getEsModuleValue(getObject) {
|
|
8988
9051
|
return getObject([['value', 'true']], {
|
|
@@ -9158,6 +9221,8 @@ const builtinModules = [
|
|
|
9158
9221
|
"module",
|
|
9159
9222
|
"node:net",
|
|
9160
9223
|
"net",
|
|
9224
|
+
"node:net/promises",
|
|
9225
|
+
"net/promises",
|
|
9161
9226
|
"node:os",
|
|
9162
9227
|
"os",
|
|
9163
9228
|
"node:path",
|
|
@@ -9367,7 +9432,7 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
|
|
|
9367
9432
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
9368
9433
|
.map(specifier => specifier.imported === specifier.local
|
|
9369
9434
|
? specifier.imported
|
|
9370
|
-
: `${
|
|
9435
|
+
: `${stringifyExportName(specifier.imported)} as ${specifier.local}`)
|
|
9371
9436
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
9372
9437
|
}
|
|
9373
9438
|
}
|
|
@@ -9397,14 +9462,14 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
|
|
|
9397
9462
|
for (const specifier of namespaceReexports) {
|
|
9398
9463
|
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
9399
9464
|
? name
|
|
9400
|
-
: `${name} as ${
|
|
9465
|
+
: `${name} as ${stringifyExportName(specifier.reexported)}`} };`);
|
|
9401
9466
|
}
|
|
9402
9467
|
}
|
|
9403
9468
|
if (namedReexports.length > 0) {
|
|
9404
9469
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
9405
9470
|
.map(specifier => specifier.imported === specifier.reexported
|
|
9406
|
-
?
|
|
9407
|
-
: `${
|
|
9471
|
+
? stringifyExportName(specifier.imported)
|
|
9472
|
+
: `${stringifyExportName(specifier.imported)} as ${stringifyExportName(specifier.reexported)}`)
|
|
9408
9473
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
9409
9474
|
}
|
|
9410
9475
|
}
|
|
@@ -9422,13 +9487,14 @@ function getExportBlock(exports, { _, cnst }) {
|
|
|
9422
9487
|
exportDeclaration[index++] =
|
|
9423
9488
|
specifier.exported === specifier.local
|
|
9424
9489
|
? specifier.local
|
|
9425
|
-
: `${specifier.local} as ${
|
|
9490
|
+
: `${specifier.local} as ${stringifyExportName(specifier.exported)}`;
|
|
9426
9491
|
}
|
|
9427
9492
|
if (exportDeclaration.length > 0) {
|
|
9428
9493
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
9429
9494
|
}
|
|
9430
9495
|
return exportBlock;
|
|
9431
9496
|
}
|
|
9497
|
+
const stringifyExportName = (name) => stringifyIdentifierIfNeeded(unescapeExportName(name));
|
|
9432
9498
|
|
|
9433
9499
|
const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getPropertyAccess).join('');
|
|
9434
9500
|
|
|
@@ -9614,7 +9680,7 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
|
|
|
9614
9680
|
setter.push(`${specifier.local}${_}=${_}module;`);
|
|
9615
9681
|
}
|
|
9616
9682
|
else {
|
|
9617
|
-
setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(specifier.imported)};`);
|
|
9683
|
+
setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(unescapeExportName(specifier.imported))};`);
|
|
9618
9684
|
}
|
|
9619
9685
|
}
|
|
9620
9686
|
}
|
|
@@ -9627,8 +9693,8 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
|
|
|
9627
9693
|
}
|
|
9628
9694
|
else {
|
|
9629
9695
|
reexportedNames.push([
|
|
9630
|
-
reexported,
|
|
9631
|
-
imported === '*' ? 'module' : `module${getPropertyAccess(imported)}`
|
|
9696
|
+
unescapeExportName(reexported),
|
|
9697
|
+
imported === '*' ? 'module' : `module${getPropertyAccess(unescapeExportName(imported))}`
|
|
9632
9698
|
]);
|
|
9633
9699
|
}
|
|
9634
9700
|
}
|
|
@@ -9656,13 +9722,13 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
|
|
|
9656
9722
|
return { importBindings, setters, starExcludes };
|
|
9657
9723
|
}
|
|
9658
9724
|
const getStarExcludes = ({ dependencies, exports }) => {
|
|
9659
|
-
const starExcludes = new Set(exports.map(expt => expt.exported));
|
|
9725
|
+
const starExcludes = new Set(exports.map(expt => unescapeExportName(expt.exported)));
|
|
9660
9726
|
starExcludes.add('default');
|
|
9661
9727
|
for (const { reexports } of dependencies) {
|
|
9662
9728
|
if (reexports) {
|
|
9663
9729
|
for (const reexport of reexports) {
|
|
9664
9730
|
if (reexport.reexported !== '*')
|
|
9665
|
-
starExcludes.add(reexport.reexported);
|
|
9731
|
+
starExcludes.add(unescapeExportName(reexport.reexported));
|
|
9666
9732
|
}
|
|
9667
9733
|
}
|
|
9668
9734
|
}
|
|
@@ -9688,11 +9754,11 @@ function getExportsBlock(exports, t, { _, n }) {
|
|
|
9688
9754
|
return '';
|
|
9689
9755
|
}
|
|
9690
9756
|
if (exports.length === 1) {
|
|
9691
|
-
return `exports(${JSON.stringify(exports[0].name)},${_}${exports[0].value});${n}${n}`;
|
|
9757
|
+
return `exports(${JSON.stringify(unescapeExportName(exports[0].name))},${_}${exports[0].value});${n}${n}`;
|
|
9692
9758
|
}
|
|
9693
9759
|
return (`exports({${n}` +
|
|
9694
9760
|
exports
|
|
9695
|
-
.map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(name)}:${_}${value}`)
|
|
9761
|
+
.map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(unescapeExportName(name))}:${_}${value}`)
|
|
9696
9762
|
.join(`,${n}`) +
|
|
9697
9763
|
`${n}});${n}${n}`);
|
|
9698
9764
|
}
|
|
@@ -17724,6 +17790,11 @@ function decodedSourcemap(map) {
|
|
|
17724
17790
|
if (typeof map === 'string') {
|
|
17725
17791
|
map = JSON.parse(map);
|
|
17726
17792
|
}
|
|
17793
|
+
// A map this function already returned, e.g. one restored from the cache of a previous build, is
|
|
17794
|
+
// lazy. Reading its mappings below would decode it.
|
|
17795
|
+
if (sourceMapCache.has(map)) {
|
|
17796
|
+
return map;
|
|
17797
|
+
}
|
|
17727
17798
|
if ('sections' in map) {
|
|
17728
17799
|
map = flattenIndexSourceMap(map);
|
|
17729
17800
|
}
|
|
@@ -18302,7 +18373,7 @@ class Module {
|
|
|
18302
18373
|
exportedVariablesByName.set(name, exportedVariable);
|
|
18303
18374
|
}
|
|
18304
18375
|
else {
|
|
18305
|
-
return error(logMissingEntryExport(name, this.id));
|
|
18376
|
+
return error(logMissingEntryExport(unescapeExportName(name), this.id));
|
|
18306
18377
|
}
|
|
18307
18378
|
}
|
|
18308
18379
|
}
|
|
@@ -18314,7 +18385,7 @@ class Module {
|
|
|
18314
18385
|
}
|
|
18315
18386
|
for (const module of this.exportAllModules) {
|
|
18316
18387
|
if (module instanceof ExternalModule) {
|
|
18317
|
-
exportedVariablesByName.set(
|
|
18388
|
+
exportedVariablesByName.set(getExternalNamespaceExportName(module.id), module.getVariableForExportName('*', {
|
|
18318
18389
|
importChain: [this.id]
|
|
18319
18390
|
})[0]);
|
|
18320
18391
|
continue;
|
|
@@ -18374,13 +18445,13 @@ class Module {
|
|
|
18374
18445
|
return this.syntheticNamespace;
|
|
18375
18446
|
}
|
|
18376
18447
|
getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = EMPTY_OBJECT) {
|
|
18377
|
-
if (name
|
|
18448
|
+
if (isNamespaceExportName(name)) {
|
|
18378
18449
|
if (name.length === 1) {
|
|
18379
18450
|
// export * from './other'
|
|
18380
18451
|
return [this.namespace];
|
|
18381
18452
|
}
|
|
18382
18453
|
// export * from 'external'
|
|
18383
|
-
const module = this.graph.modulesById.get(name
|
|
18454
|
+
const module = this.graph.modulesById.get(getExternalNamespaceId(name));
|
|
18384
18455
|
return module.getVariableForExportName('*', {
|
|
18385
18456
|
importChain: [...importChain, this.id]
|
|
18386
18457
|
});
|
|
@@ -18390,7 +18461,7 @@ class Module {
|
|
|
18390
18461
|
if (reexportDeclaration) {
|
|
18391
18462
|
const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id], sideEffectModules, exportOrReexportModules);
|
|
18392
18463
|
if (!variable) {
|
|
18393
|
-
return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
|
|
18464
|
+
return this.error(logMissingExport(unescapeExportName(reexportDeclaration.localName), this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
|
|
18394
18465
|
}
|
|
18395
18466
|
if (importerForSideEffects) {
|
|
18396
18467
|
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
@@ -18453,7 +18524,7 @@ class Module {
|
|
|
18453
18524
|
}
|
|
18454
18525
|
if (this.info.syntheticNamedExports) {
|
|
18455
18526
|
return [
|
|
18456
|
-
getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, name, this.getSyntheticNamespace()))
|
|
18527
|
+
getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, unescapeExportName(name), this.getSyntheticNamespace()))
|
|
18457
18528
|
];
|
|
18458
18529
|
}
|
|
18459
18530
|
// we don't want to create shims when we are just
|
|
@@ -18592,7 +18663,7 @@ class Module {
|
|
|
18592
18663
|
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
18593
18664
|
options: this.options,
|
|
18594
18665
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
18595
|
-
traceExport: (name) => this.getVariableForExportName(name),
|
|
18666
|
+
traceExport: (name) => this.getVariableForExportName(escapeExportName(name)),
|
|
18596
18667
|
traceVariable: this.traceVariable.bind(this),
|
|
18597
18668
|
usesTopLevelAwait: false
|
|
18598
18669
|
};
|
|
@@ -18668,7 +18739,7 @@ class Module {
|
|
|
18668
18739
|
}
|
|
18669
18740
|
const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id], sideEffectModules, exportOrReexportModules);
|
|
18670
18741
|
if (!declaration) {
|
|
18671
|
-
return this.error(logMissingExport(importDescription.name, this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
|
|
18742
|
+
return this.error(logMissingExport(unescapeExportName(importDescription.name), this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
|
|
18672
18743
|
}
|
|
18673
18744
|
return declaration;
|
|
18674
18745
|
}
|
|
@@ -18706,7 +18777,7 @@ class Module {
|
|
|
18706
18777
|
}
|
|
18707
18778
|
assertUniqueExportName(name, nodeStart) {
|
|
18708
18779
|
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
18709
|
-
this.error(logDuplicateExportError(name), nodeStart);
|
|
18780
|
+
this.error(logDuplicateExportError(unescapeExportName(name)), nodeStart);
|
|
18710
18781
|
}
|
|
18711
18782
|
}
|
|
18712
18783
|
addExport(node) {
|
|
@@ -18723,7 +18794,7 @@ class Module {
|
|
|
18723
18794
|
this.addSource(source, node);
|
|
18724
18795
|
if (node.exported) {
|
|
18725
18796
|
// export * as name from './other'
|
|
18726
|
-
const name = node.exported instanceof Literal ? node.exported.value : node.exported.name;
|
|
18797
|
+
const name = escapeExportName(node.exported instanceof Literal ? node.exported.value : node.exported.name);
|
|
18727
18798
|
this.assertUniqueExportName(name, node.exported.start);
|
|
18728
18799
|
this.reexportDescriptions.set(name, {
|
|
18729
18800
|
localName: '*',
|
|
@@ -18742,10 +18813,10 @@ class Module {
|
|
|
18742
18813
|
const source = node.source.value;
|
|
18743
18814
|
this.addSource(source, node);
|
|
18744
18815
|
for (const { exported, local, start } of node.specifiers) {
|
|
18745
|
-
const name = exported instanceof Literal ? exported.value : exported.name;
|
|
18816
|
+
const name = escapeExportName(exported instanceof Literal ? exported.value : exported.name);
|
|
18746
18817
|
this.assertUniqueExportName(name, start);
|
|
18747
18818
|
this.reexportDescriptions.set(name, {
|
|
18748
|
-
localName: local instanceof Literal ? local.value : local.name,
|
|
18819
|
+
localName: escapeExportName(local instanceof Literal ? local.value : local.name),
|
|
18749
18820
|
module: null, // filled in later,
|
|
18750
18821
|
source,
|
|
18751
18822
|
start
|
|
@@ -18776,7 +18847,7 @@ class Module {
|
|
|
18776
18847
|
for (const { local, exported } of node.specifiers) {
|
|
18777
18848
|
// except for reexports, local must be an Identifier
|
|
18778
18849
|
const localName = local.name;
|
|
18779
|
-
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
18850
|
+
const exportedName = escapeExportName(exported instanceof Identifier ? exported.name : exported.value);
|
|
18780
18851
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
18781
18852
|
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
18782
18853
|
}
|
|
@@ -18798,7 +18869,7 @@ class Module {
|
|
|
18798
18869
|
? '*'
|
|
18799
18870
|
: specifier.imported instanceof Identifier
|
|
18800
18871
|
? specifier.imported.name
|
|
18801
|
-
: specifier.imported.value;
|
|
18872
|
+
: escapeExportName(specifier.imported.value);
|
|
18802
18873
|
this.importDescriptions.set(localName, {
|
|
18803
18874
|
module: null, // filled in later
|
|
18804
18875
|
name,
|
|
@@ -19150,8 +19221,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
19150
19221
|
: chunk.variableName);
|
|
19151
19222
|
}
|
|
19152
19223
|
else {
|
|
19153
|
-
|
|
19154
|
-
variable.setRenderNames(chunk.variableName, null);
|
|
19224
|
+
variable.setRenderNames(chunk.variableName, unescapeExportName(name));
|
|
19155
19225
|
}
|
|
19156
19226
|
}
|
|
19157
19227
|
else {
|
|
@@ -19163,7 +19233,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
|
|
|
19163
19233
|
variable.setRenderNames(null, chunk.variableName);
|
|
19164
19234
|
}
|
|
19165
19235
|
else {
|
|
19166
|
-
variable.setRenderNames(chunk.variableName, chunk.getVariableExportName(variable));
|
|
19236
|
+
variable.setRenderNames(chunk.variableName, unescapeExportName(chunk.getVariableExportName(variable)));
|
|
19167
19237
|
}
|
|
19168
19238
|
}
|
|
19169
19239
|
}
|
|
@@ -19195,36 +19265,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
|
|
|
19195
19265
|
}
|
|
19196
19266
|
}
|
|
19197
19267
|
|
|
19198
|
-
function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
|
|
19199
|
-
let nameIndex = 0;
|
|
19200
|
-
for (const variable of exports) {
|
|
19201
|
-
let [exportName] = variable.name;
|
|
19202
|
-
if (exportsByName.has(exportName)) {
|
|
19203
|
-
do {
|
|
19204
|
-
exportName = toBase64(++nameIndex);
|
|
19205
|
-
// skip past leading number identifiers
|
|
19206
|
-
if (exportName.charCodeAt(0) === 49 /* '1' */) {
|
|
19207
|
-
nameIndex += 9 * 64 ** (exportName.length - 1);
|
|
19208
|
-
exportName = toBase64(nameIndex);
|
|
19209
|
-
}
|
|
19210
|
-
} while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
|
|
19211
|
-
}
|
|
19212
|
-
exportsByName.set(exportName, variable);
|
|
19213
|
-
exportNamesByVariable.set(variable, [exportName]);
|
|
19214
|
-
}
|
|
19215
|
-
}
|
|
19216
|
-
function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
|
|
19217
|
-
for (const variable of exports) {
|
|
19218
|
-
let nameIndex = 0;
|
|
19219
|
-
let exportName = variable.name;
|
|
19220
|
-
while (exportsByName.has(exportName)) {
|
|
19221
|
-
exportName = variable.name + '$' + ++nameIndex;
|
|
19222
|
-
}
|
|
19223
|
-
exportsByName.set(exportName, variable);
|
|
19224
|
-
exportNamesByVariable.set(variable, [exportName]);
|
|
19225
|
-
}
|
|
19226
|
-
}
|
|
19227
|
-
|
|
19228
19268
|
function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
|
|
19229
19269
|
const exportKeys = chunk.getExportNames();
|
|
19230
19270
|
if (exportMode === 'default') {
|
|
@@ -19700,7 +19740,8 @@ class Chunk {
|
|
|
19700
19740
|
this.facadeModule = module;
|
|
19701
19741
|
this.facadeChunkByModule.set(module, this);
|
|
19702
19742
|
this.strictFacade = true;
|
|
19703
|
-
this.dynamicName =
|
|
19743
|
+
this.dynamicName =
|
|
19744
|
+
getPredefinedChunkNameFromModule(module) ?? getDynamicAliasName(module.id);
|
|
19704
19745
|
}
|
|
19705
19746
|
else if (this.facadeModule === module &&
|
|
19706
19747
|
!this.strictFacade &&
|
|
@@ -20015,7 +20056,7 @@ class Chunk {
|
|
|
20015
20056
|
getChunkExportDeclarations(format) {
|
|
20016
20057
|
const exports = [];
|
|
20017
20058
|
for (const exportName of this.getExportNames()) {
|
|
20018
|
-
if (exportName
|
|
20059
|
+
if (isNamespaceExportName(exportName))
|
|
20019
20060
|
continue;
|
|
20020
20061
|
const variable = this.exportsByName.get(exportName);
|
|
20021
20062
|
if (!(variable instanceof SyntheticNamedExportVariable)) {
|
|
@@ -20087,7 +20128,7 @@ class Chunk {
|
|
|
20087
20128
|
else if (variable.isNamespace &&
|
|
20088
20129
|
namespaceInteropHelpersByInteropType[interop(module.id)] &&
|
|
20089
20130
|
(this.imports.has(variable) ||
|
|
20090
|
-
!this.exportNamesByVariable.get(variable)?.every(
|
|
20131
|
+
!this.exportNamesByVariable.get(variable)?.every(isNamespaceExportName))) {
|
|
20091
20132
|
// We only need to deconflict it if the namespace is actually
|
|
20092
20133
|
// created as a variable, i.e. because it is used internally or
|
|
20093
20134
|
// because it is reexported as an object
|
|
@@ -20272,8 +20313,8 @@ class Chunk {
|
|
|
20272
20313
|
let dependency;
|
|
20273
20314
|
let imported;
|
|
20274
20315
|
let needsLiveBinding;
|
|
20275
|
-
if (exportName
|
|
20276
|
-
const id = exportName
|
|
20316
|
+
if (isNamespaceExportName(exportName)) {
|
|
20317
|
+
const id = getExternalNamespaceId(exportName);
|
|
20277
20318
|
if (interop(id) === 'defaultOnly') {
|
|
20278
20319
|
this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id));
|
|
20279
20320
|
}
|
|
@@ -20505,7 +20546,7 @@ class Chunk {
|
|
|
20505
20546
|
format !== 'system' &&
|
|
20506
20547
|
exportVariable.isReassigned &&
|
|
20507
20548
|
!exportVariable.isId) {
|
|
20508
|
-
exportVariable.setRenderNames('exports', exportName);
|
|
20549
|
+
exportVariable.setRenderNames('exports', unescapeExportName(exportName));
|
|
20509
20550
|
}
|
|
20510
20551
|
else if (exportVariable instanceof SyntheticNamedExportVariable) {
|
|
20511
20552
|
syntheticExports.add(exportVariable);
|
|
@@ -20833,16 +20874,19 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
|
|
|
20833
20874
|
staticDependencies.add(dependency);
|
|
20834
20875
|
}
|
|
20835
20876
|
}
|
|
20836
|
-
for (const { node
|
|
20877
|
+
for (const { node } of module.dynamicImports) {
|
|
20878
|
+
const { resolution } = node;
|
|
20837
20879
|
if (resolution instanceof Module &&
|
|
20838
20880
|
resolution.includedDynamicImporters.length > 0 &&
|
|
20839
20881
|
(dynamicEntryModules.has(resolution) || !allEntriesSet.has(resolution))) {
|
|
20840
20882
|
dynamicEntriesForCurrentEntry.add(resolution);
|
|
20883
|
+
if (node.included) {
|
|
20884
|
+
dynamicImportsForCurrentEntry.add(resolution);
|
|
20885
|
+
}
|
|
20841
20886
|
if (!allEntriesSet.has(resolution)) {
|
|
20842
20887
|
dynamicEntryModules.add(resolution);
|
|
20843
20888
|
allEntriesSet.add(resolution);
|
|
20844
20889
|
allEntriesAndManualChunks.push([resolution]);
|
|
20845
|
-
dynamicImportsForCurrentEntry.add(resolution);
|
|
20846
20890
|
}
|
|
20847
20891
|
}
|
|
20848
20892
|
}
|
|
@@ -20852,6 +20896,9 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
|
|
|
20852
20896
|
allEntriesSet.add(dependency);
|
|
20853
20897
|
allEntriesAndManualChunks.push([dependency]);
|
|
20854
20898
|
}
|
|
20899
|
+
if (dynamicEntryModules.has(dependency)) {
|
|
20900
|
+
dynamicImportsForCurrentEntry.add(dependency);
|
|
20901
|
+
}
|
|
20855
20902
|
}
|
|
20856
20903
|
}
|
|
20857
20904
|
// A dynamic import can be awaited indirectly through a static dependency.
|
|
@@ -21809,8 +21856,10 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
21809
21856
|
if (sourcemap) {
|
|
21810
21857
|
timeStart('sourcemaps', 3);
|
|
21811
21858
|
let resultingFile;
|
|
21812
|
-
if (
|
|
21813
|
-
resultingFile = resolve$1(sourcemapFile
|
|
21859
|
+
if (sourcemapFile)
|
|
21860
|
+
resultingFile = resolve$1(sourcemapFile);
|
|
21861
|
+
else if (file)
|
|
21862
|
+
resultingFile = resolve$1(file);
|
|
21814
21863
|
else if (dir)
|
|
21815
21864
|
resultingFile = resolve$1(dir, fileName);
|
|
21816
21865
|
else
|
|
@@ -21906,6 +21955,9 @@ function getChunkHash({ code, map, fileName, sourcemapFileName }, outputOptions,
|
|
|
21906
21955
|
// replaced with the same value before hashing
|
|
21907
21956
|
const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
|
|
21908
21957
|
let contentToHash = transformedCode;
|
|
21958
|
+
if (map && outputOptions.sourcemapDebugIds) {
|
|
21959
|
+
contentToHash += '//# debugId=\n';
|
|
21960
|
+
}
|
|
21909
21961
|
if (map && outputOptions.sourcemap !== 'hidden') {
|
|
21910
21962
|
// Normalize raw map data and file names before base64 or URL encoding
|
|
21911
21963
|
// can hide placeholders and make hashes depend on chunk order.
|
|
@@ -24328,7 +24380,7 @@ class Graph {
|
|
|
24328
24380
|
if (importDescription.name !== '*' && importDescription.phase !== 'source') {
|
|
24329
24381
|
const [variable, options] = importDescription.module.getVariableForExportName(importDescription.name, { importChain: [module.id] });
|
|
24330
24382
|
if (!variable) {
|
|
24331
|
-
module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
|
|
24383
|
+
module.log(LOGLEVEL_WARN, logMissingExport(unescapeExportName(importDescription.name), module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
|
|
24332
24384
|
}
|
|
24333
24385
|
}
|
|
24334
24386
|
}
|