Skip to content

Commit

Permalink
feat(bazel): allow passing and rewriting an old bazel host (#31381)
Browse files Browse the repository at this point in the history
Updates the decision made in #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.

PR Close #31381
  • Loading branch information
ayazhafiz authored and alxhub committed Jul 2, 2019
1 parent 1db3ac4 commit 11a208f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/bazel/src/ngc-wrapped/index.ts
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,12 @@ 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) {
// TODO(ayazhafiz): this kind of patching is hacky. Revisit this after the
// indexer consumer of this code is known to be working.
Object.assign(bazelHost, oldBazelHost);
}

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

0 comments on commit 11a208f

Please sign in to comment.