Skip to content

Commit

Permalink
feat(bazel): allow passing and rewriting an old bazel host
Browse files Browse the repository at this point in the history
Updates the decision made in angular#31341; this is for the Angular indexer
inside Google. The indexer currently passes (and ngc-wrapped#compile
accepts) a bazel host to use, but because many methods are overwritten
specially for Angular compilation a better approach is to pass an old
bazel compiler host and siphon methods needed off of it before creating
a new host. This enables that.
  • Loading branch information
ayazhafiz committed Jul 2, 2019
1 parent a4a423a commit 0a4c1c8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/bazel/src/ngc-wrapped/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ export function relativeToRootDirs(filePath: string, rootDirs: string[]): string
}

export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost, bazelOpts, files,
inputs, expectedOuts, gatherDiagnostics, bazelHost}: {
inputs, expectedOuts, gatherDiagnostics, oldBazelHost}: {
allDepsCompiledWithBazel?: boolean,
compilerOpts: ng.CompilerOptions,
tsHost: ts.CompilerHost, inputs?: {[path: string]: string},
bazelOpts: BazelOptions,
files: string[],
expectedOuts: string[],
gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics,
bazelHost?: CompilerHost,
oldBazelHost?: CompilerHost,
}): {diagnostics: ng.Diagnostics, program: ng.Program} {
let fileLoader: FileLoader;

Expand Down Expand Up @@ -246,9 +246,10 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost,
moduleName, containingFile, compilerOptions, generatedFileModuleResolverHost);
}

if (!bazelHost) {
bazelHost = new CompilerHost(
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
const bazelHost = new CompilerHost(
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
if (oldBazelHost) {
Object.assign(bazelHost, oldBazelHost);
}

// Also need to disable decorator downleveling in the BazelHost in Ivy mode.
Expand Down

0 comments on commit 0a4c1c8

Please sign in to comment.