Skip to content

Commit

Permalink
feat(bazel): allow passing a custom bazel compiler host to ngc compile (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
ayazhafiz authored and alxhub committed Jun 28, 2019
1 parent 0de5d79 commit a29dc96
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/bazel/src/ngc-wrapped/index.ts
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a29dc96

Please sign in to comment.