From a29dc961a2d8f7a3cd735dfbb71bda109b89801a Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Fri, 28 Jun 2019 08:33:53 -0700 Subject: [PATCH] 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 --- packages/bazel/src/ngc-wrapped/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index 489d74b390..74b2c7b47f 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -145,13 +145,15 @@ export function relativeToRootDirs(filePath: string, rootDirs: string[]): string } export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost, bazelOpts, files, - inputs, expectedOuts, gatherDiagnostics}: { + inputs, expectedOuts, gatherDiagnostics, bazelHost}: { allDepsCompiledWithBazel?: boolean, compilerOpts: ng.CompilerOptions, tsHost: ts.CompilerHost, inputs?: {[path: string]: string}, bazelOpts: BazelOptions, files: string[], - expectedOuts: string[], gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics + expectedOuts: string[], + gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics, + bazelHost?: CompilerHost, }): {diagnostics: ng.Diagnostics, program: ng.Program} { let fileLoader: FileLoader; @@ -244,8 +246,10 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost, moduleName, containingFile, compilerOptions, generatedFileModuleResolverHost); } - const bazelHost = new CompilerHost( - files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver); + if (!bazelHost) { + bazelHost = new CompilerHost( + files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver); + } // Also need to disable decorator downleveling in the BazelHost in Ivy mode. if (isInIvyMode) {