( existingTsConfigFile: any, tsConfigDir: string, matchedTargets: readonly TsConfigMatchedTarget[], baseTsFiles: readonly string[], )
| 229 | } |
| 230 | |
| 231 | function computeTsCompilerOptions( |
| 232 | existingTsConfigFile: any, |
| 233 | tsConfigDir: string, |
| 234 | matchedTargets: readonly TsConfigMatchedTarget[], |
| 235 | baseTsFiles: readonly string[], |
| 236 | ): unknown { |
| 237 | let compilerOptions: any; |
| 238 | if (existingTsConfigFile) { |
| 239 | compilerOptions = { ...existingTsConfigFile }; |
| 240 | } else { |
| 241 | compilerOptions = {}; |
| 242 | } |
| 243 | |
| 244 | compilerOptions.paths = {}; |
| 245 | const rootDirs: string[] = []; |
| 246 | let valdiCoreTarget: TargetDescription | undefined; |
| 247 | for (const matchedTarget of matchedTargets) { |
| 248 | const targetRootDirs = matchedTarget.target.paths.map(p => relativePathTo(tsConfigDir, path.dirname(p))); |
| 249 | |
| 250 | for (const targetRootDir of targetRootDirs) { |
| 251 | if (!rootDirs.includes(targetRootDir)) { |
| 252 | rootDirs.push(targetRootDir); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | const selfName = matchedTarget.target.label.name ?? ''; |
| 257 | const selfInclude = `${selfName}/*`; |
| 258 | |
| 259 | const selfImportPaths = matchedTarget.target.paths.map(p => `${relativePathTo(tsConfigDir, p)}/*`); |
| 260 | |
| 261 | compilerOptions.paths[selfInclude] = selfImportPaths; |
| 262 | |
| 263 | for (const dependency of matchedTarget.dependencies) { |
| 264 | if (!dependency.label.name || compilerOptions.paths[dependency.label.name]) { |
| 265 | // Already present |
| 266 | continue; |
| 267 | } |
| 268 | |
| 269 | if (dependency.label.name === 'valdi_core') { |
| 270 | valdiCoreTarget = dependency; |
| 271 | } |
| 272 | |
| 273 | const importPaths = dependency.paths.map(p => `${relativePathTo(tsConfigDir, p)}/*`); |
| 274 | |
| 275 | const key = `${dependency.label.name}/*`; |
| 276 | compilerOptions.paths[key] = importPaths; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | if (valdiCoreTarget) { |
| 281 | // Add tslib dep |
| 282 | compilerOptions.paths['tslib'] = valdiCoreTarget.paths.map(p => |
| 283 | relativePathTo(tsConfigDir, path.join(p, 'src/tslib')), |
| 284 | ); |
| 285 | } |
| 286 | |
| 287 | compilerOptions.types = baseTsFiles.map(p => relativePathTo(tsConfigDir, removeTsFileExtension(p))); |
| 288 |
no test coverage detected