fix(angular): warn in ng-packagr executors when finding conflicting package export conditions (#16905)

This commit is contained in:
Leosvel Pérez Espinosa 2023-05-10 12:55:35 +01:00 committed by GitHub
parent 6aac7ba04b
commit bdfb10db0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -397,20 +397,15 @@ function generatePackageExports(
subpath: string,
mapping: ConditionalExport
) => {
if (exports[subpath] === undefined) {
exports[subpath] = {};
}
exports[subpath] ??= {};
const subpathExport = exports[subpath];
// Go through all conditions that should be inserted. If the condition is already
// manually set of the subpath export, we throw an error. In general, we allow for
// additional conditions to be set. These will always precede the generated ones.
for (const conditionName of Object.keys(mapping) as [
keyof ConditionalExport
]) {
for (const conditionName of Object.keys(mapping)) {
if (subpathExport[conditionName] !== undefined) {
throw Error(
logger.warn(
`Found a conflicting export condition for "${subpath}". The "${conditionName}" ` +
`condition would be overridden by ng-packagr. Please unset it.`
);