Paul Gschwendtner af25379a3b build: migrate @angular/ssr tests to rules_js
Migrates the SSR tesst to run natively via `rules_js`. Notably, we still
need the bundling in between as the tests and SSR plain code is not
valid ESM technically; due to lack of extensions.

We'll need to revisit this in the future, or at the very least come up
with a `rules_js`-variant of the `spec_bundle`; but for this is
sufficient and unblocks other packages.
2025-01-23 15:27:55 +01:00

94 lines
2.3 KiB
Python

load("@aspect_rules_js//npm:defs.bzl", "npm_package")
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")
load("//tools:defaults2.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
ts_project(
name = "ssr",
srcs = glob(
include = [
"*.ts",
"src/**/*.ts",
],
exclude = [
"**/*_spec.ts",
],
),
args = [
"--lib",
"dom,es2020",
],
data = [
"//packages/angular/ssr/third_party/beasties:beasties_bundled",
],
module_name = "@angular/ssr",
source_map = True,
tsconfig = "//:build-tsconfig-esm",
deps = [
"//:node_modules/@angular/common",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/router",
"//:node_modules/tslib",
"//packages/angular/ssr/third_party/beasties:beasties_dts",
],
)
ng_package(
name = "angular_package",
package_name = "@angular/ssr",
srcs = [
":package.json",
"//packages/angular/ssr/third_party/beasties:beasties_bundled",
],
externals = [
"@angular/ssr",
"@angular/ssr/node",
"../../third_party/beasties",
],
nested_packages = [
"//packages/angular/ssr/schematics:npm_package",
],
deps = [
":ssr",
"//packages/angular/ssr/node",
],
)
pkg_tar(
name = "npm_package_archive",
srcs = [":npm_package"],
extension = "tgz",
strip_prefix = "./npm_package",
# should not be built unless it is a dependency of another rule
tags = ["manual"],
)
# TODO: Replace when `ng_package` creates a valid `rules_js`-compliant npm package.
npm_package(
name = "npm_package",
srcs = [":angular_package"],
replace_prefixes = {
"angular_package/": "",
},
tags = ["release-package"],
)
alias(
name = "pkg",
actual = ":npm_package",
)
api_golden_test_npm_package(
name = "ssr_api",
data = [
":npm_package",
"//goldens:public-api",
],
golden_dir = "angular_cli/goldens/public-api/angular/ssr",
npm_package = "angular_cli/packages/angular/ssr/npm_package",
)