Paul Gschwendtner 4fee94a96c build: rename //:root_modules to //:node_modules.
This is necessary as `rules_js` requires this "common name" when dealing
with Yarn workspaces, linking first party dependencies automatically.

In the future, we may be able to send a PR to `rules_js` to support a
custom name somehow.
2025-01-15 19:20:40 +01:00

161 lines
4.6 KiB
Python

# Copyright Google Inc. All Rights Reserved.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
# Create a list of Tuple("path/file.json", "path_file") to be used as rules
ALL_SCHEMA_TARGETS = [
(
x,
x.replace("/", "_").replace("-", "_").replace(".json", ""),
)
for x in glob(
include = ["*/schema.json"],
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
)
]
# Create all the targets.
[
ts_json_schema(
name = name,
src = src,
)
for (src, name) in ALL_SCHEMA_TARGETS
]
RUNTIME_ASSETS = [
"collection.json",
"migrations/migration-collection.json",
"package.json",
"utility/latest-versions/package.json",
] + glob(
include = [
"*/schema.json",
"*/files/**/*",
"*/other-files/**/*",
"*/implements-files/**/*",
"*/type-files/**/*",
"*/functional-files/**/*",
"*/class-files/**/*",
],
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
)
ts_project(
name = "angular",
srcs = glob(
include = ["**/*.ts"],
exclude = [
"**/*_spec.ts",
# Also exclude templated files.
"*/files/**/*.ts",
"*/other-files/**/*.ts",
"*/implements-files/**/*",
"*/type-files/**/*",
"*/functional-files/**/*",
"*/class-files/**/*",
# Exclude test helpers.
"utility/test/**/*.ts",
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
) + [
"//packages/schematics/angular:" + src.replace(".json", ".ts")
for (src, _) in ALL_SCHEMA_TARGETS
],
data = RUNTIME_ASSETS,
module_name = "@schematics/angular",
deps = [
"//:node_modules/@inquirer/prompts",
"//:node_modules/@types/node",
"//:node_modules/browserslist",
"//:node_modules/jsonc-parser",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
"//packages/schematics/angular/third_party/github.com/Microsoft/TypeScript:TypeScript_rjs",
],
)
jasmine_node_test(
name = "no_typescript_runtime_dep_test",
srcs = ["no_typescript_runtime_dep_spec.js"],
deps = [
":angular",
"//:node_modules/@types/jasmine",
],
)
ts_project(
name = "angular_test_lib",
testonly = True,
srcs = glob(
include = [
"**/*_spec.ts",
"utility/test/**/*.ts",
],
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
),
deps = [
":angular_rjs",
"//:node_modules/@types/jasmine",
"//:node_modules/jsonc-parser",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node/testing:testing_rjs",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
"//packages/angular_devkit/schematics/testing:testing_rjs",
"//packages/schematics/angular/third_party/github.com/Microsoft/TypeScript:TypeScript_rjs",
],
)
jasmine_node_test(
name = "angular_test",
srcs = [":angular_test_lib"],
)
genrule(
name = "license",
srcs = ["//:LICENSE"],
outs = ["LICENSE"],
cmd = "cp $(execpath //:LICENSE) $@",
)
npm_package(
name = "pkg",
pkg_deps = [
"//packages/angular_devkit/schematics:package.json",
"//packages/angular_devkit/core:package.json",
],
stamp_files = [
"utility/latest-versions.js",
],
tags = ["release-package"],
deps = RUNTIME_ASSETS + [
":README.md",
":angular_rjs",
":license",
"//packages/schematics/angular/third_party/github.com/Microsoft/TypeScript:LICENSE",
# Force typescript library to be included.
"//packages/schematics/angular/third_party/github.com/Microsoft/TypeScript:lib/typescript.js",
],
)