@@ -91,7 +91,9 @@ export class TypescriptCompiler {
9191 throw new Error ( `Invalid TypeScript file: "${ key } ".` ) ;
9292 }
9393
94- result . files [ key ] . name = path . normalize ( result . files [ key ] . name ) ;
94+ result . files [ key ] . name = path . posix . normalize (
95+ result . files [ key ] . name ,
96+ ) ;
9597 } ) ;
9698
9799 let hasExternalDependencies = false ;
@@ -121,13 +123,13 @@ export class TypescriptCompiler {
121123 const host = {
122124 getScriptFileNames : ( ) => Object . keys ( result . files ) ,
123125 getScriptVersion : ( fileName ) => {
124- fileName = path . normalize ( fileName ) ;
126+ fileName = path . posix . normalize ( fileName . replace ( / \\ / g , "/" ) ) ;
125127 const file =
126128 result . files [ fileName ] || this . getLibraryFile ( fileName ) ;
127129 return file ?. version ?. toString ( ) ;
128130 } ,
129131 getScriptSnapshot : ( fileName ) => {
130- fileName = path . normalize ( fileName ) ;
132+ fileName = path . posix . normalize ( fileName . replace ( / \\ / g , "/" ) ) ;
131133 const file =
132134 result . files [ fileName ] || this . getLibraryFile ( fileName ) ;
133135
@@ -317,10 +319,20 @@ export class TypescriptCompiler {
317319 }
318320
319321 private resolvePath ( containingFile : string , moduleName : string ) : string {
320- const currentFolderPath = path
321- . dirname ( containingFile )
322- . replace ( this . sourcePath . replace ( / \/ $ / , "" ) , "" ) ;
323- const modulePath = path . join ( currentFolderPath , moduleName ) ;
322+ const posixSourcePath = this . sourcePath
323+ . replace ( / \\ / g, "/" )
324+ . replace ( / \/ $ / , "" ) ;
325+ const posixContainingDir = path . posix . dirname (
326+ containingFile . replace ( / \\ / g, "/" ) ,
327+ ) ;
328+ const currentFolderPath = posixContainingDir . replace (
329+ posixSourcePath ,
330+ "" ,
331+ ) ;
332+ const modulePath = path . posix . join (
333+ currentFolderPath || "." ,
334+ moduleName ,
335+ ) ;
324336
325337 // Let's ensure we search for the App's modules first
326338 const transformedModule =
@@ -370,7 +382,7 @@ export class TypescriptCompiler {
370382 return undefined ;
371383 }
372384
373- const norm = path . normalize ( fileName ) ;
385+ const norm = path . posix . normalize ( fileName . replace ( / \\ / g , "/" ) ) ;
374386
375387 if ( this . libraryFiles [ norm ] ) {
376388 return this . libraryFiles [ norm ] ;
@@ -396,7 +408,7 @@ export class TypescriptCompiler {
396408
397409 return (
398410 file . name . trim ( ) !== "" &&
399- path . normalize ( file . name ) &&
411+ path . posix . normalize ( file . name ) &&
400412 file . content . trim ( ) !== ""
401413 ) ;
402414 }
0 commit comments