66"use strict" ;
77
88const path = require ( "path" ) ;
9+ const { join, normalize } = require ( "./util/path" ) ;
910
1011/** @typedef {import("./Resolver") } Resolver */
1112/** @typedef {import("./Resolver").FileSystem } FileSystem */
@@ -65,7 +66,7 @@ function getAbsoluteMappingEntries(paths, baseUrl) {
6566 const mappings = paths [ pattern ] ;
6667 // const aliasName = pattern.replace(/\/\*$/, "");
6768 // Convert targets like "dir/*" -> "dir"
68- const aliasTargets = mappings . map ( ( mapping ) => path . join ( baseUrl , mapping ) ) ;
69+ const aliasTargets = mappings . map ( ( mapping ) => join ( baseUrl , mapping ) ) ;
6970 if ( aliasTargets . length > 0 ) {
7071 absolutePaths . push ( { name : pattern , alias : aliasTargets } ) ;
7172 }
@@ -117,7 +118,7 @@ async function loadTsconfigFromExtends(
117118 }
118119
119120 const currentDir = path . dirname ( configFilePath ) ;
120- let extendedConfigPath = path . join ( currentDir , extendedConfigValue ) ;
121+ let extendedConfigPath = join ( currentDir , extendedConfigValue ) ;
121122
122123 // Check if file exists, if not try node_modules
123124 const exists = await new Promise ( ( resolve ) => {
@@ -130,10 +131,9 @@ async function loadTsconfigFromExtends(
130131 extendedConfigValue . includes ( "/" ) &&
131132 extendedConfigValue . includes ( "." )
132133 ) {
133- extendedConfigPath = path . join (
134+ extendedConfigPath = join (
134135 currentDir ,
135- "node_modules" ,
136- extendedConfigValue ,
136+ normalize ( `node_modules/${ extendedConfigValue } ` ) ,
137137 ) ;
138138 }
139139
@@ -147,7 +147,7 @@ async function loadTsconfigFromExtends(
147147 // but we need to update it so it is relative to the original tsconfig being loaded
148148 if ( compilerOptions . baseUrl ) {
149149 const extendsDir = path . dirname ( extendedConfigValue ) ;
150- compilerOptions . baseUrl = path . join ( extendsDir , compilerOptions . baseUrl ) ;
150+ compilerOptions . baseUrl = join ( extendsDir , compilerOptions . baseUrl ) ;
151151 }
152152
153153 return /** @type {Tsconfig } */ ( config ) ;
@@ -238,7 +238,7 @@ async function readTsconfigCompilerOptions(fileSystem, absTsconfigPath) {
238238 if ( ! baseUrl ) {
239239 baseUrl = path . dirname ( absTsconfigPath ) ;
240240 } else if ( ! path . isAbsolute ( baseUrl ) ) {
241- baseUrl = path . join ( path . dirname ( absTsconfigPath ) , baseUrl ) ;
241+ baseUrl = join ( path . dirname ( absTsconfigPath ) , baseUrl ) ;
242242 }
243243
244244 const paths = compilerOptions . paths || { } ;
@@ -295,7 +295,7 @@ async function loadTsconfigPathsData(
295295 try {
296296 const absTsconfigPath = path . isAbsolute ( configFile )
297297 ? configFile
298- : path . join ( context , configFile ) ;
298+ : join ( context , configFile ) ;
299299
300300 const result = await readTsconfigCompilerOptions (
301301 fileSystem ,
0 commit comments