Skip to content

Commit

Permalink
feat(angular): support angular v18.2.0 (#27379)
Browse files Browse the repository at this point in the history
<!-- 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 Aug 14, 2024
1 parent 0d97039 commit c0f5c15
Show file tree
Hide file tree
Showing 10 changed files with 2,077 additions and 396 deletions.
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)_ |
| --------------- | ------------------------------ | ---------------------------------------- |
| ~18.2.0 | **latest** | >=19.6.0 <=latest |
| ~18.1.0 | **latest** | >=19.5.0 <=latest |
| ~18.0.0 | **latest** | >=19.1.0 <=latest |
| ~17.3.0 | **latest** | >=18.2.0 <=latest |
Expand Down
1 change: 1 addition & 0 deletions docs/shared/packages/angular/angular-nx-version-matrix.md
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)_ |
| --------------- | ------------------------------ | ---------------------------------------- |
| ~18.2.0 | **latest** | >=19.6.0 <=latest |
| ~18.1.0 | **latest** | >=19.5.0 <=latest |
| ~18.0.0 | **latest** | >=19.1.0 <=latest |
| ~17.3.0 | **latest** | >=18.2.0 <=latest |
Expand Down
24 changes: 12 additions & 12 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.1801.0",
"@angular-devkit/build-angular": "~18.1.0",
"@angular-devkit/core": "~18.1.0",
"@angular-devkit/schematics": "~18.1.0",
"@angular-devkit/architect": "~0.1802.0",
"@angular-devkit/build-angular": "~18.2.0",
"@angular-devkit/core": "~18.2.0",
"@angular-devkit/schematics": "~18.2.0",
"@angular-eslint/eslint-plugin": "^18.0.1",
"@angular-eslint/eslint-plugin-template": "^18.0.1",
"@angular-eslint/template-parser": "^18.0.1",
"@angular/cli": "~18.1.0",
"@angular/common": "~18.1.0",
"@angular/compiler": "~18.1.0",
"@angular/compiler-cli": "~18.1.0",
"@angular/core": "~18.1.0",
"@angular/router": "~18.1.0",
"@angular/cli": "~18.2.0",
"@angular/common": "~18.2.0",
"@angular/compiler": "~18.2.0",
"@angular/compiler-cli": "~18.2.0",
"@angular/core": "~18.2.0",
"@angular/router": "~18.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 @@ -95,7 +95,7 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-url": "^8.0.2",
"@schematics/angular": "~18.1.0",
"@schematics/angular": "~18.2.0",
"@storybook/addon-essentials": "^8.2.8",
"@storybook/addon-interactions": "^8.2.8",
"@storybook/core-server": "^8.2.8",
Expand Down Expand Up @@ -233,7 +233,7 @@
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "9.0.3",
"next-sitemap": "^3.1.10",
"ng-packagr": "~18.1.0",
"ng-packagr": "~18.2.0",
"node-fetch": "^2.6.7",
"npm-package-arg": "11.0.1",
"nuxt": "^3.10.0",
Expand Down
70 changes: 70 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@
"version": "19.6.0-beta.4",
"description": "Ensure Module Federation DTS is turned off by default.",
"factory": "./src/migrations/update-19-6-0/turn-off-dts-by-default"
},
"update-angular-cli-version-18-2-0": {
"cli": "nx",
"version": "19.6.0-beta.7",
"requires": {
"@angular/core": ">=18.2.0"
},
"description": "Update the @angular/cli package version to ~18.2.0.",
"factory": "./src/migrations/update-19-6-0/update-angular-cli"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -2034,6 +2043,67 @@
"alwaysAddToPackageJson": false
}
}
},
"19.6.0": {
"version": "19.6.0-beta.7",
"x-prompt": "Do you want to update the Angular version to v18.2?",
"requires": {
"@angular/core": ">=18.1.0 <18.2.0"
},
"packages": {
"@angular-devkit/build-angular": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/core": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/schematics": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular/build": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular/pwa": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular/ssr": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@schematics/angular": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/architect": {
"version": "~0.1802.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-webpack": {
"version": "~0.1802.0",
"alwaysAddToPackageJson": false
},
"@angular/core": {
"version": "~18.2.0",
"alwaysAddToPackageJson": true
},
"@angular/material": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"@angular/cdk": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
},
"ng-packagr": {
"version": "~18.2.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { registerTsProject } from '@nx/js/src/internal';
import type { Plugin } from 'esbuild';
import { loadModule } from './module-loader';

// This is a workaround to make sure we use the same esbuild version as the
// Angular DevKit uses. This is only used internally to load the plugins and
// forward them to the Angular DevKit builders.
type Plugin = Parameters<
typeof import('@angular-devkit/build-angular').buildApplication
>[2]['codePlugins'][number];

export type PluginSpec = {
path: string;
options: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { readJson, Tree, writeJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import updateAngularCli, { angularCliVersion } from './update-angular-cli';

describe('update-angular-cli migration', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
});

it('should update @angular/cli version when defined as a dev dependency', async () => {
writeJson(tree, 'package.json', {
devDependencies: { '@angular/cli': '~13.3.0' },
});

await updateAngularCli(tree);

const { devDependencies } = readJson(tree, 'package.json');
expect(devDependencies['@angular/cli']).toBe(angularCliVersion);
});

it('should update @angular/cli version when defined as a dependency', async () => {
writeJson(tree, 'package.json', {
dependencies: { '@angular/cli': '~13.3.0' },
});

await updateAngularCli(tree);

const { dependencies } = readJson(tree, 'package.json');
expect(dependencies['@angular/cli']).toBe(angularCliVersion);
});

it('should not add @angular/cli to package.json when it is not set', async () => {
const initialPackageJson = readJson(tree, 'package.json');

await updateAngularCli(tree);

const packageJson = readJson(tree, 'package.json');
expect(packageJson).toStrictEqual(initialPackageJson);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { formatFiles, Tree, updateJson } from '@nx/devkit';

export const angularCliVersion = '~18.2.0';

export default async function (tree: Tree) {
let shouldFormat = false;

updateJson(tree, 'package.json', (json) => {
if (json.devDependencies?.['@angular/cli']) {
json.devDependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
} else if (json.dependencies?.['@angular/cli']) {
json.dependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
}

return json;
});

if (shouldFormat) {
await formatFiles(tree);
}
}
6 changes: 3 additions & 3 deletions packages/angular/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const nxVersion = require('../../package.json').version;

export const angularVersion = '~18.1.0';
export const angularDevkitVersion = '~18.1.0';
export const ngPackagrVersion = '~18.1.0';
export const angularVersion = '~18.2.0';
export const angularDevkitVersion = '~18.2.0';
export const ngPackagrVersion = '~18.2.0';
export const ngrxVersion = '^18.0.1';
export const rxjsVersion = '~7.8.0';
export const zoneJsVersion = '~0.14.3';
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const typescriptVersion = '~5.5.2';

// TODO: remove when preset generation is reworked and
// deps are not installed from workspace
export const angularCliVersion = '~18.1.0';
export const angularCliVersion = '~18.2.0';
Loading

0 comments on commit c0f5c15

Please sign in to comment.