Skip to content

Commit 31cbf5f

Browse files
committed
build: replace hardcoded Angular and ng-packagr peer dependencies with Bazel stamping
Refactor the build configuration to use Bazel stamping for Angular and ng-packagr dependencies, eliminating the need for hardcoded peer dependencies.
1 parent 2046ce4 commit 31cbf5f

File tree

12 files changed

+35
-37
lines changed

12 files changed

+35
-37
lines changed

Diff for: constants.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RELEASE_ENGINES_NODE = "^18.19.1 || ^20.11.1 || >=22.0.0"
33
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
44
RELEASE_ENGINES_YARN = ">= 1.13.0"
55

6+
NG_PACKAGR_VERSION = "^19.1.0-next.0"
7+
ANGULAR_FW_VERSION = "^19.1.0-next.0"
8+
ANGULAR_FW_PEER_DEP = "^19.0.0 || ^19.1.0-next.0"
9+
NG_PACKAGR_PEER_DEP = "^19.0.0 || ^19.1.0-next.0"
10+
611
SNAPSHOT_REPOS = {
712
"@angular/cli": "angular/cli-builds",
813
"@angular/pwa": "angular/angular-pwa-builds",

Diff for: docs/process/release.md

+3-13
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,14 @@ Releasing is performed using Angular's unified release tooling. Each week, two r
6969

7070
Once FW releases the actual minor/major release (for example: `13.0.0` or `13.1.0`), update dependencies with the following:
7171

72-
1. Run `sed -i -E "s, \|\| \^13\.1\.0-(next|rc)\.[0-9]+,,g" packages/**/package.json` with the release version to remove prerelease tags.
73-
- No need to update `devDependencies` in the root `package.json`, Renovate will get them later.
74-
2. Update [`latest-versions/package.json`](packages/schematics/angular/utility/latest-versions/package.json) so `@angular/core` and `ng-packagr` are using the release version (drop `-rc.0` / `-next.0`).
75-
- This is the file used by `ng new` to determine versions in the generated `package.json` seen by developers.
76-
3. Run `yarn -s bazel run @npm2//:sync` to update the pnpm lockfile.
72+
1. Update [`constants.bzl`](../../constants.bzl) so `@angular/core` and `ng-packagr` are using the release version (drop `-next.0`).
7773

78-
Merge the above two changes in a separate PR which lands _after_ FW releases (or else CI will fail) but _before_ the CLI
74+
Merge the above change in a separate PR which lands _after_ FW releases (or else CI will fail) but _before_ the CLI
7975
release PR. Releases are built before the PR is sent for review, so any changes after that point won't be included in the release.
8076

81-
**AFTER a major CLI release:**
82-
83-
Once a major release is complete, peer dependencies in the above files will need to be updated to "undo" the above change and add the
84-
prerelease version segment on `main`. For example, `"@angular/compiler-cli": "^13.0.0-next.0"` should become
85-
`"@angular/compiler-cli": "^13.0.0 || ^13.1.0-next.0"`. This should be done for all the peer deps in the above files.
86-
8777
**AFTER a minor OR major CLI release:**
8878

89-
`latest-versions.ts` also needs to be updated to use `-next.0` after a major or minor release. However this needs to happen _after_ FW
79+
`constants.bzl` also needs to be updated to use `-next.0` after a major or minor release. However this needs to happen _after_ FW
9080
publishes the initial `-next.0` release, which will happen 1 week after the major or minor release.
9181

9282
## Releasing the CLI

Diff for: packages/angular/build/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
"lmdb": "3.2.2"
4949
},
5050
"peerDependencies": {
51-
"@angular/compiler": "^19.0.0 || ^19.1.0-next.0",
52-
"@angular/compiler-cli": "^19.0.0 || ^19.1.0-next.0",
53-
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
54-
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
55-
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
51+
"@angular/compiler": "0.0.0-ANGULAR-FW-PEER-DEP",
52+
"@angular/compiler-cli": "0.0.0-ANGULAR-FW-PEER-DEP",
53+
"@angular/localize": "0.0.0-ANGULAR-FW-PEER-DEP",
54+
"@angular/platform-server": "0.0.0-ANGULAR-FW-PEER-DEP",
55+
"@angular/service-worker": "0.0.0-ANGULAR-FW-PEER-DEP",
5656
"@angular/ssr": "^0.0.0-PLACEHOLDER",
5757
"less": "^4.2.0",
58-
"ng-packagr": "^19.0.0 || ^19.1.0-next.0",
58+
"ng-packagr": "0.0.0-NG-PACKAGR-PEER-DEP",
5959
"postcss": "^8.4.0",
6060
"tailwindcss": "^2.0.0 || ^3.0.0",
6161
"typescript": ">=5.5 <5.8"

Diff for: packages/angular/pwa/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"parse5-html-rewriting-stream": "7.0.0"
1818
},
1919
"peerDependencies": {
20-
"@angular/cli": "^19.0.0 || ^19.1.0-next.0"
20+
"@angular/cli": "0.0.0-ANGULAR-FW-PEER-DEP"
2121
},
2222
"peerDependenciesMeta": {
2323
"@angular/cli": {

Diff for: packages/angular/ssr/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"tslib": "^2.3.0"
1717
},
1818
"peerDependencies": {
19-
"@angular/common": "^19.0.0 || ^19.1.0-next.0",
20-
"@angular/core": "^19.0.0 || ^19.1.0-next.0",
21-
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
22-
"@angular/router": "^19.0.0 || ^19.1.0-next.0"
19+
"@angular/common": "0.0.0-ANGULAR-FW-PEER-DEP",
20+
"@angular/core": "0.0.0-ANGULAR-FW-PEER-DEP",
21+
"@angular/platform-server": "0.0.0-ANGULAR-FW-PEER-DEP",
22+
"@angular/router": "0.0.0-ANGULAR-FW-PEER-DEP"
2323
},
2424
"peerDependenciesMeta": {
2525
"@angular/platform-server": {

Diff for: packages/angular_devkit/build_angular/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@
6969
"undici": "7.2.3"
7070
},
7171
"peerDependencies": {
72-
"@angular/compiler-cli": "^19.0.0 || ^19.1.0-next.0",
73-
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
74-
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
75-
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
72+
"@angular/compiler-cli": "0.0.0-ANGULAR-FW-PEER-DEP",
73+
"@angular/localize": "0.0.0-ANGULAR-FW-PEER-DEP",
74+
"@angular/platform-server": "0.0.0-ANGULAR-FW-PEER-DEP",
75+
"@angular/service-worker": "0.0.0-ANGULAR-FW-PEER-DEP",
7676
"@angular/ssr": "^0.0.0-PLACEHOLDER",
7777
"@web/test-runner": "^0.19.0",
7878
"browser-sync": "^3.0.2",
7979
"jest": "^29.5.0",
8080
"jest-environment-jsdom": "^29.5.0",
8181
"karma": "^6.3.0",
82-
"ng-packagr": "^19.0.0 || ^19.1.0-next.0",
82+
"ng-packagr": "0.0.0-NG-PACKAGR-PEER-DEP",
8383
"protractor": "^7.0.0",
8484
"tailwindcss": "^2.0.0 || ^3.0.0",
8585
"typescript": ">=5.5 <5.8"

Diff for: packages/ngtools/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/angular/angular-cli/tree/main/packages/ngtools/webpack",
2323
"peerDependencies": {
24-
"@angular/compiler-cli": "^19.0.0 || ^19.1.0-next.0",
24+
"@angular/compiler-cli": "0.0.0-ANGULAR-FW-PEER-DEP",
2525
"typescript": ">=5.5 <5.8",
2626
"webpack": "^5.54.0"
2727
},

Diff for: packages/schematics/angular/library/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function addDependenciesToPackageJson() {
5959
{
6060
type: NodeDependencyType.Dev,
6161
name: 'ng-packagr',
62-
version: latestVersions['ng-packagr'],
62+
version: latestVersions.NgPackagr,
6363
},
6464
{
6565
type: NodeDependencyType.Default,

Diff for: packages/schematics/angular/library/index_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('Library Schematic', () => {
218218
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
219219

220220
const packageJson = getJsonFileContent(tree, 'package.json');
221-
expect(packageJson.devDependencies['ng-packagr']).toEqual(latestVersions['ng-packagr']);
221+
expect(packageJson.devDependencies['ng-packagr']).toBeDefined();
222222
});
223223

224224
it('should use the latest known versions in package.json', async () => {

Diff for: packages/schematics/angular/utility/latest-versions.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export const latestVersions: Record<string, string> & {
1515
DevkitBuildAngular: string;
1616
AngularBuild: string;
1717
AngularSSR: string;
18+
NgPackagr: string;
1819
} = {
1920
...dependencies,
2021

2122
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
22-
Angular: dependencies['@angular/core'],
23-
23+
Angular: '0.0.0-ANGULAR-FW-VERSION',
24+
NgPackagr: '0.0.0-NG-PACKAGR-VERSION',
2425
DevkitBuildAngular: '^0.0.0-PLACEHOLDER',
2526
AngularBuild: '^0.0.0-PLACEHOLDER',
2627
AngularSSR: '^0.0.0-PLACEHOLDER',

Diff for: packages/schematics/angular/utility/latest-versions/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"comment": "This file is needed so that dependencies are synced by Renovate.",
44
"private": true,
55
"dependencies": {
6-
"@angular/core": "^19.1.0-next.0",
76
"@types/express": "^4.17.17",
87
"@types/jasmine": "~5.1.0",
98
"@types/node": "^18.18.0",
@@ -17,7 +16,6 @@
1716
"karma-jasmine": "~5.1.0",
1817
"karma": "~6.4.0",
1918
"less": "^4.2.0",
20-
"ng-packagr": "^19.1.0-next.0",
2119
"postcss": "^8.4.38",
2220
"protractor": "~7.0.0",
2321
"rxjs": "~7.8.0",

Diff for: tools/substitutions.bzl

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//:constants.bzl", "RELEASE_ENGINES_NODE", "RELEASE_ENGINES_NPM", "RELEASE_ENGINES_YARN")
1+
load("//:constants.bzl", "ANGULAR_FW_PEER_DEP", "ANGULAR_FW_VERSION", "NG_PACKAGR_PEER_DEP", "NG_PACKAGR_VERSION", "RELEASE_ENGINES_NODE", "RELEASE_ENGINES_NPM", "RELEASE_ENGINES_YARN")
22

33
NPM_PACKAGE_SUBSTITUTIONS = {
44
# Version of the local package being built, generated via the `--workspace_status_command` flag.
@@ -8,6 +8,10 @@ NPM_PACKAGE_SUBSTITUTIONS = {
88
"0.0.0-ENGINES-NODE": RELEASE_ENGINES_NODE,
99
"0.0.0-ENGINES-NPM": RELEASE_ENGINES_NPM,
1010
"0.0.0-ENGINES-YARN": RELEASE_ENGINES_YARN,
11+
"0.0.0-NG-PACKAGR-VERSION": NG_PACKAGR_VERSION,
12+
"0.0.0-NG-PACKAGR-PEER-DEP": NG_PACKAGR_PEER_DEP,
13+
"0.0.0-ANGULAR-FW-VERSION": ANGULAR_FW_VERSION,
14+
"0.0.0-ANGULAR-FW-PEER-DEP": ANGULAR_FW_PEER_DEP,
1115
# The below is needed for @angular/ssr FESM file.
1216
"\\./(.+)/packages/angular/ssr/third_party/beasties": "../third_party/beasties/index.js",
1317
}

0 commit comments

Comments
 (0)