MCPcopy
hub / github.com/rollup/rollup / traceVariable

Method traceVariable

src/Module.ts:987–1043  ·  view source on GitHub ↗
(
		name: string,
		{
			importerForSideEffects,
			isExportAllSearch,
			searchedNamesAndModules,
			sideEffectModules,
			exportOrReexportModules
		}: {
			importerForSideEffects?: Module;
			isExportAllSearch?: boolean;
			searchedNamesAndModules?: Map<string, Set<Module | ExternalModule>>;
			sideEffectModules?: Set<Module>;
			exportOrReexportModules?: Set<Module>;
		} = EMPTY_OBJECT
	)

Source from the content-addressed store, hash-verified

985 }
986
987 traceVariable(
988 name: string,
989 {
990 importerForSideEffects,
991 isExportAllSearch,
992 searchedNamesAndModules,
993 sideEffectModules,
994 exportOrReexportModules
995 }: {
996 importerForSideEffects?: Module;
997 isExportAllSearch?: boolean;
998 searchedNamesAndModules?: Map<string, Set<Module | ExternalModule>>;
999 sideEffectModules?: Set<Module>;
1000 exportOrReexportModules?: Set<Module>;
1001 } = EMPTY_OBJECT
1002 ): Variable | null {
1003 const localVariable = this.scope.variables.get(name);
1004 if (localVariable) {
1005 return localVariable;
1006 }
1007
1008 const importDescription = this.importDescriptions.get(name);
1009 if (importDescription) {
1010 const otherModule = importDescription.module;
1011
1012 if (otherModule instanceof Module && importDescription.name === '*') {
1013 return otherModule.namespace;
1014 }
1015
1016 const [declaration, options] = getVariableForExportNameRecursive(
1017 otherModule,
1018 importDescription.name,
1019 importerForSideEffects || this,
1020 isExportAllSearch,
1021 searchedNamesAndModules,
1022 [this.id],
1023 sideEffectModules,
1024 exportOrReexportModules
1025 );
1026
1027 if (!declaration) {
1028 return this.error(
1029 logMissingExport(
1030 importDescription.name,
1031 this.id,
1032 otherModule.id,
1033 !!options?.missingButExportExists
1034 ),
1035 importDescription.start
1036 );
1037 }
1038
1039 return declaration;
1040 }
1041
1042 return null;
1043 }
1044

Callers 2

findVariableMethod · 0.80

Calls 4

errorMethod · 0.95
logMissingExportFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected