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.

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Leosvel Pérez Espinosa 2024-11-13 10:13:40 +01:00 committed by GitHub
parent 5c7d4d1fbf
commit dc8f29cc36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 29 additions and 4 deletions

View File

@ -36,6 +36,10 @@
"description": "Whether to run a build when any file changes.", "description": "Whether to run a build when any file changes.",
"default": false "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": { "tailwindConfig": {
"type": "string", "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." "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."

View File

@ -41,6 +41,10 @@
"description": "Whether to run a build when any file changes.", "description": "Whether to run a build when any file changes.",
"default": false "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": { "tailwindConfig": {
"type": "string", "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_.", "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_.",

View File

@ -33,6 +33,10 @@
"description": "Whether to run a build when any file changes.", "description": "Whether to run a build when any file changes.",
"default": false "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": { "tailwindConfig": {
"type": "string", "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." "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."

View File

@ -10,6 +10,7 @@ import type { NgPackagr } from 'ng-packagr';
import { join, resolve } from 'path'; import { join, resolve } from 'path';
import { from } from 'rxjs'; import { from } from 'rxjs';
import { mapTo, switchMap } from 'rxjs/operators'; import { mapTo, switchMap } from 'rxjs/operators';
import { getInstalledAngularVersionInfo } from '../utilities/angular-version-utils';
import { parseRemappedTsConfigAndMergeDefaults } from '../utilities/typescript'; import { parseRemappedTsConfigAndMergeDefaults } from '../utilities/typescript';
import { getNgPackagrInstance } from './ng-packagr-adjustments/ng-packagr'; import { getNgPackagrInstance } from './ng-packagr-adjustments/ng-packagr';
import type { BuildAngularLibraryExecutorOptions } from './schema'; import type { BuildAngularLibraryExecutorOptions } from './schema';
@ -56,6 +57,14 @@ export function createLibraryExecutor(
options: BuildAngularLibraryExecutorOptions, options: BuildAngularLibraryExecutorOptions,
context: ExecutorContext 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 } = const { target, dependencies, topLevelDependencies } =
calculateProjectBuildableDependencies( calculateProjectBuildableDependencies(
context.taskGraph, context.taskGraph,

View File

@ -1,6 +1,6 @@
export interface BuildAngularLibraryExecutorOptions { import type { NgPackagrBuilderOptions } from '@angular-devkit/build-angular';
project: string;
export interface BuildAngularLibraryExecutorOptions
extends NgPackagrBuilderOptions {
tailwindConfig?: string; tailwindConfig?: string;
tsConfig?: string;
watch?: boolean;
} }

View File

@ -33,6 +33,10 @@
"description": "Whether to run a build when any file changes.", "description": "Whether to run a build when any file changes.",
"default": false "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": { "tailwindConfig": {
"type": "string", "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_.", "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_.",