(filePath: string, context: ResolutionContext)
| 301 | } |
| 302 | |
| 303 | function getFileExportIndex(filePath: string, context: ResolutionContext): FileExportIndex { |
| 304 | let perFile = fileExportIndexes.get(context); |
| 305 | if (!perFile) { |
| 306 | perFile = new Map(); |
| 307 | fileExportIndexes.set(context, perFile); |
| 308 | } |
| 309 | let idx = perFile.get(filePath); |
| 310 | if (!idx) { |
| 311 | idx = { byName: new Map(), defaultComponent: undefined, defaultFnClass: undefined, members: new Map() }; |
| 312 | // Python has no export keyword: every module-level def is importable, and |
| 313 | // the extractor never flags one isExported. Without this a Python named |
| 314 | // import could only ever resolve through the bare-name matcher. |
| 315 | const exported = PYTHON_MODULE_FILE.test(filePath) |
| 316 | ? context.getNodesInFile(filePath).filter((n) => n.isExported || isPythonModuleLevelDef(n)) |
| 317 | : context.getExportedNodesInFile?.(filePath) ?? context.getNodesInFile(filePath).filter((n) => n.isExported); |
| 318 | const jsFamily = JS_FAMILY_FILE.test(filePath); |
| 319 | for (const n of exported) { |
| 320 | if (jsFamily && n.qualifiedName !== n.name) { |
| 321 | if (!idx.members.has(n.name)) idx.members.set(n.name, n); |
| 322 | continue; |
| 323 | } |
| 324 | if (!idx.byName.has(n.name)) idx.byName.set(n.name, n); |
| 325 | if (idx.defaultComponent === undefined && n.kind === 'component') idx.defaultComponent = n; |
| 326 | if (idx.defaultFnClass === undefined && (n.kind === 'function' || n.kind === 'class')) idx.defaultFnClass = n; |
| 327 | } |
| 328 | perFile.set(filePath, idx); |
| 329 | } |
| 330 | return idx; |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * `nodes` with the members of something else in their JS/TS file (an |
no test coverage detected