File size: 478 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// @ts-check

import path from 'node:path'
import ts from 'typescript'

const tsconfig = ts.readConfigFile(
  path.resolve(__dirname, '..', 'tsconfig.json'),
  ts.sys.readFile,
).config

export const dynamicAliases = Object.entries(
  tsconfig.compilerOptions.paths || {},
).reduce((aliases, [key, [value]]) => {
  const aliasKey = key.replace('/*', '')
  aliases[aliasKey] = path.resolve(value.replace('/*', ''))
  return aliases
}, /** @type {Record<string, string>} */ ({}))