build: support new ng_project rule (#61275)

Supports the `ng_project` rule with the local compiler-cli version
from HEAD.

PR Close #61275
This commit is contained in:
Paul Gschwendtner
2025-05-09 16:42:03 +00:00
committed by Jessica Janiuk
parent a7b58e3c5a
commit 397f9987ef
12 changed files with 2543 additions and 2441 deletions
@@ -3,6 +3,9 @@
# This file should be checked into version control along with the pnpm-lock.yaml file. # This file should be checked into version control along with the pnpm-lock.yaml file.
.npmrc=-1406867100 .npmrc=-1406867100
package.json=-686175807 package.json=-686175807
pnpm-lock.yaml=1839765696 packages/compiler-cli/package.json=-1767555217
pnpm-workspace.yaml=1711114604 packages/compiler/package.json=-426903429
pnpm-lock.yaml=-445193031
pnpm-workspace.yaml=353334404
tools/bazel/rules_angular_store/package.json=-239561259
yarn.lock=1067917288 yarn.lock=1067917288
+6
View File
@@ -36,3 +36,9 @@ integration/trusted-types/node_modules
integration/typings_test_rxjs7/node_modules integration/typings_test_rxjs7/node_modules
integration/typings_test_ts58/node_modules integration/typings_test_ts58/node_modules
modules/ssr-benchmarks/node_modules modules/ssr-benchmarks/node_modules
# For rules_js
packages/compiler/node_modules
packages/compiler-cli/node_modules
tools/bazel/rules_angular_store/node_modules
+6 -3
View File
@@ -108,6 +108,9 @@ npm_translate_lock(
data = [ data = [
"//:package.json", "//:package.json",
"//:pnpm-workspace.yaml", "//:pnpm-workspace.yaml",
"//packages/compiler:package.json",
"//packages/compiler-cli:package.json",
"//tools/bazel/rules_angular_store:package.json",
], ],
npmrc = "//:.npmrc", npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml", pnpm_lock = "//:pnpm-lock.yaml",
@@ -269,7 +272,7 @@ setup_dependencies_2()
git_repository( git_repository(
name = "rules_angular", name = "rules_angular",
commit = "e35da7371d02d0c8d165c518d532d66be7afb8a6", commit = "ad3a2d652f41c953fad8f55c3959fde628fa8ebf",
remote = "https://github.com/devversion/rules_angular.git", remote = "https://github.com/devversion/rules_angular.git",
) )
@@ -284,6 +287,6 @@ rules_angular_step2()
load("@rules_angular//setup:step_3.bzl", "rules_angular_step3") load("@rules_angular//setup:step_3.bzl", "rules_angular_step3")
rules_angular_step3( rules_angular_step3(
angular_compiler_cli = "@angular//packages/compiler-cli", angular_compiler_cli = "@angular//tools/bazel/rules_angular_store:node_modules/@angular/compiler-cli",
typescript = "//:node_modules/typescript", typescript = "@angular//:node_modules/typescript",
) )
+19 -1
View File
@@ -1,7 +1,8 @@
load("@npm//@bazel/esbuild:index.bzl", "esbuild", "esbuild_config") load("@npm//@bazel/esbuild:index.bzl", "esbuild", "esbuild_config")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("//packages/bazel/src:ng_perf.bzl", "ng_perf_flag") load("//packages/bazel/src:ng_perf.bzl", "ng_perf_flag")
load("//tools:defaults.bzl", "api_golden_test", "extract_types", "pkg_npm", "ts_library") load("//tools:defaults.bzl", "api_golden_test", "extract_types", "pkg_npm", "ts_library")
load("//tools:defaults2.bzl", "ts_config") load("//tools:defaults2.bzl", "npm_package", "ts_config")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
@@ -12,6 +13,8 @@ PUBLIC_TARGETS = [
"//packages/compiler-cli/linker/babel", "//packages/compiler-cli/linker/babel",
] ]
npm_link_all_packages()
ts_config( ts_config(
name = "tsconfig_build", name = "tsconfig_build",
src = "tsconfig.json", src = "tsconfig.json",
@@ -141,6 +144,21 @@ pkg_npm(
], ],
) )
# TODO(devversion): Temporary early `npm_package` for making compiler-cli usable in `rules_angular`.
# Long-term, `pkg_npm` will be migrated to `npm_package` in general.
npm_package(
name = "pkg",
srcs = [":npm_package"],
data = [
# Needed because compiler is a dev dependency (to satisfy the peer dependency)
# and `rules_js` only makes transitive production dependencies available.
":node_modules/@angular/compiler",
],
replace_prefixes = {
"npm_package/": "",
},
)
api_golden_test( api_golden_test(
name = "error_code_api", name = "error_code_api",
data = [ data = [
+3
View File
@@ -55,6 +55,9 @@
"@angular/compiler": "0.0.0-PLACEHOLDER", "@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=5.8 <5.9" "typescript": ">=5.8 <5.9"
}, },
"devDependencies": {
"@angular/compiler": "workspace:*"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/angular/angular.git", "url": "https://github.com/angular/angular.git",
+11
View File
@@ -1,4 +1,5 @@
load("//tools:defaults.bzl", "ng_package", "ts_library", "tsec_test") load("//tools:defaults.bzl", "ng_package", "ts_library", "tsec_test")
load("//tools:defaults2.bzl", "npm_package")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
@@ -43,6 +44,16 @@ ng_package(
], ],
) )
# TODO(devversion): Temporary early `npm_package` for making compiler usable in `rules_angular`.
# Long-term, `pkg_npm` will be migrated to `npm_package` in general.
npm_package(
name = "pkg",
srcs = [":npm_package"],
replace_prefixes = {
"npm_package/": "",
},
)
filegroup( filegroup(
name = "files_for_docgen", name = "files_for_docgen",
srcs = glob([ srcs = glob([
+2477 -2435
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -1,2 +1,5 @@
packages: packages:
- . - .
- packages/compiler/
- packages/compiler-cli/
- tools/bazel/rules_angular_store/
@@ -0,0 +1,3 @@
load("@npm2//:defs.bzl", "npm_link_all_packages")
npm_link_all_packages()
@@ -0,0 +1,3 @@
This directory will be used for exposing `@angular/compiler-cli` to `rules_angular`.
A folder structure generated through this `package.json` ensures that transitive dependencies are available at runtime, and module resolution can naturally work.
@@ -0,0 +1,5 @@
{
"dependencies": {
"@angular/compiler-cli": "workspace:*"
}
}
+2
View File
@@ -1,9 +1,11 @@
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test") load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", _ts_config = "ts_config") load("@aspect_rules_ts//ts:defs.bzl", _ts_config = "ts_config")
load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project") load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project")
load("//tools/bazel:module_name.bzl", "compute_module_name") load("//tools/bazel:module_name.bzl", "compute_module_name")
load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project") load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project")
npm_package = _npm_package
ts_config = _ts_config ts_config = _ts_config
def ts_project( def ts_project(