Skip to content

Commit

Permalink
feat(angular): support angular v19.1.0-rc.0 (#29601)
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 Jan 13, 2025
1 parent ba51e52 commit bf5788c
Show file tree
Hide file tree
Showing 13 changed files with 841 additions and 584 deletions.
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@angular-devkit/architect": "~0.1901.0-next.2",
"@angular-devkit/build-angular": "~19.1.0-next.2",
"@angular-devkit/core": "~19.1.0-next.2",
"@angular-devkit/schematics": "~19.1.0-next.2",
"@angular-devkit/architect": "~0.1901.0-rc.0",
"@angular-devkit/build-angular": "~19.1.0-rc.0",
"@angular-devkit/core": "~19.1.0-rc.0",
"@angular-devkit/schematics": "~19.1.0-rc.0",
"@angular-eslint/eslint-plugin": "19.0.2",
"@angular-eslint/eslint-plugin-template": "19.0.2",
"@angular-eslint/template-parser": "19.0.2",
"@angular/cli": "~19.1.0-next.2",
"@angular/common": "~19.1.0-next.4",
"@angular/compiler": "~19.1.0-next.4",
"@angular/compiler-cli": "~19.1.0-next.4",
"@angular/core": "~19.1.0-next.4",
"@angular/router": "~19.1.0-next.4",
"@angular/cli": "~19.1.0-rc.0",
"@angular/common": "~19.1.0-rc.0",
"@angular/compiler": "~19.1.0-rc.0",
"@angular/compiler-cli": "~19.1.0-rc.0",
"@angular/core": "~19.1.0-rc.0",
"@angular/router": "~19.1.0-rc.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 @@ -107,7 +107,7 @@
"@rspack/dev-server": "1.0.9",
"@rspack/plugin-minify": "^0.7.5",
"@rspack/plugin-react-refresh": "^1.0.0",
"@schematics/angular": "~19.1.0-next.2",
"@schematics/angular": "~19.1.0-rc.0",
"@storybook/addon-essentials": "8.4.6",
"@storybook/addon-interactions": "8.4.6",
"@storybook/core-server": "8.4.6",
Expand Down Expand Up @@ -246,7 +246,7 @@
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "9.0.3",
"next-sitemap": "^3.1.10",
"ng-packagr": "~19.1.0-next.2",
"ng-packagr": "~19.1.0-next.3",
"node-fetch": "^2.6.7",
"npm-package-arg": "11.0.1",
"nuxt": "^3.10.0",
Expand Down
34 changes: 17 additions & 17 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@
"description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.",
"factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package"
},
"update-angular-cli-version-19-1-0-next-2": {
"update-angular-cli-version-19-1-0-rc-0": {
"cli": "nx",
"version": "20.4.0-beta.0",
"requires": {
"@angular/core": ">=19.1.0-next.4"
"@angular/core": ">=19.1.0-rc.0"
},
"description": "Update the @angular/cli package version to ~19.1.0-next.2.",
"description": "Update the @angular/cli package version to ~19.1.0-rc.0.",
"factory": "./src/migrations/update-20-4-0/update-angular-cli"
}
},
Expand Down Expand Up @@ -1429,59 +1429,59 @@
"version": "20.4.0-beta.0",
"x-prompt": "Do you want to update the Angular version to v19.1?",
"requires": {
"@angular/core": ">=19.0.0 <19.1.0-next.4"
"@angular/core": ">=19.0.0 <19.1.0-rc.0"
},
"packages": {
"@angular-devkit/build-angular": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/core": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/schematics": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular/build": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular/pwa": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular/ssr": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@schematics/angular": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/architect": {
"version": "~0.1901.0-next.2",
"version": "~0.1901.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-webpack": {
"version": "~0.1901.0-next.2",
"version": "~0.1901.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular/core": {
"version": "~19.1.0-next.4",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": true
},
"@angular/material": {
"version": "~19.1.0-next.3",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"@angular/cdk": {
"version": "~19.1.0-next.3",
"version": "~19.1.0-rc.0",
"alwaysAddToPackageJson": false
},
"ng-packagr": {
"version": "~19.1.0-next.2",
"version": "~19.1.0-next.3",
"alwaysAddToPackageJson": false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AngularDevkitKarmaMigrator extends BuilderMigrator {
) {
super(
tree,
'@angular-devkit/build-angular:karma',
['@angular-devkit/build-angular:karma'],
'karma',
project,
projectConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class AngularDevkitNgPackagrMigrator extends BuilderMigrator {
) {
super(
tree,
'@angular-devkit/build-angular:ng-packagr',
['@angular-devkit/build-angular:ng-packagr', '@angular/build:ng-packagr'],
undefined,
project,
projectConfig,
Expand All @@ -39,8 +39,11 @@ export class AngularDevkitNgPackagrMigrator extends BuilderMigrator {

if (!this.targets.size) {
this.logger.warn(
`There is no target in the project configuration using the ${this.builderName} builder. This might not be an issue. ` +
`Skipping updating the build configuration.`
`There is no target in the project configuration using the ${this.possibleBuilderNames
.map((b) => `"${b}"`)
.join(', ')} builder${
this.possibleBuilderNames.length > 1 ? 's' : ''
}. This might not be an issue. Skipping updating the build configuration.`
);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AngularEslintLintMigrator extends BuilderMigrator {
) {
super(
tree,
'@angular-eslint/builder:lint',
['@angular-eslint/builder:lint'],
'eslint',
project,
projectConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export abstract class BuilderMigrator extends Migrator {

constructor(
tree: Tree,
public readonly builderName: string,
public readonly possibleBuilderNames: string[],
public readonly rootFileType: WorkspaceRootFileType | undefined,
project: ProjectMigrationInfo,
projectConfig: ProjectConfiguration,
Expand All @@ -40,9 +40,9 @@ export abstract class BuilderMigrator extends Migrator {
// expanding what's supported.
if (this.targets.size > 1) {
errors.push({
message: `There is more than one target using the builder "${
this.builderName
}": ${arrayToString([
message: `There is more than one target using the builder${
this.possibleBuilderNames.length > 1 ? 's' : ''
} ${arrayToString(this.possibleBuilderNames)}: ${arrayToString([
...this.targets.keys(),
])}. This is not currently supported by the automated migration. These targets will be skipped.`,
hint: 'Make sure to manually migrate their configuration and any possible associated files.',
Expand All @@ -61,7 +61,7 @@ export abstract class BuilderMigrator extends Migrator {
for (const [name, target] of Object.entries(
this.projectConfig.targets ?? {}
)) {
if (target.executor === this.builderName) {
if (this.possibleBuilderNames.includes(target.executor)) {
this.targets.set(name, target);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('lib migrator', () => {
`The "build" target is using a builder "@not/supported:builder" that's not currently supported by the automated migration. The target will be skipped.`,
]);
expect(result[0].hint).toMatchInlineSnapshot(
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular/build:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
);
});

Expand All @@ -163,7 +163,7 @@ describe('lib migrator', () => {
`The "test" target is using a builder "@other/not-supported:builder" that's not currently supported by the automated migration. The target will be skipped.`,
]);
expect(result[0].hint).toMatchInlineSnapshot(
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular/build:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
);
});

Expand All @@ -182,7 +182,7 @@ describe('lib migrator', () => {
`The "my-build" target is using a builder "@not/supported:builder" that's not currently supported by the automated migration. The target will be skipped.`,
]);
expect(result[0].hint).toMatchInlineSnapshot(
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
`"Make sure to manually migrate the target configuration and any possible associated files. Alternatively, you could revert the migration, change the builder to one of the builders supported by the automated migration ("@angular-devkit/build-angular:ng-packagr", "@angular/build:ng-packagr", "@angular-devkit/build-angular:karma" and "@angular-eslint/builder:lint"), and run the migration again."`
);
});

Expand All @@ -200,7 +200,7 @@ describe('lib migrator', () => {

expect(result).toHaveLength(1);
expect(result[0].message).toBe(
'There is more than one target using the builder "@angular-devkit/build-angular:ng-packagr": "build1" and "build2". This is not currently supported by the automated migration. These targets will be skipped.'
'There is more than one target using the builders "@angular-devkit/build-angular:ng-packagr" and "@angular/build:ng-packagr": "build1" and "build2". This is not currently supported by the automated migration. These targets will be skipped.'
);
expect(result[0].hint).toBe(
'Make sure to manually migrate their configuration and any possible associated files.'
Expand All @@ -223,7 +223,7 @@ describe('lib migrator', () => {

expect(result).toHaveLength(2);
expect(result[0].message).toBe(
'There is more than one target using the builder "@angular-devkit/build-angular:ng-packagr": "build1" and "build2". This is not currently supported by the automated migration. These targets will be skipped.'
'There is more than one target using the builders "@angular-devkit/build-angular:ng-packagr" and "@angular/build:ng-packagr": "build1" and "build2". This is not currently supported by the automated migration. These targets will be skipped.'
);
expect(result[0].hint).toBe(
'Make sure to manually migrate their configuration and any possible associated files.'
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('lib migrator', () => {
await expect(migrator.migrate()).resolves.not.toThrow();

expect(mockedLogger.warn).toHaveBeenCalledWith(
'There is no target in the project configuration using the @angular-devkit/build-angular:ng-packagr builder. This might not be an issue. Skipping updating the build configuration.'
'There is no target in the project configuration using the "@angular-devkit/build-angular:ng-packagr", "@angular/build:ng-packagr" builders. This might not be an issue. Skipping updating the build configuration.'
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export class ProjectMigrator<
.flat(),
];
allSupportedBuilders.push(
...this.builderMigrators.map((migrator) => migrator.builderName)
...this.builderMigrators.flatMap(
(migrator) => migrator.possibleBuilderNames
)
);
const unsupportedBuilders: [target: string, builder: string][] = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatFiles, Tree, updateJson } from '@nx/devkit';

export const angularCliVersion = '~19.1.0-next.2';
export const angularCliVersion = '~19.1.0-rc.0';

export default async function (tree: Tree) {
let shouldFormat = false;
Expand Down
9 changes: 7 additions & 2 deletions packages/angular/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const knownExecutors = {
'@angular-devkit/build-angular:browser-esbuild',
'@angular-devkit/build-angular:browser',
'@angular-devkit/build-angular:ng-packagr',
'@angular/build:ng-packagr',
]),
devServer: new Set(['@angular-devkit/build-angular:dev-server']),
extractI18n: new Set(['@angular-devkit/build-angular:extract-i18n']),
Expand Down Expand Up @@ -371,7 +372,8 @@ async function updateBuildTarget(
),
];
} else if (
angularTarget.builder === '@angular-devkit/build-angular:ng-packagr'
angularTarget.builder === '@angular-devkit/build-angular:ng-packagr' ||
angularTarget.builder === '@angular/build:ng-packagr'
) {
const outputs = await getNgPackagrOutputs(
angularTarget,
Expand All @@ -393,7 +395,10 @@ async function updateBuildTarget(
: ['default', '^default'];
}

if (angularTarget.builder === '@angular-devkit/build-angular:ng-packagr') {
if (
angularTarget.builder === '@angular-devkit/build-angular:ng-packagr' ||
angularTarget.builder === '@angular/build:ng-packagr'
) {
target.metadata.help.example.options = { watch: true };
} else {
target.metadata.help.example.options = { localize: true };
Expand Down
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 = '~19.1.0-next.4';
export const angularDevkitVersion = '~19.1.0-next.2';
export const ngPackagrVersion = '~19.1.0-next.2';
export const angularVersion = '~19.1.0-rc.0';
export const angularDevkitVersion = '~19.1.0-rc.0';
export const ngPackagrVersion = '~19.1.0-next.3';
export const ngrxVersion = '^19.0.0';
export const rxjsVersion = '~7.8.0';
export const zoneJsVersion = '~0.15.0';
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.6.2';

// TODO: remove when preset generation is reworked and
// deps are not installed from workspace
export const angularCliVersion = '~19.1.0-next.2';
export const angularCliVersion = '~19.1.0-rc.0';
Loading

0 comments on commit bf5788c

Please sign in to comment.