Skip to content

Commit

Permalink
build: create a ts_library and ng_module macro
Browse files Browse the repository at this point in the history
This prevents us repeating the tsconfig attribute everywhere, and possibly having different tsconfig for different targets
  • Loading branch information
alexeagle committed Jan 9, 2018
1 parent fa03ae1 commit c8133e4
Show file tree
Hide file tree
Showing 36 changed files with 52 additions and 75 deletions.
5 changes: 2 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ node_repositories(package_json = ["//:package.json"])
git_repository(
name = "build_bazel_rules_typescript",
remote = "https://github.com/bazelbuild/rules_typescript.git",
# tag = "0.7.1+",
commit = "89d2c75066bea3d9c942f29dd1d2ea543c58d6d5"
commit = "985c1c8b7c598f9afa276511c0484485f6a64098",
)

load("@build_bazel_rules_typescript//:setup.bzl", "ts_setup_workspace")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")

ts_setup_workspace()

Expand Down
9 changes: 1 addition & 8 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ exports_files([
"tsconfig.json",
])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_config", "ts_library")

ts_config(
name = "tsconfig",
src = ":tsconfig-build.json",
deps = [],
)
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "types",
srcs = glob(["*.ts"]),
tsconfig = ":tsconfig",
)
3 changes: 1 addition & 2 deletions packages/animations/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "animations",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/animations",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core",
],
Expand Down
3 changes: 1 addition & 2 deletions packages/animations/browser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "browser",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/animations/browser",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/animations",
],
Expand Down
3 changes: 1 addition & 2 deletions packages/animations/browser/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "test",
testonly = 1,
srcs = glob(["**/*.ts"]),
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/animations",
Expand Down
3 changes: 1 addition & 2 deletions packages/animations/browser/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/animations/browser/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/animations",
"//packages/animations/browser",
Expand Down
3 changes: 1 addition & 2 deletions packages/animations/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "test",
testonly = 1,
srcs = glob(["test/**/*.ts"]),
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/animations",
Expand Down
2 changes: 1 addition & 1 deletion packages/bazel/test/ngc-wrapped/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "ngc_test_lib",
Expand Down
3 changes: 1 addition & 2 deletions packages/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "common",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/common",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core",
"@rxjs",
Expand Down
3 changes: 1 addition & 2 deletions packages/common/http/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "http",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/common/http",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/common",
"//packages/core",
Expand Down
3 changes: 1 addition & 2 deletions packages/common/http/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/common/http/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/common/http",
"//packages/core",
Expand Down
3 changes: 1 addition & 2 deletions packages/common/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/common/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/common",
"//packages/core",
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "compiler",
Expand All @@ -11,5 +11,4 @@ ts_library(
],
),
module_name = "@angular/compiler",
tsconfig = "//packages:tsconfig",
)
4 changes: 2 additions & 2 deletions packages/compiler/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_web_test")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "test_lib",
Expand All @@ -8,7 +9,6 @@ ts_library(
["**/*.ts"],
exclude = ["**/*_node_only_spec.ts"],
),
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/common",
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/compiler/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/compiler",
Expand Down
4 changes: 1 addition & 3 deletions packages/core/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ts_library")

ng_module(
name = "core",
Expand All @@ -12,7 +11,6 @@ ng_module(
],
),
module_name = "@angular/core",
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"@rxjs",
Expand Down
5 changes: 2 additions & 3 deletions packages/core/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_web_test")
load("//tools:defaults.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")

ts_library(
Expand All @@ -13,7 +14,6 @@ ts_library(
"render3/**/*.ts",
],
),
tsconfig = "//packages:tsconfig",
deps = [
"//packages/animations",
"//packages/animations/browser",
Expand All @@ -37,7 +37,6 @@ ts_library(
name = "test_node_only_lib",
testonly = 1,
srcs = glob(["**/*_node_only_spec.ts"]),
tsconfig = "//packages:tsconfig",
deps = [
":test_lib",
"//packages/compiler",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/core/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/core",
Expand Down
3 changes: 1 addition & 2 deletions packages/http/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "http",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/http",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core",
"//packages/platform-browser",
Expand Down
3 changes: 1 addition & 2 deletions packages/http/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/http/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core",
"//packages/http",
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-browser-dynamic/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "platform-browser-dynamic",
Expand All @@ -12,7 +12,6 @@ ts_library(
],
),
module_name = "@angular/platform-browser-dynamic",
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/common",
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-browser-dynamic/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/platform-browser-dynamic/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/compiler",
"//packages/compiler/testing",
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-browser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "platform-browser",
Expand All @@ -12,7 +12,6 @@ ts_library(
],
),
module_name = "@angular/platform-browser",
tsconfig = "//packages:tsconfig",
deps = [
"//packages:types",
"//packages/common",
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-browser/animations/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "animations",
Expand All @@ -11,7 +11,6 @@ ts_library(
],
),
module_name = "@angular/platform-browser/animations",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/animations",
"//packages/animations/browser",
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-browser/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library")

ts_library(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/platform-browser/testing",
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core",
"//packages/platform-browser",
Expand Down

0 comments on commit c8133e4

Please sign in to comment.