fix(compiler-cli): ngcc - cope with processing entry-points multiple times (#29657)
With the new API, where you can choose to only process the first matching format, it is possible to process an entry-point multiple times, if you pass in a different format each time. Previously, ngcc would always try to process the typings files for the entry-point along with processing the first format of the current execution of ngcc. But this meant that it would be trying to process the typings a second time. Now we only process the typings if they have not already been processed as part of processing another format in another even if it was in a different execution of ngcc. PR Close #29657
This commit is contained in:

committed by
Jason Aden

parent
c5799491e7
commit
6b39c9cf32
@ -110,6 +110,8 @@ export function mainNgcc({basePath, targetEntryPointPath,
|
||||
const entryPointPackageJson = entryPoint.packageJson;
|
||||
const entryPointPackageJsonPath = AbsoluteFsPath.from(resolve(entryPoint.path, 'package.json'));
|
||||
|
||||
const hasProcessedDts = hasBeenProcessed(entryPointPackageJson, 'typings');
|
||||
|
||||
for (let i = 0; i < propertiesToConsider.length; i++) {
|
||||
const property = propertiesToConsider[i] as EntryPointJsonProperty;
|
||||
const formatPath = entryPointPackageJson[property];
|
||||
@ -124,12 +126,14 @@ export function mainNgcc({basePath, targetEntryPointPath,
|
||||
continue;
|
||||
}
|
||||
|
||||
const isFirstFormat = compiledFormats.size === 0;
|
||||
const processDts = !hasProcessedDts && isFirstFormat;
|
||||
|
||||
// We don't break if this if statement fails because we still want to mark
|
||||
// the property as processed even if its underlying format has been built already.
|
||||
if (!compiledFormats.has(formatPath) && (compileAllFormats || compiledFormats.size === 0)) {
|
||||
if (!compiledFormats.has(formatPath) && (compileAllFormats || isFirstFormat)) {
|
||||
const bundle = makeEntryPointBundle(
|
||||
entryPoint.path, formatPath, entryPoint.typings, isCore, property, format,
|
||||
compiledFormats.size === 0);
|
||||
entryPoint.path, formatPath, entryPoint.typings, isCore, property, format, processDts);
|
||||
if (bundle) {
|
||||
logger.info(`Compiling ${entryPoint.name} : ${property} as ${format}`);
|
||||
const transformedFiles = transformer.transform(bundle);
|
||||
@ -147,6 +151,9 @@ export function mainNgcc({basePath, targetEntryPointPath,
|
||||
// previous property.
|
||||
if (compiledFormats.has(formatPath)) {
|
||||
markAsProcessed(entryPointPackageJson, entryPointPackageJsonPath, property);
|
||||
if (processDts) {
|
||||
markAsProcessed(entryPointPackageJson, entryPointPackageJsonPath, 'typings');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user