From 827a83e00f1c2d708adf105f9227803f5a95468f Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 27 Sep 2021 23:45:30 +0200 Subject: [PATCH] refactor(bazel): update api-extractor bazel tool to only accept a single input (#43431) Updates the API extractor tool used by the `ng_module` rule to only accept a single entry-point file. This change is made in preparation for APF v13 where this logic is no longer needed. The logic previously only existed to also bundle the `r3_symbols` file. This file is no longer needed in APF v13 because Angular core no longer needs to be processed with `ngcc`. This allows us to clean up this logic which helps simplifying `ng_module`. Consumers that use an older version of `@angular/core` should respectively also use a compiler-cli version matching the core version. PR Close #43431 --- packages/bazel/src/api-extractor/index.ts | 28 ++++++----------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/packages/bazel/src/api-extractor/index.ts b/packages/bazel/src/api-extractor/index.ts index f7d02009ad4..ab3b0c94554 100644 --- a/packages/bazel/src/api-extractor/index.ts +++ b/packages/bazel/src/api-extractor/index.ts @@ -17,7 +17,7 @@ import * as path from 'path'; const DEBUG = false; export function runMain( - tsConfig: string, entryPoint: string, dtsBundleOut?: string, apiReviewFolder?: string, + tsConfig: string, entryPointExecPath: string, dtsBundleOut: string, apiReviewFolder?: string, acceptApiUpdates = false): 1|0 { const [parsedConfig, errors] = parseTsconfig(tsConfig); if (errors && errors.length) { @@ -26,7 +26,7 @@ export function runMain( return 1; } - const pkgJson = path.resolve(path.dirname(entryPoint), 'package.json'); + const pkgJson = path.resolve(path.dirname(entryPointExecPath), 'package.json'); if (!fs.existsSync(pkgJson)) { fs.writeFileSync(pkgJson, JSON.stringify({ 'name': 'GENERATED-BY-BAZEL', @@ -64,7 +64,7 @@ export function runMain( overrideTsconfig: parsedTsConfig, }, projectFolder: path.resolve(path.dirname(tsConfig)), - mainEntryPointFilePath: path.resolve(entryPoint), + mainEntryPointFilePath: path.resolve(entryPointExecPath), apiReport: { enabled: !!apiReviewFolder, // TODO(alan-agius4): remove this folder name when the below issue is solved upstream @@ -75,8 +75,8 @@ export function runMain( enabled: false, }, dtsRollup: { - enabled: !!dtsBundleOut, - untrimmedFilePath: dtsBundleOut && path.resolve(dtsBundleOut), + enabled: true, + untrimmedFilePath: path.resolve(dtsBundleOut), }, tsdocMetadata: { enabled: false, @@ -108,20 +108,6 @@ api-extractor: running with `); } - const [tsConfig, entryPoint, dtsBundleOut] = process.argv.slice(2); - const entryPoints = entryPoint.split(','); - const dtsBundleOuts = dtsBundleOut.split(','); - - if (entryPoints.length !== entryPoints.length) { - throw new Error(`Entry points count (${entryPoints.length}) does not match Bundle out count (${ - dtsBundleOuts.length})`); - } - - for (let i = 0; i < entryPoints.length; i++) { - process.exitCode = runMain(tsConfig, entryPoints[i], dtsBundleOuts[i]); - - if (process.exitCode !== 0) { - break; - } - } + const [tsConfig, entryPointExecPath, outputExecPath] = process.argv.slice(2); + process.exitCode = runMain(tsConfig, entryPointExecPath, outputExecPath); }