Skip to content

Commit f22d4ee

Browse files
devversionclydin
authored andcommitted
build: setup rules_js and link dependencies
This also requires us to move patches from `patch:` protocol to `patch-package` temporarily. This is because we need to temporarily use pnpm and yarn berry in hybrid, and both don't have any overlap in how patching works; and pnpm would fail if it sees the `patch` protocol.
1 parent 183f772 commit f22d4ee

14 files changed

+15778
-515
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# @generated
2+
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
3+
# This file should be checked into version control along with the pnpm-lock.yaml file.
4+
.npmrc=-2023857461
5+
package.json=1474377014
6+
pnpm-lock.yaml=1733416088
7+
pnpm-workspace.yaml=1711114604
8+
yarn.lock=-607783516

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
run: yarn install --immutable
6666
- name: Run module and package tests
6767
run: yarn bazel test //modules/... //packages/...
68+
env:
69+
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'
6870

6971
e2e:
7072
strategy:

.github/workflows/pr.yml

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jobs:
9999
run: yarn install --immutable
100100
- name: Run module and package tests
101101
run: yarn bazel test //modules/... //packages/...
102+
env:
103+
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'
102104

103105
e2e:
104106
strategy:

.npmrc

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
engine-strict = true
1+
# Yarn Berry doesn't check engines at all, so pnpm shouldn't either.
2+
engine-strict = false
3+
4+
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
5+
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
6+
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules)
7+
hoist=false

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
dist/
1616
/tests/legacy-cli/e2e/assets/
1717
/tools/test/*.json
18+
pnpm-lock.yaml

BUILD.bazel

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
66
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
77
load("@npm//@bazel/concatjs:index.bzl", "ts_config")
8+
load("@npm2//:defs.bzl", "npm_link_all_packages")
89

910
package(default_visibility = ["//visibility:public"])
1011

@@ -19,6 +20,10 @@ exports_files([
1920
"package.json",
2021
])
2122

23+
npm_link_all_packages(
24+
name = "node_modules",
25+
)
26+
2227
# Files required by e2e tests
2328
copy_to_bin(
2429
name = "config-files",

WORKSPACE

+47-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
workspace(name = "angular_cli")
22

3+
DEFAULT_NODE_VERSION = "18.19.1"
4+
35
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
46

57
http_archive(
@@ -27,6 +29,17 @@ load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_d
2729

2830
build_bazel_rules_nodejs_dependencies()
2931

32+
http_archive(
33+
name = "aspect_rules_js",
34+
sha256 = "75c25a0f15a9e4592bbda45b57aa089e4bf17f9176fd735351e8c6444df87b52",
35+
strip_prefix = "rules_js-2.1.0",
36+
url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.0/rules_js-v2.1.0.tar.gz",
37+
)
38+
39+
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
40+
41+
rules_js_dependencies()
42+
3043
http_archive(
3144
name = "rules_pkg",
3245
sha256 = "8c20f74bca25d2d442b327ae26768c02cf3c99e93fad0381f32be9aab1967675",
@@ -70,7 +83,7 @@ nodejs_register_toolchains(
7083
name = "nodejs",
7184
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
7285
node_repositories = NODE_18_REPO,
73-
node_version = "18.19.1",
86+
node_version = DEFAULT_NODE_VERSION,
7487
)
7588

7689
nodejs_register_toolchains(
@@ -103,16 +116,23 @@ nodejs_register_toolchains(
103116
node_version = "22.0.0",
104117
)
105118

119+
load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains")
120+
121+
rules_js_register_toolchains(
122+
node_repositories = NODE_18_REPO,
123+
node_version = DEFAULT_NODE_VERSION,
124+
)
125+
106126
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
107127

108128
yarn_install(
109129
name = "npm",
110130
data = [
111-
"//:.yarn/patches/@angular-bazel-https-9848736cf4.patch",
112-
"//:.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
113-
"//:.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch",
114131
"//:.yarn/releases/yarn-4.5.0.cjs",
115132
"//:.yarnrc.yml",
133+
"//:patches/@angular+bazel+19.0.0-next.7.patch",
134+
"//:patches/@bazel+concatjs+5.8.1.patch",
135+
"//:patches/@bazel+jasmine+5.8.1.patch",
116136
],
117137
# Currently disabled due to:
118138
# 1. Missing Windows support currently.
@@ -152,3 +172,26 @@ load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "
152172
esbuild_repositories(
153173
npm_repository = "npm",
154174
)
175+
176+
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
177+
178+
npm_translate_lock(
179+
name = "npm2",
180+
data = [
181+
"//:package.json",
182+
"//:pnpm-workspace.yaml",
183+
],
184+
npmrc = "//:.npmrc",
185+
patches = {
186+
# Note: Patches not needed as the existing patches are only
187+
# for `rules_nodejs` dependencies :)
188+
},
189+
pnpm_lock = "//:pnpm-lock.yaml",
190+
update_pnpm_lock = True,
191+
verify_node_modules_ignored = "//:.bazelignore",
192+
yarn_lock = "//:yarn.lock",
193+
)
194+
195+
load("@npm2//:repositories.bzl", "npm_repositories")
196+
197+
npm_repositories()

package.json

+9-15
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
"sdk",
1111
"Angular DevKit"
1212
],
13-
"packageManager": "[email protected]",
1413
"scripts": {
1514
"admin": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/devkit-admin.mjs",
1615
"test": "bazel test //packages/...",
1716
"build": "yarn admin build",
1817
"lint": "eslint --cache --max-warnings=0 \"**/*.@(ts|mts|cts)\"",
1918
"templates": "yarn admin templates",
2019
"validate": "yarn admin validate",
21-
"postinstall": "yarn webdriver-update && yarn husky",
20+
"postinstall": "patch-package && yarn webdriver-update && yarn husky",
2221
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
2322
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
2423
"public-api:check": "node goldens/public-api/manage.js test",
@@ -42,18 +41,10 @@
4241
"url": "https://github.com/angular/angular-cli/issues"
4342
},
4443
"homepage": "https://github.com/angular/angular-cli",
45-
"workspaces": {
46-
"packages": [
47-
"packages/angular/*",
48-
"packages/angular_devkit/*",
49-
"packages/ngtools/*",
50-
"packages/schematics/*"
51-
]
52-
},
5344
"devDependencies": {
5445
"@ampproject/remapping": "2.3.0",
5546
"@angular/animations": "19.1.0-next.3",
56-
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=07617f0f8540d27f8895b1820a6f994e1e5b7277#~/.yarn/patches/@angular-bazel-https-9848736cf4.patch",
47+
"@angular/bazel": "https://github.com/angular/bazel-builds.git#07617f0f8540d27f8895b1820a6f994e1e5b7277",
5748
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#d17f802de0af0ac409259f97678ce59ddd0671a0",
5849
"@angular/cdk": "19.1.0-next.2",
5950
"@angular/common": "19.1.0-next.3",
@@ -81,8 +72,8 @@
8172
"@babel/runtime": "7.26.0",
8273
"@bazel/bazelisk": "1.25.0",
8374
"@bazel/buildifier": "7.3.1",
84-
"@bazel/concatjs": "patch:@bazel/concatjs@npm%3A5.8.1#~/.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
85-
"@bazel/jasmine": "patch:@bazel/jasmine@npm%3A5.8.1#~/.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch",
75+
"@bazel/concatjs": "5.8.1",
76+
"@bazel/jasmine": "5.8.1",
8677
"@bazel/rollup": "^5.8.1",
8778
"@bazel/runfiles": "^5.8.1",
8879
"@discoveryjs/json-ext": "0.6.3",
@@ -175,6 +166,7 @@
175166
"ora": "5.4.1",
176167
"pacote": "20.0.0",
177168
"parse5-html-rewriting-stream": "7.0.0",
169+
"patch-package": "^8.0.0",
178170
"picomatch": "4.0.2",
179171
"piscina": "4.8.0",
180172
"postcss": "8.4.49",
@@ -225,8 +217,10 @@
225217
"built": true
226218
}
227219
},
220+
"pnpm": {
221+
"onlyBuiltDependencies": []
222+
},
228223
"resolutions": {
229-
"@bazel/concatjs@npm:5.8.1": "patch:@bazel/concatjs@npm%3A5.8.1#~/.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
230-
"@microsoft/api-extractor/typescript": "5.6.3"
224+
"typescript": "5.7.2"
231225
}
232226
}

.yarn/patches/@angular-bazel-https-9848736cf4.patch renamed to patches/@angular+bazel+19.0.0-next.7.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
diff --git a/src/ng_package/packager.mjs b/src/ng_package/packager.mjs
1+
diff --git a/node_modules/@angular/bazel/src/ng_package/packager.mjs b/node_modules/@angular/bazel/src/ng_package/packager.mjs
22
index 5c1f3a2c72e28a90b666c96b2fe9755cdafd5259..47034ceeb0b9ab9c1e9bee50239723a51d2e2e19 100755
3-
--- a/src/ng_package/packager.mjs
4-
+++ b/src/ng_package/packager.mjs
3+
--- a/node_modules/@angular/bazel/src/ng_package/packager.mjs
4+
+++ b/node_modules/@angular/bazel/src/ng_package/packager.mjs
55
@@ -7,7 +7,7 @@
66
*/
77
import * as fs from 'fs';

.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch renamed to patches/@bazel+concatjs+5.8.1.patch

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
diff --git a/internal/build_defs.bzl b/internal/build_defs.bzl
1+
diff --git a/node_modules/@bazel/concatjs/internal/build_defs.bzl b/node_modules/@bazel/concatjs/internal/build_defs.bzl
22
index 9e5cda684f0456b61d1b6c0f9c56ae021594713f..6c45196bda5880531d32618dfca0dee44c035cb9 100755
3-
--- a/internal/build_defs.bzl
4-
+++ b/internal/build_defs.bzl
3+
--- a/node_modules/@bazel/concatjs/internal/build_defs.bzl
4+
+++ b/node_modules/@bazel/concatjs/internal/build_defs.bzl
55
@@ -76,7 +76,7 @@ _TYPESCRIPT_TYPINGS = Label(
66
"//typescript:typescript__typings",
77
)
8-
8+
99
-_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "esnext"]
1010
+_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2022", "esnext"]
1111
_TYPESCRIPT_MODULE_KINDS = ["none", "commonjs", "amd", "umd", "system", "es2015", "esnext"]
12-
12+
1313
_DEVMODE_TARGET_DEFAULT = "es2015"
14-
diff --git a/internal/common/tsconfig.bzl b/internal/common/tsconfig.bzl
14+
diff --git a/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl b/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
1515
index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1ccea720e 100755
16-
--- a/internal/common/tsconfig.bzl
17-
+++ b/internal/common/tsconfig.bzl
16+
--- a/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
17+
+++ b/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
1818
@@ -211,9 +211,6 @@ def create_tsconfig(
1919
# will convert that to goog.module syntax.
2020
"module": "umd" if devmode_manifest or has_node_runtime else "esnext",
21-
21+
2222
- # Has no effect in closure/ES2015 mode. Always true just for simplicity.
2323
- "downlevelIteration": True,
2424
-
@@ -28,7 +28,7 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
2828
@@ -248,13 +245,6 @@ def create_tsconfig(
2929
# "short name" mappings for npm packages, such as "@angular/core"
3030
"paths": mapped_module_roots,
31-
31+
3232
- # Inline const enums.
3333
- "preserveConstEnums": False,
3434
-
@@ -38,7 +38,7 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
3838
-
3939
# Interpret JSX as React calls (until someone asks for something different)
4040
"jsx": "react",
41-
41+
4242
@@ -277,12 +267,6 @@ def create_tsconfig(
4343
# always emit declaration files in the same location as outDir.
4444
"declarationDir": "/".join([workspace_path, outdir_path]),
@@ -50,12 +50,12 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
5050
- # Implied by inlineSourceMap: True
5151
- "sourceMap": False,
5252
}
53-
53+
5454
# "node_modules" still checked for backward compat for ng_module
55-
diff --git a/internal/tsetse/rules/must_use_promises_rule.js b/internal/tsetse/rules/must_use_promises_rule.js
55+
diff --git a/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js b/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
5656
index e404d01cf80ab4da4b9cca89005b14a60b7d8c79..85488d9a339982af4495d2b5f4c30effb98a538b 100755
57-
--- a/internal/tsetse/rules/must_use_promises_rule.js
58-
+++ b/internal/tsetse/rules/must_use_promises_rule.js
57+
--- a/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
58+
+++ b/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
5959
@@ -30,6 +30,10 @@ function checkCallExpression(checker, node) {
6060
if (tsutils.isExpressionValueUsed(node) || !inAsyncFunction(node)) {
6161
return;
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
diff --git a/jasmine_runner.js b/jasmine_runner.js
1+
diff --git a/node_modules/@bazel/jasmine/jasmine_runner.js b/node_modules/@bazel/jasmine/jasmine_runner.js
22
index 097eb920357f5f02e5b6592e0e4be27c0b4bf25d..bd55c2dad833b32a9e644fed8c7d6b626cd01128 100755
3-
--- a/jasmine_runner.js
4-
+++ b/jasmine_runner.js
3+
--- a/node_modules/@bazel/jasmine/jasmine_runner.js
4+
+++ b/node_modules/@bazel/jasmine/jasmine_runner.js
55
@@ -147,7 +147,7 @@ async function main(args) {
66
// TODO(6.0): remove support for deprecated versions of Jasmine that use the old API &
77
// remember to update the `peerDependencies` as well.
88
// Jasmine versions prior to 4.0.0 should use the old API.
99
- if (jrunner.coreVersion().charAt(0) !== '4') {
1010
+ if (+jrunner.coreVersion().charAt(0) < 4) {
1111
console.warn(`DEPRECATED: Support for Jasmine versions prior to '4.0.x' is deprecated in '@bazel/jasmine'.`);
12-
12+
1313
// Old Jasmine API.

0 commit comments

Comments
 (0)