6
6
"use strict" ;
7
7
8
8
const path = require ( "path" ) ;
9
+ const { join, normalize } = require ( "./util/path" ) ;
9
10
10
11
/** @typedef {import("./Resolver") } Resolver */
11
12
/** @typedef {import("./Resolver").FileSystem } FileSystem */
@@ -65,7 +66,7 @@ function getAbsoluteMappingEntries(paths, baseUrl) {
65
66
const mappings = paths [ pattern ] ;
66
67
// const aliasName = pattern.replace(/\/\*$/, "");
67
68
// Convert targets like "dir/*" -> "dir"
68
- const aliasTargets = mappings . map ( ( mapping ) => path . join ( baseUrl , mapping ) ) ;
69
+ const aliasTargets = mappings . map ( ( mapping ) => join ( baseUrl , mapping ) ) ;
69
70
if ( aliasTargets . length > 0 ) {
70
71
absolutePaths . push ( { name : pattern , alias : aliasTargets } ) ;
71
72
}
@@ -117,7 +118,7 @@ async function loadTsconfigFromExtends(
117
118
}
118
119
119
120
const currentDir = path . dirname ( configFilePath ) ;
120
- let extendedConfigPath = path . join ( currentDir , extendedConfigValue ) ;
121
+ let extendedConfigPath = join ( currentDir , extendedConfigValue ) ;
121
122
122
123
// Check if file exists, if not try node_modules
123
124
const exists = await new Promise ( ( resolve ) => {
@@ -130,10 +131,9 @@ async function loadTsconfigFromExtends(
130
131
extendedConfigValue . includes ( "/" ) &&
131
132
extendedConfigValue . includes ( "." )
132
133
) {
133
- extendedConfigPath = path . join (
134
+ extendedConfigPath = join (
134
135
currentDir ,
135
- "node_modules" ,
136
- extendedConfigValue ,
136
+ normalize ( `node_modules/${ extendedConfigValue } ` ) ,
137
137
) ;
138
138
}
139
139
@@ -147,7 +147,7 @@ async function loadTsconfigFromExtends(
147
147
// but we need to update it so it is relative to the original tsconfig being loaded
148
148
if ( compilerOptions . baseUrl ) {
149
149
const extendsDir = path . dirname ( extendedConfigValue ) ;
150
- compilerOptions . baseUrl = path . join ( extendsDir , compilerOptions . baseUrl ) ;
150
+ compilerOptions . baseUrl = join ( extendsDir , compilerOptions . baseUrl ) ;
151
151
}
152
152
153
153
return /** @type {Tsconfig } */ ( config ) ;
@@ -238,7 +238,7 @@ async function readTsconfigCompilerOptions(fileSystem, absTsconfigPath) {
238
238
if ( ! baseUrl ) {
239
239
baseUrl = path . dirname ( absTsconfigPath ) ;
240
240
} else if ( ! path . isAbsolute ( baseUrl ) ) {
241
- baseUrl = path . join ( path . dirname ( absTsconfigPath ) , baseUrl ) ;
241
+ baseUrl = join ( path . dirname ( absTsconfigPath ) , baseUrl ) ;
242
242
}
243
243
244
244
const paths = compilerOptions . paths || { } ;
@@ -295,7 +295,7 @@ async function loadTsconfigPathsData(
295
295
try {
296
296
const absTsconfigPath = path . isAbsolute ( configFile )
297
297
? configFile
298
- : path . join ( context , configFile ) ;
298
+ : join ( context , configFile ) ;
299
299
300
300
const result = await readTsconfigCompilerOptions (
301
301
fileSystem ,
0 commit comments