Updates the Bazel NodeJS rules to v4.0.0-beta.0. This is necessary so that the Angular components repo can update, and it's generally good to stay as up-to-date as possible with the Bazel rules as it's easy to fall behind, and updating early allows us to discover issues affecting our tooling earlier (where they are easier to address due to e.g. potential breaking change policy). PR Close #42760
116 lines
2.7 KiB
Python
116 lines
2.7 KiB
Python
# BEGIN-INTERNAL
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
|
|
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
|
load("//tools:defaults.bzl", "jasmine_node_test")
|
|
|
|
ts_library(
|
|
name = "lib",
|
|
srcs = glob(["lib/*.ts"]),
|
|
module_name = "ts-api-guardian",
|
|
tsconfig = "//tools:tsconfig.json",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"@npm//@types/diff",
|
|
"@npm//@types/minimist",
|
|
"@npm//@types/node",
|
|
"@npm//chalk",
|
|
"@npm//diff",
|
|
"@npm//minimist",
|
|
"@npm//typescript",
|
|
],
|
|
)
|
|
|
|
# Copy Angular's license to govern ts-api-guardian as well.
|
|
# We use a genrule to put it in this package, so it will be in the right root directory.
|
|
genrule(
|
|
name = "license",
|
|
srcs = ["//:LICENSE"],
|
|
outs = ["LICENSE"],
|
|
cmd = "cp $< $@",
|
|
)
|
|
|
|
pkg_npm(
|
|
name = "ts-api-guardian",
|
|
package_name = "ts-api-guardian",
|
|
srcs = [
|
|
"BUILD.bazel",
|
|
"README.md",
|
|
"bin/ts-api-guardian",
|
|
"index.bzl",
|
|
"package.json",
|
|
],
|
|
substitutions = {
|
|
"@angular//tools/ts-api-guardian:bin": "//:node_modules/ts-api-guardian/bin",
|
|
"@angular//tools/ts-api-guardian:lib": "@npm//ts-api-guardian",
|
|
},
|
|
deps = [
|
|
":lib",
|
|
":license",
|
|
],
|
|
)
|
|
|
|
#######################################3
|
|
# Tests for this package
|
|
|
|
ts_library(
|
|
name = "test_lib",
|
|
testonly = True,
|
|
srcs = glob(
|
|
["test/*.ts"],
|
|
exclude = ["test/bootstrap.ts"],
|
|
),
|
|
tsconfig = "//tools:tsconfig-test",
|
|
deps = [
|
|
":lib",
|
|
"@npm//@bazel/runfiles",
|
|
"@npm//@types/jasmine",
|
|
"@npm//@types/node",
|
|
"@npm//jasmine",
|
|
"@npm//typescript",
|
|
],
|
|
)
|
|
|
|
ts_library(
|
|
name = "bootstrap",
|
|
testonly = True,
|
|
srcs = ["test/bootstrap.ts"],
|
|
tsconfig = "//tools:tsconfig-test",
|
|
deps = ["@npm//@types/node"],
|
|
)
|
|
|
|
# Select the es5 .js output of the ts_library :boostrap target
|
|
# with `output_group = "es5_sources"` for use in the jasmine_node_test
|
|
# below. This exposes an internal detail of ts_library that is not ideal.
|
|
# TODO(gregmagolan): clean this up by using tsc() in this case rather than ts_library
|
|
filegroup(
|
|
name = "bootstrap_es5",
|
|
testonly = True,
|
|
srcs = [":bootstrap"],
|
|
output_group = "es5_sources",
|
|
)
|
|
|
|
jasmine_node_test(
|
|
name = "tests",
|
|
srcs = [
|
|
":test_lib",
|
|
],
|
|
bootstrap = [":bootstrap_es5"],
|
|
data = glob([
|
|
"test/fixtures/*.ts",
|
|
"test/fixtures/*.patch",
|
|
]) + [
|
|
":ts-api-guardian",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "bin",
|
|
srcs = glob(["lib/*.js"]) + ["bin/ts-api-guardian"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Exported to be referenced as entry_point of the nodejs_binary
|
|
exports_files(["bin/ts-api-guardian"])
|
|
|
|
# END-INTERNAL
|