Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular): support angular 17.2.0 #21671

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ We provide a recommended version, and it is usually the latest minor version of

| Angular Version | **Nx Version _(recommended)_** | Nx Version _(range)_ |
| --------------- | ------------------------------ | -------------------------------------- |
| ~17.2.0 | **latest** | 18.1.0 <= latest |
| ~17.1.0 | **latest** | 17.3.0 <= latest |
| ~17.0.0 | **latest** | 17.1.0 <= latest |
| ~16.2.0 | **latest** | 16.7.0 <= latest |
Expand Down
10 changes: 10 additions & 0 deletions docs/generated/packages/angular/executors/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"items": { "type": "string" },
"default": []
},
"clearScreen": {
"type": "boolean",
"default": false,
"description": "Automatically clear the terminal screen during rebuilds. _Note: this is only supported in Angular versions >= 17.2.0_."
},
"optimization": {
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
"default": true,
Expand Down Expand Up @@ -234,6 +239,11 @@
"^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
}
},
"define": {
"description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced. _Note: this is only supported in Angular versions >= 17.2.0_.",
"type": "object",
"additionalProperties": { "type": "string" }
},
"fileReplacements": {
"description": "Replace compilation source files with other compilation source files in the build.",
"type": "array",
Expand Down
18 changes: 18 additions & 0 deletions docs/generated/packages/angular/executors/dev-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@
"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_.",
"default": false
},
"prebundle": {
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders. _Note: this is only supported in Angular versions >= 17.2.0_.",
"oneOf": [
{ "type": "boolean" },
{
"type": "object",
"properties": {
"exclude": {
"description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself.",
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false,
"required": ["exclude"]
}
]
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ We provide a recommended version, and it is usually the latest minor version of

| Angular Version | **Nx Version _(recommended)_** | Nx Version _(range)_ |
| --------------- | ------------------------------ | -------------------------------------- |
| ~17.2.0 | **latest** | 18.1.0 <= latest |
| ~17.1.0 | **latest** | 17.3.0 <= latest |
| ~17.0.0 | **latest** | 17.1.0 <= latest |
| ~16.2.0 | **latest** | 16.7.0 <= latest |
Expand Down
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@angular-devkit/architect": "~0.1701.0",
"@angular-devkit/build-angular": "~17.1.0",
"@angular-devkit/core": "~17.1.0",
"@angular-devkit/schematics": "~17.1.0",
"@angular-devkit/architect": "~0.1702.0",
"@angular-devkit/build-angular": "~17.2.0",
"@angular-devkit/core": "~17.2.0",
"@angular-devkit/schematics": "~17.2.0",
"@angular-eslint/eslint-plugin": "17.0.1",
"@angular-eslint/eslint-plugin-template": "17.0.1",
"@angular-eslint/template-parser": "17.0.1",
"@angular/cli": "~17.1.0",
"@angular/common": "~17.1.0",
"@angular/compiler": "~17.1.0",
"@angular/compiler-cli": "~17.1.0",
"@angular/core": "~17.1.0",
"@angular/router": "~17.1.0",
"@angular/cli": "~17.2.0",
"@angular/common": "~17.2.0",
"@angular/compiler": "~17.2.0",
"@angular/compiler-cli": "~17.2.0",
"@angular/core": "~17.2.0",
"@angular/router": "~17.2.0",
"@babel/core": "^7.23.2",
"@babel/helper-create-regexp-features-plugin": "^7.22.9",
"@babel/plugin-transform-runtime": "^7.23.2",
Expand Down Expand Up @@ -93,7 +93,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-url": "^7.0.0",
"@schematics/angular": "~17.1.0",
"@schematics/angular": "~17.2.0",
"@side/jest-runtime": "^1.1.0",
"@storybook/addon-essentials": "7.5.3",
"@storybook/core-server": "7.5.3",
Expand Down Expand Up @@ -228,7 +228,7 @@
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "9.0.3",
"next-sitemap": "^3.1.10",
"ng-packagr": "~17.1.0",
"ng-packagr": "~17.2.0",
"node-fetch": "^2.6.7",
"npm-package-arg": "11.0.1",
"nuxt": "^3.10.0",
Expand Down Expand Up @@ -374,4 +374,3 @@
]
}
}

62 changes: 62 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@
"version": "18.0.0-beta.0",
"description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/angular:webpack-browser' is used for Module Federation.",
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
},
"update-angular-cli-version-17-2-0": {
"cli": "nx",
"version": "18.1.0-beta.1",
"requires": {
"@angular/core": ">=17.2.0"
},
"description": "Update the @angular/cli package version to ~17.2.0.",
"factory": "./src/migrations/update-18-1-0/update-angular-cli"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -1646,6 +1655,59 @@
"alwaysAddToPackageJson": false
}
}
},
"18.1.0": {
"version": "18.1.0-beta.1",
"packages": {
"@angular-devkit/build-angular": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/core": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/schematics": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular/pwa": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular/ssr": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@schematics/angular": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/architect": {
"version": "~0.1702.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-webpack": {
"version": "~0.1702.0",
"alwaysAddToPackageJson": false
},
"@angular/core": {
"version": "~17.2.0",
"alwaysAddToPackageJson": true
},
"@angular/material": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"@angular/cdk": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
},
"ng-packagr": {
"version": "~17.2.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ export function validateOptions(options: Schema): void {
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.`);
}

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}".
You can resolve this error by removing the "prebundle" option or by migrating to Angular 17.2.0.`);
}
}
1 change: 1 addition & 0 deletions packages/angular/src/builders/dev-server/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface BaseSchema {
watch?: boolean;
poll?: number;
forceEsbuild?: boolean;
prebundle?: boolean | { exclude: string[] };
buildLibsFromSource?: boolean;
esbuildMiddleware?: string[];
}
Expand Down
18 changes: 18 additions & 0 deletions packages/angular/src/builders/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@
"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_.",
"default": false
},
"prebundle": {
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders. _Note: this is only supported in Angular versions >= 17.2.0_.",
"oneOf": [
{ "type": "boolean" },
{
"type": "object",
"properties": {
"exclude": {
"description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself.",
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false,
"required": ["exclude"]
}
]
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default async function* applicationExecutor(
const {
buildLibsFromSource = true,
plugins: pluginPaths,
indexHtmlTransformer: indexHtmlTransformerPath,
...delegateExecutorOptions
} = options;

Expand All @@ -36,11 +37,8 @@ export default async function* applicationExecutor(
}

const plugins = await loadPlugins(pluginPaths, options.tsConfig);
const indexHtmlTransformer = options.indexHtmlTransformer
? await loadIndexHtmlTransformer(
options.indexHtmlTransformer,
options.tsConfig
)
const indexHtmlTransformer = indexHtmlTransformerPath
? await loadIndexHtmlTransformer(indexHtmlTransformerPath, options.tsConfig)
: undefined;

const { buildApplication } = await import('@angular-devkit/build-angular');
Expand Down
12 changes: 12 additions & 0 deletions packages/angular/src/executors/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
},
"default": []
},
"clearScreen": {
"type": "boolean",
"default": false,
"description": "Automatically clear the terminal screen during rebuilds. _Note: this is only supported in Angular versions >= 17.2.0_."
},
"optimization": {
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
"default": true,
Expand Down Expand Up @@ -213,6 +218,13 @@
"^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
}
},
"define": {
"description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced. _Note: this is only supported in Angular versions >= 17.2.0_.",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"fileReplacements": {
"description": "Replace compilation source files with other compilation source files in the build.",
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,62 @@ export function validateOptions(options: ApplicationExecutorOptions): void {
);
}

if (options.loader && lt(angularVersion, '17.1.0')) {
throw new Error(
`The "loader" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}
if (lt(angularVersion, '17.1.0')) {
if (options.loader) {
throw new Error(
`The "loader" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}

if (options.indexHtmlTransformer && lt(angularVersion, '17.1.0')) {
throw new Error(
`The "indexHtmlTransformer" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}
if (options.indexHtmlTransformer) {
throw new Error(
`The "indexHtmlTransformer" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}

if (
typeof options.index === 'object' &&
options.index.preloadInitial !== undefined &&
lt(angularVersion, '17.1.0')
) {
throw new Error(
`The "index.preloadInitial" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}
if (
typeof options.index === 'object' &&
options.index.preloadInitial !== undefined
) {
throw new Error(
`The "index.preloadInitial" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
}

if (
options.optimization &&
typeof options.optimization !== 'boolean' &&
options.optimization.styles &&
typeof options.optimization.styles !== 'boolean' &&
lt(angularVersion, '17.1.0')
) {
if (options.optimization.styles.removeSpecialComments === false) {
if (
options.optimization &&
typeof options.optimization !== 'boolean' &&
options.optimization.styles &&
typeof options.optimization.styles !== 'boolean'
) {
if (options.optimization.styles.removeSpecialComments === false) {
throw new Error(
`The "optimization.styles.removeSpecialComments" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
} else if (options.optimization.styles.removeSpecialComments === true) {
// silently remove the option, as it was the default before 17.1.0
delete options.optimization.styles.removeSpecialComments;
}
}

if (typeof options.outputPath === 'object') {
throw new Error(
`The "optimization.styles.removeSpecialComments" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
`The "outputPath" option as an object requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
} else if (options.optimization.styles.removeSpecialComments === true) {
// silently remove the option, as it was the default before 17.1.0
delete options.optimization.styles.removeSpecialComments;
}
}

if (typeof options.outputPath === 'object' && lt(angularVersion, '17.1.0')) {
throw new Error(
`The "outputPath" option as an object requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`
);
if (lt(angularVersion, '17.2.0')) {
if (options.define) {
throw new Error(
`The "define" option requires Angular version 17.2.0 or greater. You are currently using version ${angularVersion}.`
);
}

if (options.clearScreen !== undefined) {
throw new Error(
`The "clearScreen" option requires Angular version 17.2.0 or greater. You are currently using version ${angularVersion}.`
);
}
}
}
Loading