Paul Gschwendtner 9dd3f0344f
Further clean-up rules_nodejs npm workspace and remove yarn.lock (#29779)
* build: disconnect `@npm` workspace from main project

This will speed up significantly as we don't need to fetch all
dependencies again just for the `@npm` repository that is at this point
only leveraged by the `ng_package` rule for some of its dependencies.

This commit allows us to drop the `yarn.lock` and Aspect lock files, and
allows us to independently migrate `ng_package` to `rules_js`.

It also allows us to drop the `_rjs` TS interop layer in follow-up commits.

* build: drop `_rjs` suffix from `ts_project` targets

We don't need the `ts_project` interop in principle
at this point. We only have one remaining instance left for the SSR
`ng_package` integration. This commit cleans up all usages.

* build: remove yarn

* build: avoid duplicated dependencies at top-level

`rules_js` seems to be sensitive if there are similar versions of the same
package installed, but with differently matched peer dependencies. This
is fine because we can (and should long-term) move those dependencies to
their package-local `package.json` files. This commit unblocks the
migration and highlights how we can move deps to the individual packages
in the future.

* build: update checkout github action

This will allow us to use pnpm.

* build: update node to avoid strict-engines error caused by `npm`

Avoids:

```
Lockfile is up to date, resolution step is skipped
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "npm@11.2.0".

Expected version: ^20.17.0 || >=22.9.0
Got: v20.11.1
```

Note that we won't update the WORKSPACE test version as that would mean
we need to update the Node engines for shipped packages; and we can't do
this right now without introducing a breaking change.

* build: fix missing dependency for spec bundling

The beasties JS sources weren't available for bundling in the
`bazel-bin`, and this surfaced in RBE. This commit fixes this.
2025-03-11 10:05:52 +01:00

315 lines
9.3 KiB
Python

load("@devinfra//bazel/api-golden:index_rjs.bzl", "api_golden_test_npm_package")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("//tools:defaults2.bzl", "copy_to_bin", "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",
)
ts_json_schema(
name = "dev-server_schema",
src = "src/builders/dev-server/schema.json",
)
ts_json_schema(
name = "extract_i18n_schema",
src = "src/builders/extract-i18n/schema.json",
)
ts_json_schema(
name = "ng_karma_schema",
src = "src/builders/karma/schema.json",
)
ts_json_schema(
name = "ng_packagr_schema",
src = "src/builders/ng-packagr/schema.json",
)
copy_to_bin(
name = "schemas",
srcs = glob(["**/schema.json"]),
)
RUNTIME_ASSETS = glob(
include = [
"src/**/schema.json",
"src/**/*.js",
"src/**/*.mjs",
"src/**/*.html",
],
) + [
"builders.json",
"package.json",
]
ts_project(
name = "build",
srcs = glob(
include = [
"src/**/*.ts",
],
exclude = [
"src/test-utils.ts",
"src/**/*_spec.ts",
"src/**/tests/**/*.ts",
"src/testing/**/*.ts",
],
) + [
"index.ts",
"//packages/angular/build:src/builders/application/schema.ts",
"//packages/angular/build:src/builders/dev-server/schema.ts",
"//packages/angular/build:src/builders/extract-i18n/schema.ts",
"//packages/angular/build:src/builders/karma/schema.ts",
"//packages/angular/build:src/builders/ng-packagr/schema.ts",
],
data = RUNTIME_ASSETS,
module_name = "@angular/build",
deps = [
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
":node_modules/@angular/ssr",
":node_modules/@inquirer/confirm",
":node_modules/@vitejs/plugin-basic-ssl",
":node_modules/vite",
"//:node_modules/@ampproject/remapping",
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/localize",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/service-worker",
"//:node_modules/@babel/core",
"//:node_modules/@babel/helper-annotate-as-pure",
"//:node_modules/@babel/helper-split-export-declaration",
"//:node_modules/@babel/plugin-syntax-import-attributes",
"//:node_modules/@types/babel__core",
"//:node_modules/@types/karma",
"//:node_modules/@types/less",
"//:node_modules/@types/node",
"//:node_modules/@types/picomatch",
"//:node_modules/@types/semver",
"//:node_modules/@types/watchpack",
"//:node_modules/beasties",
"//:node_modules/browserslist",
"//:node_modules/esbuild",
"//:node_modules/esbuild-wasm",
"//:node_modules/https-proxy-agent",
"//:node_modules/istanbul-lib-instrument",
"//:node_modules/jsonc-parser",
"//:node_modules/karma",
"//:node_modules/less",
"//:node_modules/listr2",
"//:node_modules/lmdb",
"//:node_modules/magic-string",
"//:node_modules/mrmime",
"//:node_modules/ng-packagr",
"//:node_modules/parse5-html-rewriting-stream",
"//:node_modules/picomatch",
"//:node_modules/piscina",
"//:node_modules/postcss",
"//:node_modules/rollup",
"//:node_modules/sass",
"//:node_modules/semver",
"//:node_modules/source-map-support",
"//:node_modules/tinyglobby",
"//:node_modules/tslib",
"//:node_modules/typescript",
"//:node_modules/watchpack",
],
)
ts_project(
name = "unit_test_lib",
testonly = True,
srcs = glob(
include = ["src/**/*_spec.ts"],
exclude = ["src/builders/**/tests/**"],
),
deps = [
":build",
":node_modules/@angular-devkit/core",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@babel/core",
"//:node_modules/@types/jasmine",
"//:node_modules/prettier",
"//:node_modules/typescript",
"//packages/angular/build/private",
],
)
jasmine_test(
name = "unit_tests",
data = [":unit_test_lib"],
)
ts_project(
name = "application_integration_test_lib",
testonly = True,
srcs = glob(include = ["src/builders/application/tests/**/*.ts"]),
deps = [
":build",
"//packages/angular/build/private",
"//modules/testing/builder",
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
# Base dependencies for the application in hello-world-app.
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-browser-dynamic",
"//:node_modules/@angular/router",
"//:node_modules/rxjs",
"//:node_modules/tslib",
"//:node_modules/typescript",
"//:node_modules/zone.js",
"//:node_modules/buffer",
],
)
ts_project(
name = "dev-server_integration_test_lib",
testonly = True,
srcs = glob(include = ["src/builders/dev-server/tests/**/*.ts"]),
deps = [
":build",
"//packages/angular/build/private",
"//modules/testing/builder",
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
# dev server only test deps
"//:node_modules/@types/http-proxy",
"//:node_modules/@types/node",
"//:node_modules/http-proxy",
"//:node_modules/puppeteer",
# Base dependencies for the application in hello-world-app.
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-browser-dynamic",
"//:node_modules/@angular/router",
"//:node_modules/ng-packagr",
"//:node_modules/rxjs",
"//:node_modules/tslib",
"//:node_modules/typescript",
"//:node_modules/zone.js",
"//:node_modules/buffer",
],
)
ts_project(
name = "karma_integration_test_lib",
testonly = True,
srcs = glob(include = ["src/builders/karma/tests/**/*.ts"]),
deps = [
":build",
"//packages/angular/build/private",
"//modules/testing/builder",
":node_modules/@angular-devkit/architect",
":node_modules/@angular-devkit/core",
"//:node_modules/@types/node",
# karma specific test deps
"//:node_modules/karma-chrome-launcher",
"//:node_modules/karma-coverage",
"//:node_modules/karma-jasmine",
"//:node_modules/karma-jasmine-html-reporter",
"//:node_modules/puppeteer",
# Base dependencies for the karma in hello-world-app.
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-browser-dynamic",
"//:node_modules/@angular/router",
"//:node_modules/rxjs",
"//:node_modules/tslib",
"//:node_modules/typescript",
"//:node_modules/zone.js",
"//:node_modules/buffer",
],
)
jasmine_test(
name = "application_integration_tests",
size = "large",
data = [":application_integration_test_lib"],
flaky = True,
shard_count = 10,
)
jasmine_test(
name = "dev-server_integration_tests",
size = "large",
data = [":dev-server_integration_test_lib"],
flaky = True,
shard_count = 10,
)
jasmine_test(
name = "karma_integration_tests",
size = "large",
data = [":karma_integration_test_lib"],
env = {
# TODO: Replace Puppeteer downloaded browsers with Bazel-managed browsers,
# or standardize to avoid complex configuration like this!
"PUPPETEER_DOWNLOAD_PATH": "../../../node_modules/puppeteer/downloads",
},
flaky = True,
shard_count = 10,
)
genrule(
name = "license",
srcs = ["//:LICENSE"],
outs = ["LICENSE"],
cmd = "cp $(execpath //:LICENSE) $@",
)
npm_package(
name = "pkg",
pkg_deps = [
"//packages/angular_devkit/architect:package.json",
],
stamp_files = [
"src/utils/version.js",
"src/tools/esbuild/utils.js",
"src/utils/normalize-cache.js",
],
tags = ["release-package"],
deps = RUNTIME_ASSETS + [
":README.md",
":build",
":license",
"//packages/angular/build/private",
],
)
api_golden_test_npm_package(
name = "api",
data = [
":npm_package",
"//goldens:public-api",
],
golden_dir = "goldens/public-api/angular/build",
npm_package = "packages/angular/build/npm_package",
)