MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / buildTsconfigAliases

Function buildTsconfigAliases

packages/tooling/src/vite.ts:95–121  ·  view source on GitHub ↗
(projectDir: string)

Source from the content-addressed store, hash-verified

93}
94
95export function buildTsconfigAliases(projectDir: string): Array<{ find: RegExp; replacement: string }> {
96 const tsconfigPath = ts.findConfigFile(projectDir, ts.sys.fileExists);
97 if (!tsconfigPath) {
98 return [];
99 }
100 const { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
101 if (error || !config) {
102 return [];
103 }
104 const parsed = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(tsconfigPath));
105 const aliases: Array<{ find: RegExp; replacement: string }> = [];
106 for (const [pattern, targets] of Object.entries(parsed.options.paths ?? {})) {
107 const target = targets?.[0];
108 if (!target) {
109 continue;
110 }
111 if (pattern.endsWith('/*') && target.endsWith('/*')) {
112 aliases.push({
113 find: new RegExp(`^${escapeRegExp(pattern.slice(0, -2))}/(.*)$`),
114 replacement: `${target.slice(0, -2)}/$1`
115 });
116 } else {
117 aliases.push({ find: new RegExp(`^${escapeRegExp(pattern)}$`), replacement: target });
118 }
119 }
120 return aliases;
121}
122
123export function defaultBuildUserConfig(projectDir: string = process.cwd()): UserConfig {
124 return {

Callers 2

defineVitestConfigFunction · 0.90
defaultBuildUserConfigFunction · 0.85

Calls 4

escapeRegExpFunction · 0.85
entriesMethod · 0.45
pushMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected