MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isJsBareModuleRef

Function isJsBareModuleRef

src/resolution/import-resolver.ts:2968–2972  ·  view source on GitHub ↗

* A JS/TS `imports` reference to the module of an import named by one bare * segment — `'config'` in `import { DEFAULT_THEME_MODE } from 'config'` under * `"baseUrl": "src"`. Shaped like a package, it names a file only when * resolveImportPath finds one (the app's `baseUrl` or catch-all `paths`,

(ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

2966 * binds locally is that binding, not the module, and resolves as one.
2967 */
2968function isJsBareModuleRef(ref: UnresolvedRef, context: ResolutionContext): boolean {
2969 if (ref.referenceKind !== 'imports' || !ESM_IMPORT_LANGUAGES.has(ref.language) || isJsPathSpecifier(ref.referenceName)) return false;
2970 const imports = context.getImportMappings(ref.filePath, ref.language);
2971 return importsFrom(imports, ref.referenceName).length > 0 && importsBoundTo(imports, ref.referenceName).length === 0;
2972}
2973
2974/**
2975 * The file a JS/TS module reference names, the way resolveViaImport reads it:

Callers 1

jsModuleFileFunction · 0.85

Calls 5

importsFromFunction · 0.90
importsBoundToFunction · 0.90
isJsPathSpecifierFunction · 0.85
hasMethod · 0.80
getImportMappingsMethod · 0.80

Tested by

no test coverage detected