7
7
*/
8
8
9
9
import * as ng from '@angular/compiler-cli' ;
10
- import { BazelOptions , CachedFileLoader , CompilerHost , FileCache , FileLoader , UncachedFileLoader , constructManifest , debug , fixUmdModuleDeclarations , parseTsconfig , runAsWorker , runWorkerLoop } from '@bazel/typescript' ;
10
+ import { BazelOptions , CachedFileLoader , CompilerHost , FileCache , FileLoader , UncachedFileLoader , constructManifest , debug , fixUmdModuleDeclarations , parseTsconfig , resolveNormalizedPath , runAsWorker , runWorkerLoop } from '@bazel/typescript' ;
11
11
import * as fs from 'fs' ;
12
12
import * as path from 'path' ;
13
13
import * as tsickle from 'tsickle' ;
@@ -77,7 +77,7 @@ export function relativeToRootDirs(filePath: string, rootDirs: string[]): string
77
77
if ( ! filePath ) return filePath ;
78
78
// NB: the rootDirs should have been sorted longest-first
79
79
for ( const dir of rootDirs || [ ] ) {
80
- const rel = path . relative ( dir , filePath ) ;
80
+ const rel = path . posix . relative ( dir , filePath ) ;
81
81
if ( rel . indexOf ( '.' ) != 0 ) return rel ;
82
82
}
83
83
return filePath ;
@@ -107,7 +107,7 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
107
107
// Resolve the inputs to absolute paths to match TypeScript internals
108
108
const resolvedInputs : { [ path : string ] : string } = { } ;
109
109
for ( const key of Object . keys ( inputs ) ) {
110
- resolvedInputs [ path . resolve ( key ) ] = inputs [ key ] ;
110
+ resolvedInputs [ resolveNormalizedPath ( key ) ] = inputs [ key ] ;
111
111
}
112
112
fileCache . updateCache ( resolvedInputs ) ;
113
113
} else {
@@ -133,7 +133,7 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
133
133
tsHost . writeFile =
134
134
( fileName : string , content : string , writeByteOrderMark : boolean ,
135
135
onError ?: ( message : string ) => void , sourceFiles ?: ts . SourceFile [ ] ) => {
136
- const relative = relativeToRootDirs ( fileName , [ compilerOpts . rootDir ] ) ;
136
+ const relative = relativeToRootDirs ( fileName . replace ( / \\ / g , '/' ) , [ compilerOpts . rootDir ] ) ;
137
137
const expectedIdx = writtenExpectedOuts . findIndex ( o => o === relative ) ;
138
138
if ( expectedIdx >= 0 ) {
139
139
writtenExpectedOuts . splice ( expectedIdx , 1 ) ;
@@ -196,7 +196,7 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
196
196
}
197
197
return bazelOpts . workspaceName + '/' + result ;
198
198
} ;
199
- ngHost . toSummaryFileName = ( fileName : string , referringSrcFileName : string ) => path . join (
199
+ ngHost . toSummaryFileName = ( fileName : string , referringSrcFileName : string ) => path . posix . join (
200
200
bazelOpts . workspaceName ,
201
201
relativeToRootDirs ( fileName , compilerOpts . rootDirs ) . replace ( EXT , '' ) ) ;
202
202
if ( allDepsCompiledWithBazel ) {
@@ -206,7 +206,7 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
206
206
// as that has a different implementation of fromSummaryFileName / toSummaryFileName
207
207
ngHost . fromSummaryFileName = ( fileName : string , referringLibFileName : string ) => {
208
208
const workspaceRelative = fileName . split ( '/' ) . splice ( 1 ) . join ( '/' ) ;
209
- return path . resolve ( bazelBin , workspaceRelative ) + '.d.ts' ;
209
+ return resolveNormalizedPath ( bazelBin , workspaceRelative ) + '.d.ts' ;
210
210
} ;
211
211
}
212
212
// Patch a property on the ngHost that allows the resourceNameToModuleName function to
0 commit comments