Skip to content

Commit a29dc96

Browse files
ayazhafizalxhub
authored andcommittedJun 28, 2019
feat(bazel): allow passing a custom bazel compiler host to ngc compile (#31341)
Enable users to pass a custom Bazel CompilerHost to use for an Angular compilation. This supports users who must override the TypeScript compiler host. PR Close #31341
1 parent 0de5d79 commit a29dc96

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎packages/bazel/src/ngc-wrapped/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ export function relativeToRootDirs(filePath: string, rootDirs: string[]): string
145145
}
146146

147147
export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost, bazelOpts, files,
148-
inputs, expectedOuts, gatherDiagnostics}: {
148+
inputs, expectedOuts, gatherDiagnostics, bazelHost}: {
149149
allDepsCompiledWithBazel?: boolean,
150150
compilerOpts: ng.CompilerOptions,
151151
tsHost: ts.CompilerHost, inputs?: {[path: string]: string},
152152
bazelOpts: BazelOptions,
153153
files: string[],
154-
expectedOuts: string[], gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics
154+
expectedOuts: string[],
155+
gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics,
156+
bazelHost?: CompilerHost,
155157
}): {diagnostics: ng.Diagnostics, program: ng.Program} {
156158
let fileLoader: FileLoader;
157159

@@ -244,8 +246,10 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost,
244246
moduleName, containingFile, compilerOptions, generatedFileModuleResolverHost);
245247
}
246248

247-
const bazelHost = new CompilerHost(
248-
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
249+
if (!bazelHost) {
250+
bazelHost = new CompilerHost(
251+
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
252+
}
249253

250254
// Also need to disable decorator downleveling in the BazelHost in Ivy mode.
251255
if (isInIvyMode) {

0 commit comments

Comments
 (0)
Please sign in to comment.