From f5923380c77c1b96e1100feb1e327ef8eadbe4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 10 May 2023 11:31:28 +0100 Subject: [PATCH] fix(angular): warn in ng-packagr executors when finding conflicting package export conditions --- .../ng-package/entry-point/write-package.transform.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/angular/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.ts b/packages/angular/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.ts index 8599568f4ee1d..e3d98beb71150 100644 --- a/packages/angular/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.ts +++ b/packages/angular/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.ts @@ -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.` );