Skip to content

Commit 11a208f

Browse files
ayazhafizalxhub
authored andcommittedJul 2, 2019
feat(bazel): allow passing and rewriting an old bazel host (#31381)
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
1 parent 1db3ac4 commit 11a208f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +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, bazelHost}: {
148+
inputs, expectedOuts, gatherDiagnostics, oldBazelHost}: {
149149
allDepsCompiledWithBazel?: boolean,
150150
compilerOpts: ng.CompilerOptions,
151151
tsHost: ts.CompilerHost, inputs?: {[path: string]: string},
152152
bazelOpts: BazelOptions,
153153
files: string[],
154154
expectedOuts: string[],
155155
gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics,
156-
bazelHost?: CompilerHost,
156+
oldBazelHost?: CompilerHost,
157157
}): {diagnostics: ng.Diagnostics, program: ng.Program} {
158158
let fileLoader: FileLoader;
159159

@@ -246,9 +246,12 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost,
246246
moduleName, containingFile, compilerOptions, generatedFileModuleResolverHost);
247247
}
248248

249-
if (!bazelHost) {
250-
bazelHost = new CompilerHost(
251-
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
249+
const bazelHost = new CompilerHost(
250+
files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
251+
if (oldBazelHost) {
252+
// TODO(ayazhafiz): this kind of patching is hacky. Revisit this after the
253+
// indexer consumer of this code is known to be working.
254+
Object.assign(bazelHost, oldBazelHost);
252255
}
253256

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

0 commit comments

Comments
 (0)
Please sign in to comment.