@richapps/ong 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +12 -7
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -13,21 +13,18 @@ export function resolveTsconfigPaths(tsconfig, workspaceRoot) {
|
|
|
13
13
|
let paths;
|
|
14
14
|
let baseUrl = '.';
|
|
15
15
|
// Walk the extends chain to find paths
|
|
16
|
-
|
|
16
|
+
// Collect baseUrl from each level; paths from the first config that defines them
|
|
17
|
+
const configChain = [];
|
|
18
|
+
while (configPath) {
|
|
17
19
|
if (!existsSync(configPath))
|
|
18
20
|
break;
|
|
19
21
|
const raw = readFileSync(configPath, 'utf-8');
|
|
20
22
|
// Strip comments (single-line // and multi-line /* */)
|
|
21
23
|
const stripped = raw.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
22
24
|
const config = JSON.parse(stripped);
|
|
23
|
-
|
|
24
|
-
if (compilerOptions.paths) {
|
|
25
|
-
paths = compilerOptions.paths;
|
|
26
|
-
baseUrl = compilerOptions.baseUrl ?? '.';
|
|
27
|
-
}
|
|
25
|
+
configChain.push(config);
|
|
28
26
|
if (config.extends) {
|
|
29
27
|
configPath = resolve(configPath, '..', config.extends);
|
|
30
|
-
// Add .json if not present
|
|
31
28
|
if (!configPath.endsWith('.json'))
|
|
32
29
|
configPath += '.json';
|
|
33
30
|
}
|
|
@@ -35,6 +32,14 @@ export function resolveTsconfigPaths(tsconfig, workspaceRoot) {
|
|
|
35
32
|
break;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
35
|
+
// Resolve inherited values: child overrides parent
|
|
36
|
+
for (let i = configChain.length - 1; i >= 0; i--) {
|
|
37
|
+
const compilerOptions = configChain[i].compilerOptions ?? {};
|
|
38
|
+
if (compilerOptions.baseUrl !== undefined)
|
|
39
|
+
baseUrl = compilerOptions.baseUrl;
|
|
40
|
+
if (compilerOptions.paths !== undefined)
|
|
41
|
+
paths = compilerOptions.paths;
|
|
42
|
+
}
|
|
38
43
|
if (!paths)
|
|
39
44
|
return aliases;
|
|
40
45
|
const baseDir = resolve(workspaceRoot, baseUrl);
|