Skip to content

Commit

Permalink
feat(@angular/cli): support for Node.js v22
Browse files Browse the repository at this point in the history
Add support for Node.js v22
  • Loading branch information
alan-agius4 committed Apr 25, 2024
1 parent ffb5428 commit 4087728
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -113,20 +113,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [18, 20]
node: [18, 20, 22]
subset: [npm, yarn, esbuild]
shard: [0, 1, 2, 3, 4, 5]
exclude:
# Exclude Node.js v18 when running on a PR
- node: ${{ github.event_name != 'pull_request' && 'none' || '18' }}
# Exclude Node.js v20 when running on a PR
- node: ${{ github.event_name != 'pull_request' && 'none' || '20' }}
# Exclude Windows when running on a PR
- os: ${{ github.event_name != 'pull_request' && 'none' || 'windows-latest' }}
# Skip yarn subset on Windows
- os: windows-latest
subset: yarn
# Skip node 18 tests on Windows
# Skip Node.js v18 tests on Windows
- os: windows-latest
node: 18
# Skip Node.js v20 tests on Windows
- os: windows-latest
node: 20
runs-on: ${{ matrix.os }}
steps:
- name: Initialize environment
Expand Down
15 changes: 15 additions & 0 deletions WORKSPACE
Expand Up @@ -91,6 +91,21 @@ nodejs_register_toolchains(
node_version = "20.11.1",
)

nodejs_register_toolchains(
name = "node22",
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
node_repositories = {
"22.0.0-darwin_arm64": ("node-v22.0.0-darwin-arm64.tar.gz", "node-v22.0.0-darwin-arm64", "ea96d349cfaa67aa87ceeaa3e5b52c9167f7ac302fd8d1ff162d0785e9dc0785"),
"22.0.0-darwin_amd64": ("node-v22.0.0-darwin-x64.tar.gz", "node-v22.0.0-darwin-x64", "422a3887ff5418f0a4552d89cf99346ab8ab51bb5d384660baa88b8444d2c111"),
"22.0.0-linux_arm64": ("node-v22.0.0-linux-arm64.tar.xz", "node-v22.0.0-linux-arm64", "83711d29cbe46375bdffab5419f3d831892e24294169272f6c39edc364556241"),
"22.0.0-linux_ppc64le": ("node-v22.0.0-linux-ppc64le.tar.xz", "node-v22.0.0-linux-ppc64le", "2b3fb8707a79243bfb3131312b86716ddc3855bce21bb168095b6b916798e5e9"),
"22.0.0-linux_s390x": ("node-v22.0.0-linux-s390x.tar.xz", "node-v22.0.0-linux-s390x", "89a8efeeb9f94ce9ea251b8109e079c14919f4c0dc2cbc9f545ec47ef0886737"),
"22.0.0-linux_amd64": ("node-v22.0.0-linux-x64.tar.xz", "node-v22.0.0-linux-x64", "9122e50f2642afd5f6078cafd1f52ede60fc464284384f05c18a04d13d07ae5a"),
"22.0.0-windows_amd64": ("node-v22.0.0-win-x64.zip", "node-v22.0.0-win-x64", "32d639b47d4c0a651ff8f8d7d41a454168a3d4045be37985f9a810cf8cef6174"),
},
node_version = "22.0.0",
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

yarn_install(
Expand Down
2 changes: 1 addition & 1 deletion constants.bzl
@@ -1,5 +1,5 @@
# Engine versions to stamp in a release package.json
RELEASE_ENGINES_NODE = "^18.19.1 || >=20.11.1"
RELEASE_ENGINES_NODE = "^18.19.1 || ^20.11.1 || >=22.0.0"
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
RELEASE_ENGINES_YARN = ">= 1.13.0"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -31,7 +31,7 @@
"url": "https://github.com/angular/angular-cli.git"
},
"engines": {
"node": "^18.19.1 || >=20.11.1",
"node": "^18.19.1 || ^20.11.1 || >=22.0.0",
"yarn": ">=1.21.1 <2",
"npm": "Please use yarn instead of NPM to install dependencies"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/version/cli.ts
Expand Up @@ -23,7 +23,7 @@ interface PartialPackageInfo {
/**
* Major versions of Node.js that are officially supported by Angular.
*/
const SUPPORTED_NODE_MAJORS = [18, 20];
const SUPPORTED_NODE_MAJORS = [18, 20, 22];

const PACKAGE_PATTERNS = [
/^@angular\/.*/,
Expand Down
6 changes: 6 additions & 0 deletions tools/toolchain_info.bzl
Expand Up @@ -5,6 +5,7 @@
TOOLCHAINS_NAMES = [
"node18",
"node20",
"node22",
]

# this is the list of toolchains that should be used and are registered with nodejs_register_toolchains in the WORKSPACE file
Expand All @@ -19,6 +20,11 @@ TOOLCHAINS_VERSIONS = [
"@bazel_tools//src/conditions:darwin": "@node20_darwin_amd64//:node_toolchain",
"@bazel_tools//src/conditions:windows": "@node20_windows_amd64//:node_toolchain",
}),
select({
"@bazel_tools//src/conditions:linux_x86_64": "@node22_linux_amd64//:node_toolchain",
"@bazel_tools//src/conditions:darwin": "@node22_darwin_amd64//:node_toolchain",
"@bazel_tools//src/conditions:windows": "@node22_windows_amd64//:node_toolchain",
}),
]

# A default toolchain for use when only one is necessary
Expand Down

0 comments on commit 4087728

Please sign in to comment.