From 205abe814017a48ec602db959dea37966292dd32 Mon Sep 17 00:00:00 2001 From: Abhimanyu Deora Date: Wed, 26 Jul 2017 11:40:33 -0500 Subject: [PATCH] build: fix broken bazel build (#18335) --- packages/compiler-cli/index.ts | 1 + tools/ngc-wrapped/index.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/index.ts b/packages/compiler-cli/index.ts index b5a4f2ae37..f242a5b64b 100644 --- a/packages/compiler-cli/index.ts +++ b/packages/compiler-cli/index.ts @@ -21,6 +21,7 @@ export * from './src/transformers/api'; export * from './src/transformers/entry_points'; export {main as ngc} from './src/ngc'; +export {performCompilation} from './src/ngc'; // TODO(hansl): moving to Angular 4 need to update this API. export {NgTools_InternalApi_NG_2 as __NGTOOLS_PRIVATE_API_2} from './src/ngtools_api'; diff --git a/tools/ngc-wrapped/index.ts b/tools/ngc-wrapped/index.ts index 3929ccb05a..37d88317dd 100644 --- a/tools/ngc-wrapped/index.ts +++ b/tools/ngc-wrapped/index.ts @@ -9,8 +9,9 @@ // TODO(chuckj): Remove the requirment for a fake 'reflect` implementation from // the compiler import 'reflect-metadata'; -import {ngc} from '@angular/compiler-cli'; +import {performCompilation} from '@angular/compiler-cli'; import * as fs from 'fs'; +import * as path from 'path'; // Note, the tsc_wrapped module comes from rules_typescript, not from @angular/tsc-wrapped import {parseTsconfig} from 'tsc_wrapped'; @@ -18,7 +19,14 @@ function main(args: string[]) { const [{options, bazelOpts, files, config}] = parseTsconfig(args[1]); const ngOptions: {expectedOut: string[]} = (config as any).angularCompilerOptions; - const result = ngc(args, undefined, files, options, ngOptions); + const parsedArgs = require('minimist')(args); + const project = parsedArgs.p || parsedArgs.project || '.'; + + const projectDir = fs.lstatSync(project).isFile() ? path.dirname(project) : project; + + // file names in tsconfig are resolved relative to this absolute path + const basePath = path.resolve(process.cwd(), projectDir); + const result = performCompilation(basePath, files, options, ngOptions, undefined); if (result === 0) { // Ensure that expected output files exist. @@ -34,4 +42,4 @@ function main(args: string[]) { if (require.main === module) { process.exitCode = main(process.argv.slice(2)); -} \ No newline at end of file +}