diff --git a/src/BUILD.bazel b/src/BUILD.bazel index 81015db85..7dfcf46bd 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -1,11 +1,10 @@ package(default_visibility = ["//visibility:public"]) -load("@angular//:index.bzl", "ng_module") +load("//tools:defaults.bzl", "ng_module") ng_module( name = "src", srcs = glob(["*.ts"]), - tsconfig = ":tsconfig.json", deps = ["//src/hello-world"], ) diff --git a/src/hello-world/BUILD.bazel b/src/hello-world/BUILD.bazel index 590192bcf..87f1f5d2b 100644 --- a/src/hello-world/BUILD.bazel +++ b/src/hello-world/BUILD.bazel @@ -1,8 +1,8 @@ package(default_visibility = ["//visibility:public"]) -load("@angular//:index.bzl", "ng_module") +load("//tools:defaults.bzl", "ng_module", "ts_library") load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary") -load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test") +load("@build_bazel_rules_typescript//:defs.bzl", "ts_web_test") sass_binary( name = "hello-world-styles", @@ -20,7 +20,6 @@ ng_module( "hello-world.module.ts", ], assets = [":hello-world-styles"], - tsconfig = "//src:tsconfig.json", deps = [ "//src/lib", "@rxjs", diff --git a/src/lib/BUILD.bazel b/src/lib/BUILD.bazel index 33a3d0942..7289c60c1 100644 --- a/src/lib/BUILD.bazel +++ b/src/lib/BUILD.bazel @@ -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 = "lib", diff --git a/src/tsconfig.json b/src/tsconfig.json index a5c02c8bb..6c24e8ab0 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "strict": true, "lib": [ "dom", "es5", diff --git a/tools/BUILD b/tools/BUILD new file mode 100644 index 000000000..167bf74c5 --- /dev/null +++ b/tools/BUILD @@ -0,0 +1 @@ +# Marker that this is a Bazel package diff --git a/tools/defaults.bzl b/tools/defaults.bzl new file mode 100644 index 000000000..60944378d --- /dev/null +++ b/tools/defaults.bzl @@ -0,0 +1,14 @@ +load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library") +load("@angular//:index.bzl", _ng_module = "ng_module") + +DEFAULT_TSCONFIG = "//src:tsconfig.json" + +def ts_library(tsconfig = None, **kwargs): + if not tsconfig: + tsconfig = DEFAULT_TSCONFIG + _ts_library(tsconfig = tsconfig, **kwargs) + +def ng_module(tsconfig = None, **kwargs): + if not tsconfig: + tsconfig = DEFAULT_TSCONFIG + _ng_module(tsconfig = tsconfig, **kwargs)