rollup 4.59.1 → 4.60.1
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 +429 -37
- package/dist/es/shared/parseAst.js +29 -7
- package/dist/es/shared/watch.js +614 -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 +614 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +30 -6
- package/dist/shared/rollup.js +428 -36
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +34 -33
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.60.1
|
|
4
|
+
Mon, 30 Mar 2026 04:32:12 GMT - commit ae871d762f6bbeb4320d28fe179211168f27a434
|
|
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, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, FunctionExpression as FunctionExpression$1, ArrowFunctionExpression as ArrowFunctionExpression$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, logMissingNodeBuiltins, logReservedNamespace,
|
|
10
|
+
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, FunctionExpression as FunctionExpression$1, ArrowFunctionExpression as ArrowFunctionExpression$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, 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, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, 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 { posix, isAbsolute, resolve, win32 } 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.60.1";
|
|
31
31
|
|
|
32
32
|
// src/vlq.ts
|
|
33
33
|
var comma = ",".charCodeAt(0);
|
|
@@ -2464,12 +2464,15 @@ class Variable extends ExpressionEntity {
|
|
|
2464
2464
|
}
|
|
2465
2465
|
}
|
|
2466
2466
|
|
|
2467
|
+
/** Synthetic import name for source phase imports, similar to '*' for namespaces */
|
|
2468
|
+
const SOURCE_PHASE_IMPORT = '*source';
|
|
2467
2469
|
class ExternalVariable extends Variable {
|
|
2468
2470
|
constructor(module, name) {
|
|
2469
2471
|
super(name);
|
|
2470
2472
|
this.referenced = false;
|
|
2471
2473
|
this.module = module;
|
|
2472
2474
|
this.isNamespace = name === '*';
|
|
2475
|
+
this.isSourcePhase = name === SOURCE_PHASE_IMPORT;
|
|
2473
2476
|
}
|
|
2474
2477
|
addReference(identifier) {
|
|
2475
2478
|
this.referenced = true;
|
|
@@ -8432,6 +8435,13 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, sy
|
|
|
8432
8435
|
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, indent, snippets, externalLiveBindings, freeze, symbols)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
8433
8436
|
}
|
|
8434
8437
|
|
|
8438
|
+
function throwOnPhase(outputFormat, chunkId, dependencies) {
|
|
8439
|
+
const sourcePhaseDependency = dependencies.find(dependency => dependency.sourcePhaseImport);
|
|
8440
|
+
if (sourcePhaseDependency) {
|
|
8441
|
+
error(logSourcePhaseFormatUnsupported(outputFormat, chunkId, sourcePhaseDependency.importPath));
|
|
8442
|
+
}
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8435
8445
|
function addJsExtension(name) {
|
|
8436
8446
|
return name.endsWith('.js') ? name : name + '.js';
|
|
8437
8447
|
}
|
|
@@ -8570,6 +8580,7 @@ function warnOnBuiltins(log, dependencies) {
|
|
|
8570
8580
|
|
|
8571
8581
|
function amd(magicString, { accessedGlobals, dependencies, exports: exports$1, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, log, outro, snippets }, { amd, esModule, externalLiveBindings, freeze, generatedCode: { symbols }, interop, reexportProtoFromExternal, strict }) {
|
|
8572
8582
|
warnOnBuiltins(log, dependencies);
|
|
8583
|
+
throwOnPhase('amd', id, dependencies);
|
|
8573
8584
|
const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
8574
8585
|
const parameters = dependencies.map(m => m.name);
|
|
8575
8586
|
const { n, getNonArrowFunctionIntro, _ } = snippets;
|
|
@@ -8607,7 +8618,8 @@ function amd(magicString, { accessedGlobals, dependencies, exports: exports$1, h
|
|
|
8607
8618
|
.append(`${n}${n}}));`);
|
|
8608
8619
|
}
|
|
8609
8620
|
|
|
8610
|
-
function cjs(magicString, { accessedGlobals, dependencies, exports: exports$1, hasDefaultExport, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, generatedCode: { symbols }, reexportProtoFromExternal, strict }) {
|
|
8621
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports: exports$1, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, generatedCode: { symbols }, reexportProtoFromExternal, strict }) {
|
|
8622
|
+
throwOnPhase('cjs', id, dependencies);
|
|
8611
8623
|
const { _, n } = snippets;
|
|
8612
8624
|
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
8613
8625
|
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && symbols, snippets);
|
|
@@ -8660,11 +8672,16 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
8660
8672
|
}
|
|
8661
8673
|
function getImportBlock(dependencies, importAttributesKey, { _ }) {
|
|
8662
8674
|
const importBlock = [];
|
|
8663
|
-
for (const { importPath, reexports, imports, name, attributes } of dependencies) {
|
|
8675
|
+
for (const { importPath, reexports, imports, name, attributes, sourcePhaseImport } of dependencies) {
|
|
8664
8676
|
const assertion = attributes ? `${_}${importAttributesKey}${_}${attributes}` : '';
|
|
8665
8677
|
const pathWithAssertion = `'${importPath}'${assertion};`;
|
|
8678
|
+
if (sourcePhaseImport) {
|
|
8679
|
+
importBlock.push(`import source ${sourcePhaseImport} from${_}${pathWithAssertion}`);
|
|
8680
|
+
}
|
|
8666
8681
|
if (!reexports && !imports) {
|
|
8667
|
-
|
|
8682
|
+
if (!sourcePhaseImport) {
|
|
8683
|
+
importBlock.push(`import${_}${pathWithAssertion}`);
|
|
8684
|
+
}
|
|
8668
8685
|
continue;
|
|
8669
8686
|
}
|
|
8670
8687
|
if (imports) {
|
|
@@ -8818,7 +8835,8 @@ function trimEmptyImports(dependencies) {
|
|
|
8818
8835
|
return [];
|
|
8819
8836
|
}
|
|
8820
8837
|
|
|
8821
|
-
function iife(magicString, { accessedGlobals, dependencies, exports: exports$1, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, reexportProtoFromExternal, globals, interop, name, generatedCode: { symbols }, strict }) {
|
|
8838
|
+
function iife(magicString, { accessedGlobals, dependencies, exports: exports$1, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, reexportProtoFromExternal, globals, interop, name, generatedCode: { symbols }, strict }) {
|
|
8839
|
+
throwOnPhase('iife', id, dependencies);
|
|
8822
8840
|
const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
|
|
8823
8841
|
const isNamespaced = name && name.includes('.');
|
|
8824
8842
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
@@ -8877,7 +8895,8 @@ function iife(magicString, { accessedGlobals, dependencies, exports: exports$1,
|
|
|
8877
8895
|
|
|
8878
8896
|
const MISSING_EXPORT_SHIM_VARIABLE = '_missingExportShim';
|
|
8879
8897
|
|
|
8880
|
-
function system(magicString, { accessedGlobals, dependencies, exports: exports$1, hasExports, indent: t, intro, snippets, outro, usesTopLevelAwait }, { externalLiveBindings, freeze, name, generatedCode: { symbols }, strict, systemNullSetters }) {
|
|
8898
|
+
function system(magicString, { accessedGlobals, dependencies, exports: exports$1, hasExports, id, indent: t, intro, snippets, outro, usesTopLevelAwait }, { externalLiveBindings, freeze, name, generatedCode: { symbols }, strict, systemNullSetters }) {
|
|
8899
|
+
throwOnPhase('system', id, dependencies);
|
|
8881
8900
|
const { _, getFunctionIntro, getNonArrowFunctionIntro, n, s } = snippets;
|
|
8882
8901
|
const { importBindings, setters, starExcludes } = analyzeDependencies(dependencies, exports$1, t, snippets);
|
|
8883
8902
|
const registeredName = name ? `'${name}',${_}` : '';
|
|
@@ -9045,6 +9064,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports: exports$1, h
|
|
|
9045
9064
|
if (hasExports && !name) {
|
|
9046
9065
|
return error(logMissingNameOptionForUmdExport());
|
|
9047
9066
|
}
|
|
9067
|
+
throwOnPhase('umd', id, dependencies);
|
|
9048
9068
|
warnOnBuiltins(log, dependencies);
|
|
9049
9069
|
const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
9050
9070
|
const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
|
|
@@ -9180,6 +9200,8 @@ function requireConstants () {
|
|
|
9180
9200
|
const WIN_SLASH = '\\\\/';
|
|
9181
9201
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
9182
9202
|
|
|
9203
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
9204
|
+
|
|
9183
9205
|
/**
|
|
9184
9206
|
* Posix glob regex
|
|
9185
9207
|
*/
|
|
@@ -9246,6 +9268,7 @@ function requireConstants () {
|
|
|
9246
9268
|
*/
|
|
9247
9269
|
|
|
9248
9270
|
const POSIX_REGEX_SOURCE = {
|
|
9271
|
+
__proto__: null,
|
|
9249
9272
|
alnum: 'a-zA-Z0-9',
|
|
9250
9273
|
alpha: 'a-zA-Z',
|
|
9251
9274
|
ascii: '\\x00-\\x7F',
|
|
@@ -9263,6 +9286,7 @@ function requireConstants () {
|
|
|
9263
9286
|
};
|
|
9264
9287
|
|
|
9265
9288
|
constants = {
|
|
9289
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
9266
9290
|
MAX_LENGTH: 1024 * 64,
|
|
9267
9291
|
POSIX_REGEX_SOURCE,
|
|
9268
9292
|
|
|
@@ -9884,6 +9908,277 @@ function requireParse () {
|
|
|
9884
9908
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
9885
9909
|
};
|
|
9886
9910
|
|
|
9911
|
+
const splitTopLevel = input => {
|
|
9912
|
+
const parts = [];
|
|
9913
|
+
let bracket = 0;
|
|
9914
|
+
let paren = 0;
|
|
9915
|
+
let quote = 0;
|
|
9916
|
+
let value = '';
|
|
9917
|
+
let escaped = false;
|
|
9918
|
+
|
|
9919
|
+
for (const ch of input) {
|
|
9920
|
+
if (escaped === true) {
|
|
9921
|
+
value += ch;
|
|
9922
|
+
escaped = false;
|
|
9923
|
+
continue;
|
|
9924
|
+
}
|
|
9925
|
+
|
|
9926
|
+
if (ch === '\\') {
|
|
9927
|
+
value += ch;
|
|
9928
|
+
escaped = true;
|
|
9929
|
+
continue;
|
|
9930
|
+
}
|
|
9931
|
+
|
|
9932
|
+
if (ch === '"') {
|
|
9933
|
+
quote = quote === 1 ? 0 : 1;
|
|
9934
|
+
value += ch;
|
|
9935
|
+
continue;
|
|
9936
|
+
}
|
|
9937
|
+
|
|
9938
|
+
if (quote === 0) {
|
|
9939
|
+
if (ch === '[') {
|
|
9940
|
+
bracket++;
|
|
9941
|
+
} else if (ch === ']' && bracket > 0) {
|
|
9942
|
+
bracket--;
|
|
9943
|
+
} else if (bracket === 0) {
|
|
9944
|
+
if (ch === '(') {
|
|
9945
|
+
paren++;
|
|
9946
|
+
} else if (ch === ')' && paren > 0) {
|
|
9947
|
+
paren--;
|
|
9948
|
+
} else if (ch === '|' && paren === 0) {
|
|
9949
|
+
parts.push(value);
|
|
9950
|
+
value = '';
|
|
9951
|
+
continue;
|
|
9952
|
+
}
|
|
9953
|
+
}
|
|
9954
|
+
}
|
|
9955
|
+
|
|
9956
|
+
value += ch;
|
|
9957
|
+
}
|
|
9958
|
+
|
|
9959
|
+
parts.push(value);
|
|
9960
|
+
return parts;
|
|
9961
|
+
};
|
|
9962
|
+
|
|
9963
|
+
const isPlainBranch = branch => {
|
|
9964
|
+
let escaped = false;
|
|
9965
|
+
|
|
9966
|
+
for (const ch of branch) {
|
|
9967
|
+
if (escaped === true) {
|
|
9968
|
+
escaped = false;
|
|
9969
|
+
continue;
|
|
9970
|
+
}
|
|
9971
|
+
|
|
9972
|
+
if (ch === '\\') {
|
|
9973
|
+
escaped = true;
|
|
9974
|
+
continue;
|
|
9975
|
+
}
|
|
9976
|
+
|
|
9977
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
9978
|
+
return false;
|
|
9979
|
+
}
|
|
9980
|
+
}
|
|
9981
|
+
|
|
9982
|
+
return true;
|
|
9983
|
+
};
|
|
9984
|
+
|
|
9985
|
+
const normalizeSimpleBranch = branch => {
|
|
9986
|
+
let value = branch.trim();
|
|
9987
|
+
let changed = true;
|
|
9988
|
+
|
|
9989
|
+
while (changed === true) {
|
|
9990
|
+
changed = false;
|
|
9991
|
+
|
|
9992
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
9993
|
+
value = value.slice(2, -1);
|
|
9994
|
+
changed = true;
|
|
9995
|
+
}
|
|
9996
|
+
}
|
|
9997
|
+
|
|
9998
|
+
if (!isPlainBranch(value)) {
|
|
9999
|
+
return;
|
|
10000
|
+
}
|
|
10001
|
+
|
|
10002
|
+
return value.replace(/\\(.)/g, '$1');
|
|
10003
|
+
};
|
|
10004
|
+
|
|
10005
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
10006
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
10007
|
+
|
|
10008
|
+
for (let i = 0; i < values.length; i++) {
|
|
10009
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
10010
|
+
const a = values[i];
|
|
10011
|
+
const b = values[j];
|
|
10012
|
+
const char = a[0];
|
|
10013
|
+
|
|
10014
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
10015
|
+
continue;
|
|
10016
|
+
}
|
|
10017
|
+
|
|
10018
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
10019
|
+
return true;
|
|
10020
|
+
}
|
|
10021
|
+
}
|
|
10022
|
+
}
|
|
10023
|
+
|
|
10024
|
+
return false;
|
|
10025
|
+
};
|
|
10026
|
+
|
|
10027
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
10028
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
10029
|
+
return;
|
|
10030
|
+
}
|
|
10031
|
+
|
|
10032
|
+
let bracket = 0;
|
|
10033
|
+
let paren = 0;
|
|
10034
|
+
let quote = 0;
|
|
10035
|
+
let escaped = false;
|
|
10036
|
+
|
|
10037
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
10038
|
+
const ch = pattern[i];
|
|
10039
|
+
|
|
10040
|
+
if (escaped === true) {
|
|
10041
|
+
escaped = false;
|
|
10042
|
+
continue;
|
|
10043
|
+
}
|
|
10044
|
+
|
|
10045
|
+
if (ch === '\\') {
|
|
10046
|
+
escaped = true;
|
|
10047
|
+
continue;
|
|
10048
|
+
}
|
|
10049
|
+
|
|
10050
|
+
if (ch === '"') {
|
|
10051
|
+
quote = quote === 1 ? 0 : 1;
|
|
10052
|
+
continue;
|
|
10053
|
+
}
|
|
10054
|
+
|
|
10055
|
+
if (quote === 1) {
|
|
10056
|
+
continue;
|
|
10057
|
+
}
|
|
10058
|
+
|
|
10059
|
+
if (ch === '[') {
|
|
10060
|
+
bracket++;
|
|
10061
|
+
continue;
|
|
10062
|
+
}
|
|
10063
|
+
|
|
10064
|
+
if (ch === ']' && bracket > 0) {
|
|
10065
|
+
bracket--;
|
|
10066
|
+
continue;
|
|
10067
|
+
}
|
|
10068
|
+
|
|
10069
|
+
if (bracket > 0) {
|
|
10070
|
+
continue;
|
|
10071
|
+
}
|
|
10072
|
+
|
|
10073
|
+
if (ch === '(') {
|
|
10074
|
+
paren++;
|
|
10075
|
+
continue;
|
|
10076
|
+
}
|
|
10077
|
+
|
|
10078
|
+
if (ch === ')') {
|
|
10079
|
+
paren--;
|
|
10080
|
+
|
|
10081
|
+
if (paren === 0) {
|
|
10082
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
10083
|
+
return;
|
|
10084
|
+
}
|
|
10085
|
+
|
|
10086
|
+
return {
|
|
10087
|
+
type: pattern[0],
|
|
10088
|
+
body: pattern.slice(2, i),
|
|
10089
|
+
end: i
|
|
10090
|
+
};
|
|
10091
|
+
}
|
|
10092
|
+
}
|
|
10093
|
+
}
|
|
10094
|
+
};
|
|
10095
|
+
|
|
10096
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
10097
|
+
let index = 0;
|
|
10098
|
+
const chars = [];
|
|
10099
|
+
|
|
10100
|
+
while (index < pattern.length) {
|
|
10101
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
10102
|
+
|
|
10103
|
+
if (!match || match.type !== '*') {
|
|
10104
|
+
return;
|
|
10105
|
+
}
|
|
10106
|
+
|
|
10107
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
10108
|
+
if (branches.length !== 1) {
|
|
10109
|
+
return;
|
|
10110
|
+
}
|
|
10111
|
+
|
|
10112
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
10113
|
+
if (!branch || branch.length !== 1) {
|
|
10114
|
+
return;
|
|
10115
|
+
}
|
|
10116
|
+
|
|
10117
|
+
chars.push(branch);
|
|
10118
|
+
index += match.end + 1;
|
|
10119
|
+
}
|
|
10120
|
+
|
|
10121
|
+
if (chars.length < 1) {
|
|
10122
|
+
return;
|
|
10123
|
+
}
|
|
10124
|
+
|
|
10125
|
+
const source = chars.length === 1
|
|
10126
|
+
? utils.escapeRegex(chars[0])
|
|
10127
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
10128
|
+
|
|
10129
|
+
return `${source}*`;
|
|
10130
|
+
};
|
|
10131
|
+
|
|
10132
|
+
const repeatedExtglobRecursion = pattern => {
|
|
10133
|
+
let depth = 0;
|
|
10134
|
+
let value = pattern.trim();
|
|
10135
|
+
let match = parseRepeatedExtglob(value);
|
|
10136
|
+
|
|
10137
|
+
while (match) {
|
|
10138
|
+
depth++;
|
|
10139
|
+
value = match.body.trim();
|
|
10140
|
+
match = parseRepeatedExtglob(value);
|
|
10141
|
+
}
|
|
10142
|
+
|
|
10143
|
+
return depth;
|
|
10144
|
+
};
|
|
10145
|
+
|
|
10146
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
10147
|
+
if (options.maxExtglobRecursion === false) {
|
|
10148
|
+
return { risky: false };
|
|
10149
|
+
}
|
|
10150
|
+
|
|
10151
|
+
const max =
|
|
10152
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
10153
|
+
? options.maxExtglobRecursion
|
|
10154
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
10155
|
+
|
|
10156
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
10157
|
+
|
|
10158
|
+
if (branches.length > 1) {
|
|
10159
|
+
if (
|
|
10160
|
+
branches.some(branch => branch === '') ||
|
|
10161
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
10162
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
10163
|
+
) {
|
|
10164
|
+
return { risky: true };
|
|
10165
|
+
}
|
|
10166
|
+
}
|
|
10167
|
+
|
|
10168
|
+
for (const branch of branches) {
|
|
10169
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
10170
|
+
if (safeOutput) {
|
|
10171
|
+
return { risky: true, safeOutput };
|
|
10172
|
+
}
|
|
10173
|
+
|
|
10174
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
10175
|
+
return { risky: true };
|
|
10176
|
+
}
|
|
10177
|
+
}
|
|
10178
|
+
|
|
10179
|
+
return { risky: false };
|
|
10180
|
+
};
|
|
10181
|
+
|
|
9887
10182
|
/**
|
|
9888
10183
|
* Parse the given input string.
|
|
9889
10184
|
* @param {String} input
|
|
@@ -10064,6 +10359,8 @@ function requireParse () {
|
|
|
10064
10359
|
token.prev = prev;
|
|
10065
10360
|
token.parens = state.parens;
|
|
10066
10361
|
token.output = state.output;
|
|
10362
|
+
token.startIndex = state.index;
|
|
10363
|
+
token.tokensIndex = tokens.length;
|
|
10067
10364
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
10068
10365
|
|
|
10069
10366
|
increment('parens');
|
|
@@ -10073,6 +10370,34 @@ function requireParse () {
|
|
|
10073
10370
|
};
|
|
10074
10371
|
|
|
10075
10372
|
const extglobClose = token => {
|
|
10373
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
10374
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
10375
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
10376
|
+
|
|
10377
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
10378
|
+
const safeOutput = analysis.safeOutput
|
|
10379
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
10380
|
+
: undefined;
|
|
10381
|
+
const open = tokens[token.tokensIndex];
|
|
10382
|
+
|
|
10383
|
+
open.type = 'text';
|
|
10384
|
+
open.value = literal;
|
|
10385
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
10386
|
+
|
|
10387
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
10388
|
+
tokens[i].value = '';
|
|
10389
|
+
tokens[i].output = '';
|
|
10390
|
+
delete tokens[i].suffix;
|
|
10391
|
+
}
|
|
10392
|
+
|
|
10393
|
+
state.output = token.output + open.output;
|
|
10394
|
+
state.backtrack = true;
|
|
10395
|
+
|
|
10396
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
10397
|
+
decrement('parens');
|
|
10398
|
+
return;
|
|
10399
|
+
}
|
|
10400
|
+
|
|
10076
10401
|
let output = token.close + (opts.capture ? ')' : '');
|
|
10077
10402
|
let rest;
|
|
10078
10403
|
|
|
@@ -11165,6 +11490,14 @@ function requirePicomatch$1 () {
|
|
|
11165
11490
|
* Compile a regular expression from the `state` object returned by the
|
|
11166
11491
|
* [parse()](#parse) method.
|
|
11167
11492
|
*
|
|
11493
|
+
* ```js
|
|
11494
|
+
* const picomatch = require('picomatch');
|
|
11495
|
+
* const state = picomatch.parse('*.js');
|
|
11496
|
+
* // picomatch.compileRe(state[, options]);
|
|
11497
|
+
*
|
|
11498
|
+
* console.log(picomatch.compileRe(state));
|
|
11499
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
11500
|
+
* ```
|
|
11168
11501
|
* @param {Object} `state`
|
|
11169
11502
|
* @param {Object} `options`
|
|
11170
11503
|
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
@@ -11200,10 +11533,10 @@ function requirePicomatch$1 () {
|
|
|
11200
11533
|
*
|
|
11201
11534
|
* ```js
|
|
11202
11535
|
* const picomatch = require('picomatch');
|
|
11203
|
-
*
|
|
11204
|
-
* // picomatch.compileRe(state[, options]);
|
|
11536
|
+
* // picomatch.makeRe(state[, options]);
|
|
11205
11537
|
*
|
|
11206
|
-
*
|
|
11538
|
+
* const result = picomatch.makeRe('*.js');
|
|
11539
|
+
* console.log(result);
|
|
11207
11540
|
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
11208
11541
|
* ```
|
|
11209
11542
|
* @param {String} `state` The object returned from the `.parse` method.
|
|
@@ -16120,6 +16453,8 @@ const bufferParsers = [
|
|
|
16120
16453
|
node.specifiers = convertNodeList(node, scope, buffer[position], buffer);
|
|
16121
16454
|
node.source = convertNode(node, scope, buffer[position + 1], buffer);
|
|
16122
16455
|
node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer);
|
|
16456
|
+
const phaseIndex = buffer[position + 3];
|
|
16457
|
+
node.phase = phaseIndex === 0 ? undefined : FIXED_STRINGS[phaseIndex];
|
|
16123
16458
|
},
|
|
16124
16459
|
function importDefaultSpecifier(node, position, buffer) {
|
|
16125
16460
|
const { scope } = node;
|
|
@@ -16131,6 +16466,8 @@ const bufferParsers = [
|
|
|
16131
16466
|
node.sourceAstNode = convertNode$1(buffer[position], buffer);
|
|
16132
16467
|
const optionsPosition = buffer[position + 1];
|
|
16133
16468
|
node.options = optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer);
|
|
16469
|
+
const phaseIndex = buffer[position + 2];
|
|
16470
|
+
node.phase = phaseIndex === 0 ? undefined : FIXED_STRINGS[phaseIndex];
|
|
16134
16471
|
},
|
|
16135
16472
|
function importNamespaceSpecifier(node, position, buffer) {
|
|
16136
16473
|
const { scope } = node;
|
|
@@ -16844,7 +17181,7 @@ const MISSING_EXPORT_SHIM_DESCRIPTION = {
|
|
|
16844
17181
|
identifier: null,
|
|
16845
17182
|
localName: MISSING_EXPORT_SHIM_VARIABLE
|
|
16846
17183
|
};
|
|
16847
|
-
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map(), importChain) {
|
|
17184
|
+
function getVariableForExportNameRecursive(target, name, importerForSideEffects, isExportAllSearch, searchedNamesAndModules = new Map(), importChain, sideEffectModules, exportOrReexportModules) {
|
|
16848
17185
|
const searchedModules = searchedNamesAndModules.get(name);
|
|
16849
17186
|
if (searchedModules) {
|
|
16850
17187
|
if (searchedModules.has(target)) {
|
|
@@ -16856,10 +17193,12 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
|
|
|
16856
17193
|
searchedNamesAndModules.set(name, new Set([target]));
|
|
16857
17194
|
}
|
|
16858
17195
|
return target.getVariableForExportName(name, {
|
|
17196
|
+
exportOrReexportModules,
|
|
16859
17197
|
importChain,
|
|
16860
17198
|
importerForSideEffects,
|
|
16861
17199
|
isExportAllSearch,
|
|
16862
|
-
searchedNamesAndModules
|
|
17200
|
+
searchedNamesAndModules,
|
|
17201
|
+
sideEffectModules
|
|
16863
17202
|
});
|
|
16864
17203
|
}
|
|
16865
17204
|
function getAndExtendSideEffectModules(variable, module) {
|
|
@@ -16916,6 +17255,7 @@ class Module {
|
|
|
16916
17255
|
this.isUserDefinedEntryPoint = false;
|
|
16917
17256
|
this.needsExportShim = false;
|
|
16918
17257
|
this.sideEffectDependenciesByVariable = new Map();
|
|
17258
|
+
this.sourcePhaseSources = new Set();
|
|
16919
17259
|
this.sourcesWithAttributes = new Map();
|
|
16920
17260
|
this.allExportsIncluded = false;
|
|
16921
17261
|
this.ast = null;
|
|
@@ -17179,7 +17519,7 @@ class Module {
|
|
|
17179
17519
|
}
|
|
17180
17520
|
return this.syntheticNamespace;
|
|
17181
17521
|
}
|
|
17182
|
-
getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules } = EMPTY_OBJECT) {
|
|
17522
|
+
getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = EMPTY_OBJECT) {
|
|
17183
17523
|
if (name[0] === '*') {
|
|
17184
17524
|
if (name.length === 1) {
|
|
17185
17525
|
// export * from './other'
|
|
@@ -17194,7 +17534,7 @@ class Module {
|
|
|
17194
17534
|
// export { foo } from './other'
|
|
17195
17535
|
const reexportDeclaration = this.reexportDescriptions.get(name);
|
|
17196
17536
|
if (reexportDeclaration) {
|
|
17197
|
-
const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id]);
|
|
17537
|
+
const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id], sideEffectModules, exportOrReexportModules);
|
|
17198
17538
|
if (!variable) {
|
|
17199
17539
|
return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
|
|
17200
17540
|
}
|
|
@@ -17204,6 +17544,10 @@ class Module {
|
|
|
17204
17544
|
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, (getNewSet)).add(this);
|
|
17205
17545
|
}
|
|
17206
17546
|
}
|
|
17547
|
+
if (this.info.moduleSideEffects) {
|
|
17548
|
+
sideEffectModules?.add(this);
|
|
17549
|
+
}
|
|
17550
|
+
exportOrReexportModules?.add(this);
|
|
17207
17551
|
return [variable];
|
|
17208
17552
|
}
|
|
17209
17553
|
const exportDeclaration = this.exportDescriptions.get(name);
|
|
@@ -17213,8 +17557,10 @@ class Module {
|
|
|
17213
17557
|
}
|
|
17214
17558
|
const name = exportDeclaration.localName;
|
|
17215
17559
|
const variable = this.traceVariable(name, {
|
|
17560
|
+
exportOrReexportModules,
|
|
17216
17561
|
importerForSideEffects,
|
|
17217
|
-
searchedNamesAndModules
|
|
17562
|
+
searchedNamesAndModules,
|
|
17563
|
+
sideEffectModules
|
|
17218
17564
|
});
|
|
17219
17565
|
if (!variable) {
|
|
17220
17566
|
return [null, { missingButExportExists: true }];
|
|
@@ -17223,6 +17569,8 @@ class Module {
|
|
|
17223
17569
|
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
17224
17570
|
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, (getNewSet)).add(this);
|
|
17225
17571
|
}
|
|
17572
|
+
sideEffectModules?.add(this);
|
|
17573
|
+
exportOrReexportModules?.add(this);
|
|
17226
17574
|
return [variable];
|
|
17227
17575
|
}
|
|
17228
17576
|
if (onlyExplicit) {
|
|
@@ -17233,6 +17581,19 @@ class Module {
|
|
|
17233
17581
|
this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, [...importChain, this.id]);
|
|
17234
17582
|
this.namespaceReexportsByName.set(name, foundNamespaceReexport);
|
|
17235
17583
|
if (foundNamespaceReexport[0]) {
|
|
17584
|
+
const [namespaceReexportVariable, namespaceReexportOptions] = foundNamespaceReexport;
|
|
17585
|
+
if (importerForSideEffects) {
|
|
17586
|
+
const { exportOrReexportModules, sideEffectModules } = namespaceReexportOptions;
|
|
17587
|
+
for (const module of exportOrReexportModules) {
|
|
17588
|
+
if (importerForSideEffects.alternativeReexportModules.has(namespaceReexportVariable)) {
|
|
17589
|
+
continue;
|
|
17590
|
+
}
|
|
17591
|
+
setAlternativeExporterIfCyclic(namespaceReexportVariable, importerForSideEffects, module);
|
|
17592
|
+
}
|
|
17593
|
+
for (const module of sideEffectModules) {
|
|
17594
|
+
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, namespaceReexportVariable, (getNewSet)).add(module);
|
|
17595
|
+
}
|
|
17596
|
+
}
|
|
17236
17597
|
return foundNamespaceReexport;
|
|
17237
17598
|
}
|
|
17238
17599
|
}
|
|
@@ -17436,7 +17797,7 @@ class Module {
|
|
|
17436
17797
|
transformFiles: this.transformFiles
|
|
17437
17798
|
};
|
|
17438
17799
|
}
|
|
17439
|
-
traceVariable(name, { importerForSideEffects, isExportAllSearch, searchedNamesAndModules } = EMPTY_OBJECT) {
|
|
17800
|
+
traceVariable(name, { importerForSideEffects, isExportAllSearch, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = EMPTY_OBJECT) {
|
|
17440
17801
|
const localVariable = this.scope.variables.get(name);
|
|
17441
17802
|
if (localVariable) {
|
|
17442
17803
|
return localVariable;
|
|
@@ -17447,7 +17808,7 @@ class Module {
|
|
|
17447
17808
|
if (otherModule instanceof Module && importDescription.name === '*') {
|
|
17448
17809
|
return otherModule.namespace;
|
|
17449
17810
|
}
|
|
17450
|
-
const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id]);
|
|
17811
|
+
const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id], sideEffectModules, exportOrReexportModules);
|
|
17451
17812
|
if (!declaration) {
|
|
17452
17813
|
return this.error(logMissingExport(importDescription.name, this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
|
|
17453
17814
|
}
|
|
@@ -17566,16 +17927,19 @@ class Module {
|
|
|
17566
17927
|
if (this.scope.variables.has(localName) || this.importDescriptions.has(localName)) {
|
|
17567
17928
|
this.error(logRedeclarationError(localName), specifier.local.start);
|
|
17568
17929
|
}
|
|
17569
|
-
const name =
|
|
17570
|
-
?
|
|
17571
|
-
: specifier instanceof
|
|
17572
|
-
? '
|
|
17573
|
-
: specifier
|
|
17574
|
-
?
|
|
17575
|
-
: specifier.imported
|
|
17930
|
+
const name = node.phase === 'source'
|
|
17931
|
+
? SOURCE_PHASE_IMPORT
|
|
17932
|
+
: specifier instanceof ImportDefaultSpecifier
|
|
17933
|
+
? 'default'
|
|
17934
|
+
: specifier instanceof ImportNamespaceSpecifier
|
|
17935
|
+
? '*'
|
|
17936
|
+
: specifier.imported instanceof Identifier
|
|
17937
|
+
? specifier.imported.name
|
|
17938
|
+
: specifier.imported.value;
|
|
17576
17939
|
this.importDescriptions.set(localName, {
|
|
17577
17940
|
module: null, // filled in later
|
|
17578
17941
|
name,
|
|
17942
|
+
phase: node.phase === 'source' ? 'source' : 'instance',
|
|
17579
17943
|
source,
|
|
17580
17944
|
start: specifier.start
|
|
17581
17945
|
});
|
|
@@ -17648,6 +18012,9 @@ class Module {
|
|
|
17648
18012
|
else {
|
|
17649
18013
|
this.sourcesWithAttributes.set(source, parsedAttributes);
|
|
17650
18014
|
}
|
|
18015
|
+
if (declaration.phase === 'source') {
|
|
18016
|
+
this.sourcePhaseSources.add(source);
|
|
18017
|
+
}
|
|
17651
18018
|
}
|
|
17652
18019
|
getImportedJsxFactoryVariable(baseName, nodeStart, importSource) {
|
|
17653
18020
|
const { id } = this.resolvedIds[importSource];
|
|
@@ -17662,6 +18029,8 @@ class Module {
|
|
|
17662
18029
|
let foundSyntheticDeclaration = null;
|
|
17663
18030
|
const foundInternalDeclarations = new Map();
|
|
17664
18031
|
const foundExternalDeclarations = new Set();
|
|
18032
|
+
const sideEffectModules = new Set();
|
|
18033
|
+
const exportOrReexportModules = new Set();
|
|
17665
18034
|
for (const module of this.exportAllModules) {
|
|
17666
18035
|
// Synthetic namespaces should not hide "regular" exports of the same name
|
|
17667
18036
|
if (module.info.syntheticNamedExports === name) {
|
|
@@ -17670,7 +18039,7 @@ class Module {
|
|
|
17670
18039
|
const [variable, options] = getVariableForExportNameRecursive(module, name, importerForSideEffects, true,
|
|
17671
18040
|
// We are creating a copy to handle the case where the same binding is
|
|
17672
18041
|
// imported through different namespace reexports gracefully
|
|
17673
|
-
copyNameToModulesMap(searchedNamesAndModules), importChain);
|
|
18042
|
+
copyNameToModulesMap(searchedNamesAndModules), importChain, sideEffectModules, exportOrReexportModules);
|
|
17674
18043
|
if (module instanceof ExternalModule || options?.indirectExternal) {
|
|
17675
18044
|
foundExternalDeclarations.add(variable);
|
|
17676
18045
|
}
|
|
@@ -17687,7 +18056,7 @@ class Module {
|
|
|
17687
18056
|
const foundDeclarationList = [...foundInternalDeclarations];
|
|
17688
18057
|
const usedDeclaration = foundDeclarationList[0][0];
|
|
17689
18058
|
if (foundDeclarationList.length === 1) {
|
|
17690
|
-
return [usedDeclaration];
|
|
18059
|
+
return [usedDeclaration, { exportOrReexportModules, sideEffectModules }];
|
|
17691
18060
|
}
|
|
17692
18061
|
this.options.onLog(LOGLEVEL_WARN, logNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
|
|
17693
18062
|
// TODO we are pretending it was not found while it should behave like "undefined"
|
|
@@ -17699,10 +18068,13 @@ class Module {
|
|
|
17699
18068
|
if (foundDeclarationList.length > 1) {
|
|
17700
18069
|
this.options.onLog(LOGLEVEL_WARN, logAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
|
|
17701
18070
|
}
|
|
17702
|
-
return [
|
|
18071
|
+
return [
|
|
18072
|
+
usedDeclaration,
|
|
18073
|
+
{ exportOrReexportModules, indirectExternal: true, sideEffectModules }
|
|
18074
|
+
];
|
|
17703
18075
|
}
|
|
17704
18076
|
if (foundSyntheticDeclaration) {
|
|
17705
|
-
return [foundSyntheticDeclaration];
|
|
18077
|
+
return [foundSyntheticDeclaration, { exportOrReexportModules, sideEffectModules }];
|
|
17706
18078
|
}
|
|
17707
18079
|
return [null];
|
|
17708
18080
|
}
|
|
@@ -17861,6 +18233,9 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
17861
18233
|
? externalChunkByModule.get(module)
|
|
17862
18234
|
: chunkByModule.get(module)).variableName);
|
|
17863
18235
|
}
|
|
18236
|
+
else if (module instanceof ExternalModule && variable.isSourcePhase) {
|
|
18237
|
+
variable.setRenderNames(null, getSafeName(module.suggestedVariableName + '__source', usedNames, variable.forbiddenNames));
|
|
18238
|
+
}
|
|
17864
18239
|
else if (module instanceof ExternalModule && name === 'default') {
|
|
17865
18240
|
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
17866
18241
|
? module.suggestedVariableName + '__default'
|
|
@@ -18907,10 +19282,14 @@ class Chunk {
|
|
|
18907
19282
|
const module = variable.module;
|
|
18908
19283
|
let dependency;
|
|
18909
19284
|
let imported;
|
|
19285
|
+
const isSourcePhase = module instanceof ExternalModule && variable.isSourcePhase;
|
|
18910
19286
|
if (module instanceof ExternalModule) {
|
|
18911
19287
|
dependency = this.externalChunkByModule.get(module);
|
|
18912
19288
|
imported = variable.name;
|
|
18913
|
-
if (
|
|
19289
|
+
if (!isSourcePhase &&
|
|
19290
|
+
imported !== 'default' &&
|
|
19291
|
+
imported !== '*' &&
|
|
19292
|
+
interop(module.id) === 'defaultOnly') {
|
|
18914
19293
|
return error(logUnexpectedNamedImport(module.id, imported, false));
|
|
18915
19294
|
}
|
|
18916
19295
|
}
|
|
@@ -18920,7 +19299,8 @@ class Chunk {
|
|
|
18920
19299
|
}
|
|
18921
19300
|
getOrCreate(importsByDependency, dependency, getNewArray).push({
|
|
18922
19301
|
imported,
|
|
18923
|
-
local: variable.getName(this.snippets.getPropertyAccess)
|
|
19302
|
+
local: variable.getName(this.snippets.getPropertyAccess),
|
|
19303
|
+
phase: isSourcePhase ? 'source' : 'instance'
|
|
18924
19304
|
});
|
|
18925
19305
|
}
|
|
18926
19306
|
return importsByDependency;
|
|
@@ -19071,6 +19451,9 @@ class Chunk {
|
|
|
19071
19451
|
const reexports = reexportSpecifiers.get(dependency) || null;
|
|
19072
19452
|
const namedExportsMode = dependency instanceof ExternalChunk || dependency.exportMode !== 'default';
|
|
19073
19453
|
const importPath = dependency.getImportPath(fileName);
|
|
19454
|
+
// Separate source-phase imports from regular imports
|
|
19455
|
+
const sourcePhaseImport = imports?.find(index => index.phase === 'source');
|
|
19456
|
+
const instanceImports = imports?.filter(index => index.phase !== 'source') ?? null;
|
|
19074
19457
|
renderedDependencies.set(dependency, {
|
|
19075
19458
|
attributes: dependency instanceof ExternalChunk
|
|
19076
19459
|
? dependency.getImportAttributes(this.snippets)
|
|
@@ -19080,12 +19463,13 @@ class Chunk {
|
|
|
19080
19463
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
19081
19464
|
getGlobalName(dependency, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onLog),
|
|
19082
19465
|
importPath,
|
|
19083
|
-
imports,
|
|
19466
|
+
imports: instanceImports && instanceImports.length > 0 ? instanceImports : null,
|
|
19084
19467
|
isChunk: dependency instanceof Chunk,
|
|
19085
19468
|
name: dependency.variableName,
|
|
19086
19469
|
namedExportsMode,
|
|
19087
19470
|
namespaceVariableName: dependency.namespaceVariableName,
|
|
19088
|
-
reexports
|
|
19471
|
+
reexports,
|
|
19472
|
+
sourcePhaseImport: sourcePhaseImport?.local
|
|
19089
19473
|
});
|
|
19090
19474
|
}
|
|
19091
19475
|
return (this.renderedDependencies = renderedDependencies);
|
|
@@ -21519,13 +21903,16 @@ class ModuleLoader {
|
|
|
21519
21903
|
return loadNewModulesPromise;
|
|
21520
21904
|
}
|
|
21521
21905
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
21522
|
-
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => {
|
|
21906
|
+
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ argument, node }, resolvedId]) => {
|
|
21523
21907
|
if (resolvedId === null)
|
|
21524
21908
|
return null;
|
|
21525
21909
|
if (typeof resolvedId === 'string') {
|
|
21526
21910
|
node.resolution = resolvedId;
|
|
21527
21911
|
return null;
|
|
21528
21912
|
}
|
|
21913
|
+
if (node.phase === 'source' && !resolvedId.external) {
|
|
21914
|
+
return error(logNonExternalSourcePhaseImport(typeof argument === 'string' ? argument : relativeId(resolvedId.id), module.id));
|
|
21915
|
+
}
|
|
21529
21916
|
return (node.resolution = await this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId));
|
|
21530
21917
|
})));
|
|
21531
21918
|
for (const dependency of dependencies) {
|
|
@@ -21605,7 +21992,12 @@ class ModuleLoader {
|
|
|
21605
21992
|
return this.fetchModule(resolvedId, importer, false, false);
|
|
21606
21993
|
}
|
|
21607
21994
|
async fetchStaticDependencies(module, resolveStaticDependencyPromises) {
|
|
21608
|
-
for (const dependency of await Promise.all(resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => resolveStaticDependencyPromise.then(([source, resolvedId]) =>
|
|
21995
|
+
for (const dependency of await Promise.all(resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => resolveStaticDependencyPromise.then(([source, resolvedId]) => {
|
|
21996
|
+
if (module.sourcePhaseSources.has(source) && !resolvedId.external) {
|
|
21997
|
+
return error(logNonExternalSourcePhaseImport(source, module.id));
|
|
21998
|
+
}
|
|
21999
|
+
return this.fetchResolvedDependency(source, module.id, resolvedId);
|
|
22000
|
+
})))) {
|
|
21609
22001
|
module.dependencies.add(dependency);
|
|
21610
22002
|
dependency.importers.push(module.id);
|
|
21611
22003
|
}
|
|
@@ -22874,7 +23266,7 @@ class Graph {
|
|
|
22874
23266
|
warnForMissingExports() {
|
|
22875
23267
|
for (const module of this.modules) {
|
|
22876
23268
|
for (const importDescription of module.importDescriptions.values()) {
|
|
22877
|
-
if (importDescription.name !== '*') {
|
|
23269
|
+
if (importDescription.name !== '*' && importDescription.phase !== 'source') {
|
|
22878
23270
|
const [variable, options] = importDescription.module.getVariableForExportName(importDescription.name, { importChain: [module.id] });
|
|
22879
23271
|
if (!variable) {
|
|
22880
23272
|
module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
|