Skip to content

Commit

Permalink
build: migrate @angular/build tests to rules_js
Browse files Browse the repository at this point in the history
Migrates `@angular/build` tests to native `rules_js`. This involves
wiring up the package in the pnpm workspace, as well as adding some
missing dependencies that previously weren't needed due to less
efficient per-package isolation of transitive deps.

In addition, we need to explicitly specify `ssr` as dev dependency as we
are not auto-installing peer deps, and the dependency is needed for some
server SSR tests.
  • Loading branch information
devversion committed Jan 28, 2025
1 parent 5afcfc0 commit 66fa06c
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 916 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
.npmrc=-1406867100
modules/testing/builder/package.json=-1769051440
package.json=688000741
packages/angular/build/package.json=1789788715
modules/testing/builder/package.json=-1196120648
package.json=-865553716
packages/angular/build/package.json=954937711
packages/angular/cli/package.json=349838588
packages/angular/pwa/package.json=-1352285148
packages/angular/ssr/package.json=120782115
Expand All @@ -17,6 +17,6 @@ packages/angular_devkit/schematics/package.json=673943597
packages/angular_devkit/schematics_cli/package.json=-356386813
packages/ngtools/webpack/package.json=-942726894
packages/schematics/angular/package.json=251715148
pnpm-lock.yaml=-870184322
pnpm-workspace.yaml=-1173266031
pnpm-lock.yaml=1087719969
pnpm-workspace.yaml=-1847919625
yarn.lock=969972397
6 changes: 5 additions & 1 deletion modules/testing/builder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ ts_project(
"src/**/*_spec.ts",
],
),
data = glob(["projects/**/*"]),
data = [
# Needed at runtime by some builder tests relying on SSR being
# resolvable in the test project.
":node_modules/@angular/ssr",
] + glob(["projects/**/*"]),
deps = [
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
Expand Down
3 changes: 2 additions & 1 deletion modules/testing/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"devDependencies": {
"@angular-devkit/core": "workspace:*",
"@angular-devkit/architect": "workspace:*"
"@angular-devkit/architect": "workspace:*",
"@angular/ssr": "workspace:*"
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@
}
},
"pnpm": {
"onlyBuiltDependencies": []
"onlyBuiltDependencies": [],
"overrides": {
"@angular/build": "workspace:*"
}
},
"resolutions": {
"typescript": "5.7.3"
Expand Down
41 changes: 17 additions & 24 deletions packages/angular/build/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
load("//tools:ts_json_schema.bzl", "ts_json_schema")

licenses(["notice"])

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

npm_link_all_packages()

ts_json_schema(
name = "application_schema",
src = "src/builders/application/schema.json",
Expand Down Expand Up @@ -61,6 +63,9 @@ ts_project(
data = RUNTIME_ASSETS,
module_name = "@angular/build",
deps = [
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
":node_modules/@angular/ssr",
"//:node_modules/@ampproject/remapping",
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
Expand All @@ -87,7 +92,9 @@ ts_project(
"//:node_modules/esbuild-wasm",
"//:node_modules/fast-glob",
"//:node_modules/https-proxy-agent",
"//:node_modules/istanbul-lib-instrument",
"//:node_modules/jsonc-parser",
"//:node_modules/less",
"//:node_modules/listr2",
"//:node_modules/lmdb",
"//:node_modules/magic-string",
Expand All @@ -104,10 +111,6 @@ ts_project(
"//:node_modules/typescript",
"//:node_modules/vite",
"//:node_modules/watchpack",
"//packages/angular/ssr:ssr_rjs",
"//packages/angular/ssr/node:node_rjs",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/core:core_rjs",
],
)

Expand All @@ -126,14 +129,12 @@ ts_project(
"//:node_modules/prettier",
"//:node_modules/typescript",
"//packages/angular/build/private:private_rjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
],
)

jasmine_node_test(
jasmine_test(
name = "unit_tests",
deps = [":unit_test_lib"],
data = [":unit_test_lib_rjs"],
)

ts_project(
Expand All @@ -144,11 +145,7 @@ ts_project(
":build_rjs",
"//packages/angular/build/private:private_rjs",
"//modules/testing/builder:builder_rjs",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/architect/node:node_rjs",
"//packages/angular_devkit/architect/testing:testing_rjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
":node_modules/@angular-devkit/architect",

# Base dependencies for the application in hello-world-app.
"//:node_modules/@angular/common",
Expand All @@ -174,11 +171,7 @@ ts_project(
":build_rjs",
"//packages/angular/build/private:private_rjs",
"//modules/testing/builder:builder_rjs",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/architect/node:node_rjs",
"//packages/angular_devkit/architect/testing:testing_rjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
":node_modules/@angular-devkit/architect",

# dev server only test deps
"//:node_modules/@types/http-proxy",
Expand All @@ -202,20 +195,20 @@ ts_project(
],
)

jasmine_node_test(
jasmine_test(
name = "application_integration_tests",
size = "large",
data = [":application_integration_test_lib_rjs"],
flaky = True,
shard_count = 10,
deps = [":application_integration_test_lib"],
)

jasmine_node_test(
jasmine_test(
name = "dev-server_integration_tests",
size = "large",
data = [":dev-server_integration_test_lib_rjs"],
flaky = True,
shard_count = 10,
deps = [":dev-server_integration_test_lib"],
)

genrule(
Expand Down
6 changes: 5 additions & 1 deletion packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"builders": "builders.json",
"dependencies": {
"@ampproject/remapping": "2.3.0",
"@angular-devkit/architect": "0.0.0-EXPERIMENTAL-PLACEHOLDER",
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
"@angular-devkit/architect": "workspace:0.0.0-EXPERIMENTAL-PLACEHOLDER",
"@babel/core": "7.26.0",
"@babel/helper-annotate-as-pure": "7.25.9",
"@babel/helper-split-export-declaration": "7.24.7",
Expand Down Expand Up @@ -47,6 +48,9 @@
"optionalDependencies": {
"lmdb": "3.2.2"
},
"devDependencies": {
"@angular/ssr": "workspace:*"
},
"peerDependencies": {
"@angular/compiler": "^19.0.0",
"@angular/compiler-cli": "^19.0.0",
Expand Down
Loading

0 comments on commit 66fa06c

Please sign in to comment.