Skip to content

Commit

Permalink
feat(angular): drop support for angular v16 (#28848)
Browse files Browse the repository at this point in the history
Drop support for Angular v16.

BREAKING CHANGE: Drop support for Angular v16, which is no longer an LTS
version.

<!-- 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 #
  • Loading branch information
leosvelperez authored Nov 8, 2024
1 parent 677705e commit 1b0fe95
Show file tree
Hide file tree
Showing 84 changed files with 211 additions and 3,285 deletions.
4 changes: 2 additions & 2 deletions docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"type": "executor"
},
"/nx-api/angular/executors/application": {
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.",
"file": "generated/packages/angular/executors/application.json",
"hidden": false,
"name": "application",
Expand Down Expand Up @@ -200,7 +200,7 @@
"type": "generator"
},
"/nx-api/angular/generators/convert-to-application-executor": {
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.",
"file": "generated/packages/angular/generators/convert-to-application-executor.json",
"hidden": false,
"name": "convert-to-application-executor",
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"type": "executor"
},
{
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.",
"file": "generated/packages/angular/executors/application.json",
"hidden": false,
"name": "application",
Expand Down Expand Up @@ -195,7 +195,7 @@
"type": "generator"
},
{
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.",
"file": "generated/packages/angular/generators/convert-to-application-executor.json",
"hidden": false,
"name": "convert-to-application-executor",
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/angular/executors/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"schema": {
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Schema for Nx Application Executor",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.",
"examplesFile": "This executor is a drop-in replacement for the `@angular-devkit/build-angular:application` builder provided by the Angular CLI. It builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.\n\nIn addition to the features provided by the Angular CLI builder, the `@nx/angular:application` executor also supports the following:\n\n- Providing esbuild plugins\n- Providing a function to transform the application's `index.html` file\n- Incremental builds\n\n{% callout type=\"check\" title=\"Dev Server\" %}\nThe [`@nx/angular:dev-server` executor](/nx-api/angular/executors/dev-server) is required to serve your application when using the `@nx/angular:application` to build it. It is a drop-in replacement for the Angular CLI's `@angular-devkit/build-angular:dev-server` builder and ensures the application is correctly served with Vite when using the `@nx/angular:application` executor.\n{% /callout %}\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Providing esbuild plugins\" %}\n\nThe executor accepts a `plugins` option that allows you to provide esbuild plugins that will be used when building your application. It allows providing a path to a plugin file or an object with a `path` and `options` property to provide options to the plugin.\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[\"8-16\"] %}\n{\n ...\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:application\",\n \"options\": {\n ...\n \"plugins\": [\n \"apps/my-app/plugins/plugin1.js\",\n {\n \"path\": \"apps/my-app/plugins/plugin2.js\",\n \"options\": {\n \"someOption\": \"some value\"\n }\n }\n ]\n }\n }\n ...\n }\n}\n```\n\n```ts {% fileName=\"apps/my-app/plugins/plugin1.js\" %}\nconst plugin1 = {\n name: 'plugin1',\n setup(build) {\n const options = build.initialOptions;\n options.define.PLUGIN1_TEXT = '\"Value was provided at build time\"';\n },\n};\n\nmodule.exports = plugin1;\n```\n\n```ts {% fileName=\"apps/my-app/plugins/plugin2.js\" %}\nfunction plugin2({ someOption }) {\n return {\n name: 'plugin2',\n setup(build) {\n const options = build.initialOptions;\n options.define.PLUGIN2_TEXT = JSON.stringify(someOption);\n },\n };\n}\n\nmodule.exports = plugin2;\n```\n\nAdditionally, we need to inform TypeScript of the defined variables to prevent type-checking errors during the build. We can achieve this by creating or updating a type definition file included in the TypeScript build process (e.g. `src/types.d.ts`) with the following content:\n\n```ts {% fileName=\"apps/my-app/src/types.d.ts\" %}\ndeclare const PLUGIN1_TEXT: number;\ndeclare const PLUGIN2_TEXT: string;\n```\n\n{% /tab %}\n\n{% tab label=\"Transforming the 'index.html' file\" %}\n\nThe executor accepts an `indexHtmlTransformer` option to provide a path to a file with a default export for a function that receives the application's `index.html` file contents and outputs the updated contents.\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[8] %}\n{\n ...\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:application\",\n \"options\": {\n ...\n \"indexHtmlTransformer\": \"apps/my-app/index-html.transformer.ts\"\n }\n }\n ...\n }\n}\n```\n\n```ts {% fileName=\"apps/my-app/index-html.transformer.ts\" %}\nexport default function (indexContent: string) {\n return indexContent.replace(\n '<title>my-app</title>',\n '<title>my-app (transformed)</title>'\n );\n}\n```\n\n{% /tab %}\n{% /tabs %}\n",
"outputCapture": "direct-nodejs",
"type": "object",
Expand Down Expand Up @@ -741,7 +741,7 @@
},
"presets": []
},
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/executors/application/schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
"default": true
},
"plugins": {
"description": "A list of ESBuild plugins. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "A list of ESBuild plugins.",
"type": "array",
"items": {
"oneOf": [
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/angular/executors/dev-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
"forceEsbuild": {
"type": "boolean",
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system. _Note: this is only supported in Angular versions >= 16.1.0_.",
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system.",
"default": false
},
"inspect": {
Expand Down Expand Up @@ -145,7 +145,7 @@
"x-priority": "important"
},
"esbuildMiddleware": {
"description": "A list of HTTP request middleware functions. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "A list of HTTP request middleware functions.",
"type": "array",
"items": {
"type": "string",
Expand Down
5 changes: 3 additions & 2 deletions docs/generated/packages/angular/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@
"default": false
},
"bundler": {
"description": "Bundler to use to build the application. It defaults to `esbuild` for Angular versions >= 17.0.0. Otherwise, it defaults to `webpack`. _Note: The `esbuild` bundler is only considered stable from Angular v17._",
"description": "Bundler to use to build the application.",
"type": "string",
"enum": ["webpack", "esbuild"],
"enum": ["esbuild", "webpack"],
"default": "esbuild",
"x-prompt": "Which bundler do you want to use to build the application?",
"x-priority": "important"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"$schema": "http://json-schema.org/schema",
"$id": "NxAngularConvertToApplicationExecutorGenerator",
"cli": "nx",
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.",
"description": "Converts a project or all projects using one of the `@angular-devkit/build-angular:browser`, `@angular-devkit/build-angular:browser-esbuild`, `@nx/angular:browser` and `@nx/angular:browser-esbuild` executors to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. If the converted target is using one of the `@nx/angular` executors, the `@nx/angular:application` executor will be used. Otherwise, the `@angular-devkit/build-angular:application` builder will be used.",
"type": "object",
"properties": {
Expand All @@ -25,7 +25,7 @@
"additionalProperties": false,
"presets": []
},
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.",
"implementation": "/packages/angular/src/generators/convert-to-application-executor/convert-to-application-executor.ts",
"aliases": [],
"hidden": false,
Expand Down
10 changes: 2 additions & 8 deletions docs/generated/packages/angular/generators/setup-ssr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
"x-prompt": "What app would you like to generate an Angular Universal configuration for?",
"x-dropdown": "projects"
},
"appId": {
"type": "string",
"format": "html-selector",
"description": "The `appId` to use with `withServerTransition`.",
"default": "serverApp",
"x-deprecated": "This is deprecated and ignored since Angular 16 and not supported since Angular 17."
},
"main": {
"type": "string",
"format": "path",
Expand Down Expand Up @@ -56,7 +49,8 @@
},
"hydration": {
"type": "boolean",
"description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`."
"description": "Set up Hydration for the SSR application.",
"default": true
},
"skipFormat": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"application": {
"implementation": "./src/executors/application/application.impl",
"schema": "./src/executors/application/schema.json",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_."
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities."
},
"extract-i18n": {
"implementation": "./src/executors/extract-i18n/extract-i18n.impl",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"convert-to-application-executor": {
"factory": "./src/generators/convert-to-application-executor/convert-to-application-executor",
"schema": "./src/generators/convert-to-application-executor/schema.json",
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_."
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder."
},
"directive": {
"factory": "./src/generators/directive/directive",
Expand Down
1 change: 0 additions & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@phenomnomnominal/tsquery": "~5.0.1",
"@typescript-eslint/type-utils": "^8.0.0",
"chalk": "^4.1.0",
"find-cache-dir": "^3.3.2",
"magic-string": "~0.30.2",
"minimatch": "9.0.3",
"semver": "^7.5.3",
Expand Down
13 changes: 1 addition & 12 deletions packages/angular/src/builders/dev-server/lib/validate-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@ import { getInstalledAngularVersionInfo } from '../../../executors/utilities/ang
import type { Schema } from '../schema';

export function validateOptions(options: Schema): void {
const { major: angularMajorVersion, version: angularVersion } =
getInstalledAngularVersionInfo();

if (lt(angularVersion, '16.1.0') && options.forceEsbuild) {
throw new Error(stripIndents`The "forceEsbuild" option is only supported in Angular >= 16.1.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "forceEsbuild" option or by migrating to Angular 16.1.0.`);
}

if (angularMajorVersion < 17 && options.esbuildMiddleware?.length > 0) {
throw new Error(stripIndents`The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
}
const { version: angularVersion } = getInstalledAngularVersionInfo();

if (lt(angularVersion, '17.2.0') && options.prebundle) {
throw new Error(stripIndents`The "prebundle" option is only supported in Angular >= 17.2.0. You are currently using "${angularVersion}".
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/builders/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
"forceEsbuild": {
"type": "boolean",
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system. _Note: this is only supported in Angular versions >= 16.1.0_.",
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system.",
"default": false
},
"inspect": {
Expand Down Expand Up @@ -151,7 +151,7 @@
"x-priority": "important"
},
"esbuildMiddleware": {
"description": "A list of HTTP request middleware functions. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "A list of HTTP request middleware functions.",
"type": "array",
"items": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/executors/application/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Schema for Nx Application Executor",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.",
"examplesFile": "../../../docs/application-executor-examples.md",
"outputCapture": "direct-nodejs",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ import { getInstalledAngularVersionInfo } from '../../utilities/angular-version-
import type { ApplicationExecutorOptions } from '../schema';

export function validateOptions(options: ApplicationExecutorOptions): void {
const { major: angularMajorVersion, version: angularVersion } =
getInstalledAngularVersionInfo();

if (angularMajorVersion < 17) {
throw new Error(
`The "application" executor requires Angular version 17 or greater. You are currently using version ${angularVersion}.`
);
}
const { version: angularVersion } = getInstalledAngularVersionInfo();

if (lt(angularVersion, '17.1.0')) {
if (options.loader) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { buildEsbuildBrowser as buildEsbuildBrowserFn } from '@angular-devkit/build-angular/src/builders/browser-esbuild';
import { stripIndents, type ExecutorContext } from '@nx/devkit';
import type { ExecutorContext } from '@nx/devkit';
import type { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
import { createBuilderContext } from 'nx/src/adapter/ngcli-adapter';
import { getInstalledAngularVersionInfo } from '../utilities/angular-version-utils';
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import { loadPlugins } from '../utilities/esbuild-extensions';
import type { EsBuildSchema } from './schema';
Expand All @@ -11,15 +10,6 @@ export default async function* esbuildExecutor(
options: EsBuildSchema,
context: ExecutorContext
): ReturnType<typeof buildEsbuildBrowserFn> {
if (options.plugins) {
const { major: angularMajorVersion, version: angularVersion } =
getInstalledAngularVersionInfo();
if (angularMajorVersion < 17) {
throw new Error(stripIndents`The "plugins" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "plugins" option or by migrating to Angular 17.0.0.`);
}
}

options.buildLibsFromSource ??= true;

const {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/executors/browser-esbuild/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
"default": true
},
"plugins": {
"description": "A list of ESBuild plugins. _Note: this is only supported in Angular versions >= 17.0.0_.",
"description": "A list of ESBuild plugins.",
"type": "array",
"items": {
"oneOf": [
Expand Down
Loading

0 comments on commit 1b0fe95

Please sign in to comment.