From dc8f29cc3676d79323901becfc32833cf6774ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 13 Nov 2024 10:13:40 +0100 Subject: [PATCH] feat(angular): add poll option to ng-packagr executors (#28909) Add `poll` option to the ng-packagr executors. This change was made upstream for Angular v18, but it was missed on the Nx executors. ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes # --- .../packages/angular/executors/ng-packagr-lite.json | 4 ++++ docs/generated/packages/angular/executors/package.json | 4 ++++ .../angular/src/executors/ng-packagr-lite/schema.json | 4 ++++ packages/angular/src/executors/package/package.impl.ts | 9 +++++++++ packages/angular/src/executors/package/schema.d.ts | 8 ++++---- packages/angular/src/executors/package/schema.json | 4 ++++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/generated/packages/angular/executors/ng-packagr-lite.json b/docs/generated/packages/angular/executors/ng-packagr-lite.json index 55f2797bfe..c90d21a0d9 100644 --- a/docs/generated/packages/angular/executors/ng-packagr-lite.json +++ b/docs/generated/packages/angular/executors/ng-packagr-lite.json @@ -36,6 +36,10 @@ "description": "Whether to run a build when any file changes.", "default": false }, + "poll": { + "type": "number", + "description": "Enable and define the file watching poll time period in milliseconds. _Note: this is only supported in Angular versions >= 18.0.0_." + }, "tailwindConfig": { "type": "string", "description": "The full path for the Tailwind configuration file, relative to the workspace root. If not provided and a `tailwind.config.js` file exists in the project or workspace root, it will be used. Otherwise, Tailwind will not be configured." diff --git a/docs/generated/packages/angular/executors/package.json b/docs/generated/packages/angular/executors/package.json index d09a22ca14..2df3b53f6d 100644 --- a/docs/generated/packages/angular/executors/package.json +++ b/docs/generated/packages/angular/executors/package.json @@ -41,6 +41,10 @@ "description": "Whether to run a build when any file changes.", "default": false }, + "poll": { + "type": "number", + "description": "Enable and define the file watching poll time period in milliseconds. _Note: this is only supported in Angular versions >= 18.0.0_." + }, "tailwindConfig": { "type": "string", "description": "The full path for the Tailwind configuration file, relative to the workspace root. If not provided and a `tailwind.config.js` file exists in the project or workspace root, it will be used. Otherwise, Tailwind will not be configured. _Note: starting with Angular v17, this option is no longer used and the configuration will be picked up if exists at the project or workspace root_.", diff --git a/packages/angular/src/executors/ng-packagr-lite/schema.json b/packages/angular/src/executors/ng-packagr-lite/schema.json index c9ee575596..65036cd3dc 100644 --- a/packages/angular/src/executors/ng-packagr-lite/schema.json +++ b/packages/angular/src/executors/ng-packagr-lite/schema.json @@ -33,6 +33,10 @@ "description": "Whether to run a build when any file changes.", "default": false }, + "poll": { + "type": "number", + "description": "Enable and define the file watching poll time period in milliseconds. _Note: this is only supported in Angular versions >= 18.0.0_." + }, "tailwindConfig": { "type": "string", "description": "The full path for the Tailwind configuration file, relative to the workspace root. If not provided and a `tailwind.config.js` file exists in the project or workspace root, it will be used. Otherwise, Tailwind will not be configured." diff --git a/packages/angular/src/executors/package/package.impl.ts b/packages/angular/src/executors/package/package.impl.ts index be99c7d407..65b9386912 100644 --- a/packages/angular/src/executors/package/package.impl.ts +++ b/packages/angular/src/executors/package/package.impl.ts @@ -10,6 +10,7 @@ import type { NgPackagr } from 'ng-packagr'; import { join, resolve } from 'path'; import { from } from 'rxjs'; import { mapTo, switchMap } from 'rxjs/operators'; +import { getInstalledAngularVersionInfo } from '../utilities/angular-version-utils'; import { parseRemappedTsConfigAndMergeDefaults } from '../utilities/typescript'; import { getNgPackagrInstance } from './ng-packagr-adjustments/ng-packagr'; import type { BuildAngularLibraryExecutorOptions } from './schema'; @@ -56,6 +57,14 @@ export function createLibraryExecutor( options: BuildAngularLibraryExecutorOptions, context: ExecutorContext ) { + const { major: angularMajorVersion, version: angularVersion } = + getInstalledAngularVersionInfo(); + if (angularMajorVersion < 18 && options.poll !== undefined) { + throw new Error( + `The "poll" option requires Angular version 18.0.0 or greater. You are currently using version ${angularVersion}.` + ); + } + const { target, dependencies, topLevelDependencies } = calculateProjectBuildableDependencies( context.taskGraph, diff --git a/packages/angular/src/executors/package/schema.d.ts b/packages/angular/src/executors/package/schema.d.ts index b54db68390..d738f50028 100644 --- a/packages/angular/src/executors/package/schema.d.ts +++ b/packages/angular/src/executors/package/schema.d.ts @@ -1,6 +1,6 @@ -export interface BuildAngularLibraryExecutorOptions { - project: string; +import type { NgPackagrBuilderOptions } from '@angular-devkit/build-angular'; + +export interface BuildAngularLibraryExecutorOptions + extends NgPackagrBuilderOptions { tailwindConfig?: string; - tsConfig?: string; - watch?: boolean; } diff --git a/packages/angular/src/executors/package/schema.json b/packages/angular/src/executors/package/schema.json index 8463938533..da7b5e4f13 100644 --- a/packages/angular/src/executors/package/schema.json +++ b/packages/angular/src/executors/package/schema.json @@ -33,6 +33,10 @@ "description": "Whether to run a build when any file changes.", "default": false }, + "poll": { + "type": "number", + "description": "Enable and define the file watching poll time period in milliseconds. _Note: this is only supported in Angular versions >= 18.0.0_." + }, "tailwindConfig": { "type": "string", "description": "The full path for the Tailwind configuration file, relative to the workspace root. If not provided and a `tailwind.config.js` file exists in the project or workspace root, it will be used. Otherwise, Tailwind will not be configured. _Note: starting with Angular v17, this option is no longer used and the configuration will be picked up if exists at the project or workspace root_.",