Skip to content

Commit ac37218

Browse files
committed
build: migrate @angular-devkit/architect jasmine test to native rules_js
Instead of using `rules_nodejs` interop and the linker at runtime, the test target is migrated to the new `jasmine_test` rule, leveraging the pnpm workspace for first-party dependencies. Note that in the future we may be able to rename the local node modules to something more clear. e.g. `:local_modules/@angular-devkit/core`, but for now this is not possible :( This commit shows how similar packages can be migrated in the future.
1 parent 96b6a16 commit ac37218

File tree

8 files changed

+101
-29
lines changed

8 files changed

+101
-29
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=-2023857461
5-
package.json=2030416769
6-
pnpm-lock.yaml=757562281
7-
pnpm-workspace.yaml=1711114604
8-
yarn.lock=-1189684420
5+
package.json=1373382412
6+
packages/angular_devkit/architect/package.json=-107274537
7+
packages/angular_devkit/core/package.json=339935828
8+
pnpm-lock.yaml=1069382541
9+
pnpm-workspace.yaml=-1853274682
10+
yarn.lock=-1457550495

WORKSPACE

+14
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ npm_translate_lock(
186186
data = [
187187
"//:package.json",
188188
"//:pnpm-workspace.yaml",
189+
"//packages/angular_devkit/architect:package.json",
190+
"//packages/angular_devkit/core:package.json",
189191
],
190192
npmrc = "//:.npmrc",
191193
patches = {
@@ -225,3 +227,15 @@ http_file(
225227
sha256 = "5a5c46846ecda83e05b9da26f1672ad51c59bce08fed88419850d0e29c993b30",
226228
urls = ["https://github.com/raw/devversion/rules_angular/4b7532ba2b29078d005899cd15b415593d03cceb/dist/worker.mjs"],
227229
)
230+
231+
http_archive(
232+
name = "aspect_rules_jasmine",
233+
sha256 = "0d2f9c977842685895020cac721d8cc4f1b37aae15af46128cf619741dc61529",
234+
strip_prefix = "rules_jasmine-2.0.0",
235+
url = "https://github.com/aspect-build/rules_jasmine/releases/download/v2.0.0/rules_jasmine-v2.0.0.tar.gz",
236+
)
237+
238+
load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies")
239+
240+
# Fetch dependencies which users need as well
241+
rules_jasmine_dependencies()

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"@types/http-proxy": "^1.17.4",
9292
"@types/ini": "^4.0.0",
9393
"@types/jasmine": "~5.1.0",
94+
"@types/jasmine-reporters": "^2",
9495
"@types/karma": "^6.3.0",
9596
"@types/less": "^3.0.3",
9697
"@types/loader-utils": "^2.0.0",
@@ -141,6 +142,7 @@
141142
"istanbul-lib-instrument": "6.0.3",
142143
"jasmine": "^5.0.0",
143144
"jasmine-core": "~5.5.0",
145+
"jasmine-reporters": "^2.5.2",
144146
"jasmine-spec-reporter": "~7.0.0",
145147
"jsonc-parser": "3.3.1",
146148
"karma": "~6.4.0",

packages/angular_devkit/architect/BUILD.bazel

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
# found in the LICENSE file at https://angular.dev/license
55

66
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
7-
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
8-
load("//tools:defaults2.bzl", "npm_package", "ts_project")
7+
load("@npm2//:defs.bzl", "npm_link_all_packages")
8+
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
99
load("//tools:ts_json_schema.bzl", "ts_json_schema")
1010

11+
package(default_visibility = ["//visibility:public"])
12+
1113
licenses(["notice"])
1214

13-
package(default_visibility = ["//visibility:public"])
15+
npm_link_all_packages()
1416

1517
ts_json_schema(
1618
name = "builder_input_schema",
@@ -66,10 +68,9 @@ ts_project(
6668
data = JSON_FILES,
6769
module_name = "@angular-devkit/architect",
6870
deps = [
71+
":node_modules/@angular-devkit/core",
6972
"//:node_modules/@types/node",
7073
"//:node_modules/rxjs",
71-
"//packages/angular_devkit/core:core_rjs",
72-
"//packages/angular_devkit/core/node:node_rjs",
7374
],
7475
)
7576

@@ -79,16 +80,16 @@ ts_project(
7980
srcs = glob(["src/**/*_spec.ts"]),
8081
deps = [
8182
":architect_rjs",
83+
":node_modules/@angular-devkit/core",
8284
"//:node_modules/@types/jasmine",
8385
"//:node_modules/rxjs",
8486
"//packages/angular_devkit/architect/testing:testing_rjs",
85-
"//packages/angular_devkit/core:core_rjs",
8687
],
8788
)
8889

89-
jasmine_node_test(
90+
jasmine_test(
9091
name = "architect_test",
91-
srcs = [":architect_test_lib"],
92+
data = [":architect_test_lib_rjs"],
9293
)
9394

9495
# @external_begin

pnpm-lock.yaml

+46-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
packages:
22
- .
3+
- packages/angular_devkit/architect
4+
- packages/angular_devkit/core

tools/defaults2.bzl

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
12
load("//tools:interop.bzl", _ts_project = "ts_project")
23
load("//tools/bazel:npm_package.bzl", _npm_package = "npm_package")
34

@@ -6,3 +7,11 @@ def ts_project(**kwargs):
67

78
def npm_package(**kwargs):
89
_npm_package(**kwargs)
10+
11+
def jasmine_test(**kwargs):
12+
_jasmine_test(
13+
node_modules = "//:node_modules",
14+
chdir = native.package_name(),
15+
args = ["**/*.js"],
16+
**kwargs
17+
)

yarn.lock

+13-2
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ __metadata:
360360
"@types/http-proxy": "npm:^1.17.4"
361361
"@types/ini": "npm:^4.0.0"
362362
"@types/jasmine": "npm:~5.1.0"
363+
"@types/jasmine-reporters": "npm:^2"
363364
"@types/karma": "npm:^6.3.0"
364365
"@types/less": "npm:^3.0.3"
365366
"@types/loader-utils": "npm:^2.0.0"
@@ -410,6 +411,7 @@ __metadata:
410411
istanbul-lib-instrument: "npm:6.0.3"
411412
jasmine: "npm:^5.0.0"
412413
jasmine-core: "npm:~5.5.0"
414+
jasmine-reporters: "npm:^2.5.2"
413415
jasmine-spec-reporter: "npm:~7.0.0"
414416
jsonc-parser: "npm:3.3.1"
415417
karma: "npm:~6.4.0"
@@ -4481,7 +4483,16 @@ __metadata:
44814483
languageName: node
44824484
linkType: hard
44834485

4484-
"@types/jasmine@npm:~5.1.0":
4486+
"@types/jasmine-reporters@npm:^2":
4487+
version: 2.5.3
4488+
resolution: "@types/jasmine-reporters@npm:2.5.3"
4489+
dependencies:
4490+
"@types/jasmine": "npm:*"
4491+
checksum: 10c0/9e895e1b258bf59fbd7bb8c9079681ad48e1035c33c36e3ab0aa2034fd87e95abf71ef848996c21ca9ecd5a72ce2897cc26162fedf12e0ebaad9969f138a84a4
4492+
languageName: node
4493+
linkType: hard
4494+
4495+
"@types/jasmine@npm:*, @types/jasmine@npm:~5.1.0":
44854496
version: 5.1.5
44864497
resolution: "@types/jasmine@npm:5.1.5"
44874498
checksum: 10c0/904a2a6bfe7478478ec73d502708dc4b4cc46fa554c459cee3e0be01efda96fba7d26ef8bec2f246d9163cc517407b135acabcf6f076c11aa514ed9b79bc67e5
@@ -11325,7 +11336,7 @@ __metadata:
1132511336
languageName: node
1132611337
linkType: hard
1132711338

11328-
"jasmine-reporters@npm:~2.5.0":
11339+
"jasmine-reporters@npm:^2.5.2, jasmine-reporters@npm:~2.5.0":
1132911340
version: 2.5.2
1133011341
resolution: "jasmine-reporters@npm:2.5.2"
1133111342
dependencies:

0 commit comments

Comments
 (0)