* Reads import paths from tsconfig.json. This file is used by VSCode for * Intellisense/auto-import. Rather than duplicate and require updating both * files, we can read from it directly. JSConfig format looks like: * { compilerOptions: { paths: { * '#foo/*': ['./src/foo/*'], * '#bar/*': ['
()
| 24 | * @return {!{[key: string]: string}} |
| 25 | */ |
| 26 | function readJsconfigPaths() { |
| 27 | if (!tsConfigPaths) { |
| 28 | const tsConfig = JSON.parse(fs.readFileSync(TSCONFIG_PATH, 'utf8')); |
| 29 | const aliasPaths = tsConfig.compilerOptions.paths; |
| 30 | |
| 31 | const stripSuffix = (s) => s.replace(/\/\*$/, ''); |
| 32 | // eslint-disable-next-line local/no-deep-destructuring |
| 33 | const aliases = Object.entries(aliasPaths).map(([alias, [dest]]) => [ |
| 34 | stripSuffix(alias), |
| 35 | stripSuffix(dest), |
| 36 | ]); |
| 37 | |
| 38 | tsConfigPaths = Object.fromEntries(aliases); |
| 39 | } |
| 40 | |
| 41 | return tsConfigPaths; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Remap external modules that rely on React if building for Preact. |
no test coverage detected