(chief: ConfigurationChief)
| 83 | }; |
| 84 | |
| 85 | export const getModuleSourcePathHandler = (chief: ConfigurationChief) => { |
| 86 | const toSourceMapCache = new Map<string, string | undefined>(); |
| 87 | |
| 88 | return (filePath: string) => { |
| 89 | if (!isInternal(filePath) || hasTSExt.test(filePath)) return; |
| 90 | if (toSourceMapCache.has(filePath)) return toSourceMapCache.get(filePath); |
| 91 | const workspace = chief.findWorkspaceByFilePath(filePath); |
| 92 | let result: string | undefined; |
| 93 | if (workspace?.sourceMaps) { |
| 94 | for (const { srcDir, outDir } of workspace.sourceMaps) { |
| 95 | if (!(isUnderOutDir(filePath, outDir) || srcDir === outDir)) continue; |
| 96 | const basePath = (srcDir + filePath.slice(outDir.length)).replace(matchExt, ''); |
| 97 | const srcFilePath = findFileWithExtensions(basePath, sourceExtensions); |
| 98 | if (srcFilePath && srcFilePath !== filePath) { |
| 99 | debugLog('*', `Source mapping ${toRelative(filePath, chief.cwd)} → ${toRelative(srcFilePath, chief.cwd)}`); |
| 100 | result = srcFilePath; |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | toSourceMapCache.set(filePath, result); |
| 106 | return result; |
| 107 | }; |
| 108 | }; |
| 109 | |
| 110 | export const getToSourcePathsHandler = (chief: ConfigurationChief) => { |
| 111 | return async (specifiers: Set<string>, dir: string, extensions = defaultExtensions, label: string) => { |
no test coverage detected