From bf9c677e7977126f55405be5e95782dddd239018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Mon, 16 Jun 2025 10:20:13 +0200 Subject: [PATCH] fix(angular): fix import from ng-packagr (#31600) ## Current Behavior Using the `ng-packagr` executors in an Angular version lower than v20 results in an error due to a bad import. ## Expected Behavior The `ng-packagr` executors should work correctly regardless of the Angular version used. ## Related Issue(s) Fixes #31597 --- .../utilities/ng-packagr/pre-v19/stylesheet-processor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/angular/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.ts b/packages/angular/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.ts index b8e202f2e6..3e0c0333d4 100644 --- a/packages/angular/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.ts +++ b/packages/angular/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.ts @@ -9,8 +9,9 @@ import { workspaceRoot } from '@nx/devkit'; import browserslist from 'browserslist'; import { existsSync } from 'fs'; -import { colors } from 'ng-packagr/src/lib/utils/color'; import { dirname, join } from 'path'; +import { getNgPackagrVersionInfo } from '../ng-packagr-version'; +import { importNgPackagrPath } from '../package-imports'; const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS']; const maxThreads = @@ -100,6 +101,10 @@ export class StylesheetProcessor { ]); const tailwindConfigPath = findTailwindConfiguration(searchDirs); + const { major: ngPackagrMajorVersion } = getNgPackagrVersionInfo(); + const { colors } = importNgPackagrPath< + typeof import('ng-packagr/src/lib/utils/color') + >('ng-packagr/src/lib/utils/color', ngPackagrMajorVersion); const Piscina = getPiscina(); this.renderWorker = new Piscina({