fix: enforce buildifier lint on CI
Closes #357
PiperOrigin-RevId: 226236465
diff --git a/BUILD.bazel b/BUILD.bazel
index 997940e..c11b189 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -19,8 +19,9 @@
# https://github.com/bazelbuild/rules_go/blob/master/go/tools/gazelle/README.rst#directives
# gazelle:exclude node_modules
load("@bazel_gazelle//:def.bzl", "gazelle")
-load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
+load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library")
# ts_library defaults to this label in the top-level package.
# Point to where the file actually lives.
@@ -54,8 +55,6 @@
visibility = ["//visibility:public"],
)
-load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
-
# A nodejs_binary for @bazel/typescript/tsc_wrapped to use by default in
# ts_library that depends on @npm//@bazel/typescript instead of the
# output of the //internal/tsc_wrapped ts_library rule. This
@@ -77,18 +76,18 @@
# It's the companion of the @bazel/typescript, @bazel/karma, etc npm packages.
pkg_tar(
name = "release",
- extension = "tgz",
srcs = [
- "BUILD.bazel",
- "AUTHORS",
- "defs.bzl",
- "LICENSE",
- "package.bzl",
- "WORKSPACE",
+ "AUTHORS",
+ "BUILD.bazel",
+ "LICENSE",
+ "WORKSPACE",
+ "defs.bzl",
+ "package.bzl",
],
+ extension = "tgz",
deps = [
- "//devserver:package",
- "//internal:package",
- "//third_party/github.com/bazelbuild/bazel/src/main/protobuf:package",
+ "//devserver:package",
+ "//internal:package",
+ "//third_party/github.com/bazelbuild/bazel/src/main/protobuf:package",
],
)
diff --git a/WORKSPACE b/WORKSPACE
index 65ca04a..7a18919 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -21,6 +21,7 @@
)
rules_typescript_dependencies()
+
rules_typescript_dev_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
@@ -57,9 +58,10 @@
yarn_lock = "//:yarn.lock",
)
-load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
+load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
+
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
@@ -68,14 +70,14 @@
load(
"@build_bazel_rules_typescript//:defs.bzl",
- "ts_setup_workspace",
"check_rules_typescript_version",
+ "ts_setup_workspace",
)
ts_setup_workspace()
# Test that check_rules_typescript_version works as expected
-check_rules_typescript_version("0.15.3")
+check_rules_typescript_version(minimum_version_string = "0.15.3")
# Dependencies for generating documentation
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
@@ -94,12 +96,12 @@
platform_http_file(
name = "org_chromium_chromium",
- licenses = ["notice"], # BSD 3-clause (maybe more?)
amd64_sha256 =
"6933d0afce6e17304b62029fbbd246cbe9e130eb0d90d7682d3765d3dbc8e1c8",
amd64_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/561732/chrome-linux.zip",
],
+ licenses = ["notice"], # BSD 3-clause (maybe more?)
macos_sha256 =
"084884e91841a923d7b6e81101f0105bbc3b0026f9f6f7a3477f5b313ee89e32",
macos_urls = [
@@ -114,12 +116,12 @@
platform_http_file(
name = "org_chromium_chromedriver",
- licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
amd64_sha256 =
"71eafe087900dbca4bc0b354a1d172df48b31a4a502e21f7c7b156d7e76c95c7",
amd64_urls = [
"https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip",
],
+ licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
macos_sha256 =
"fd32a27148f44796a55f5ce3397015c89ebd9f600d9dda2bcaca54575e2497ae",
macos_urls = [
@@ -134,13 +136,13 @@
platform_http_file(
name = "org_mozilla_firefox",
- licenses = ["reciprocal"], # MPL 2.0
amd64_sha256 =
"3a729ddcb1e0f5d63933177a35177ac6172f12edbf9fbbbf45305f49333608de",
amd64_urls = [
"https://mirror.bazel.build/ftp.mozilla.org/pub/firefox/releases/61.0.2/linux-x86_64/en-US/firefox-61.0.2.tar.bz2",
"https://ftp.mozilla.org/pub/firefox/releases/61.0.2/linux-x86_64/en-US/firefox-61.0.2.tar.bz2",
],
+ licenses = ["reciprocal"], # MPL 2.0
macos_sha256 =
"bf23f659ae34832605dd0576affcca060d1077b7bf7395bc9874f62b84936dc5",
macos_urls = [
@@ -151,13 +153,13 @@
platform_http_file(
name = "org_mozilla_geckodriver",
- licenses = ["reciprocal"], # MPL 2.0
amd64_sha256 =
"c9ae92348cf00aa719be6337a608fae8304691a95668e8e338d92623ba9e0ec6",
amd64_urls = [
"https://mirror.bazel.build/github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz",
"https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz",
],
+ licenses = ["reciprocal"], # MPL 2.0
macos_sha256 =
"ce4a3e9d706db94e8760988de1ad562630412fa8cf898819572522be584f01ce",
macos_urls = [
@@ -169,6 +171,6 @@
# Tell Bazel where the nested local repositories are that are
# used for tests
local_repository(
- name = "disable_tsetse_for_external_test",
- path = "internal/e2e/disable_tsetse_for_external",
+ name = "disable_tsetse_for_external_test",
+ path = "internal/e2e/disable_tsetse_for_external",
)
diff --git a/defs.bzl b/defs.bzl
index a426b6f..3f4b0b3 100644
--- a/defs.bzl
+++ b/defs.bzl
@@ -17,9 +17,8 @@
Users should not load files under "/internal"
"""
-load("//internal:ts_repositories.bzl", _ts_setup_workspace = "ts_setup_workspace")
-load("//internal:build_defs.bzl", _ts_library = "ts_library_macro")
-load("//internal:ts_config.bzl", _ts_config = "ts_config")
+load("@build_bazel_rules_nodejs//internal/common:check_version.bzl", "check_version")
+load("//:package.bzl", "VERSION")
load("//internal/devserver:ts_devserver.bzl", _ts_devserver = "ts_devserver_macro")
load(
"//internal/karma:ts_web_test.bzl",
@@ -27,8 +26,9 @@
_ts_web_test_suite = "ts_web_test_suite",
)
load("//internal/protobufjs:ts_proto_library.bzl", _ts_proto_library = "ts_proto_library")
-load("//:package.bzl", "VERSION")
-load("@build_bazel_rules_nodejs//internal/common:check_version.bzl", "check_version")
+load("//internal:build_defs.bzl", _ts_library = "ts_library_macro")
+load("//internal:ts_config.bzl", _ts_config = "ts_config")
+load("//internal:ts_repositories.bzl", _ts_setup_workspace = "ts_setup_workspace")
ts_setup_workspace = _ts_setup_workspace
ts_library = _ts_library
diff --git a/devserver/BUILD.bazel b/devserver/BUILD.bazel
index 7b83af1..f70274b 100644
--- a/devserver/BUILD.bazel
+++ b/devserver/BUILD.bazel
@@ -1,7 +1,7 @@
-package(default_visibility = ["//visibility:public"])
-
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+
+package(default_visibility = ["//visibility:public"])
go_library(
name = "go_default_library",
@@ -25,7 +25,7 @@
constraint_values = [
"@bazel_tools//platforms:osx",
"@bazel_tools//platforms:x86_64",
- ]
+ ],
)
config_setting(
@@ -33,7 +33,7 @@
constraint_values = [
"@bazel_tools//platforms:linux",
"@bazel_tools//platforms:x86_64",
- ]
+ ],
)
config_setting(
@@ -41,7 +41,7 @@
constraint_values = [
"@bazel_tools//platforms:windows",
"@bazel_tools//platforms:x86_64",
- ]
+ ],
)
filegroup(
@@ -57,41 +57,41 @@
go_binary(
name = "devserver-windows",
+ out = "devserver-windows_amd64.exe",
+ embed = [":go_default_library"],
goarch = "amd64",
goos = "windows",
pure = "on",
- out = "devserver-windows_amd64.exe",
- embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
go_binary(
name = "devserver-darwin",
+ out = "devserver-darwin_amd64",
+ embed = [":go_default_library"],
goarch = "amd64",
goos = "darwin",
pure = "on",
- out = "devserver-darwin_amd64",
- embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
go_binary(
name = "devserver-linux",
+ out = "devserver-linux_amd64",
+ embed = [":go_default_library"],
goarch = "amd64",
goos = "linux",
pure = "on",
- out = "devserver-linux_amd64",
- embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
pkg_tar(
name = "package",
srcs = [
- ":devserver-windows",
+ "BUILD.bazel",
":devserver-darwin",
":devserver-linux",
- "BUILD.bazel",
+ ":devserver-windows",
],
package_dir = "devserver",
)
diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel
index ef8ef1d..7864c07 100644
--- a/examples/BUILD.bazel
+++ b/examples/BUILD.bazel
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("//:defs.bzl", "ts_config")
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
ts_library(
name = "types",
srcs = ["types.d.ts"],
diff --git a/examples/app/BUILD.bazel b/examples/app/BUILD.bazel
index 8c217c8..89842d1 100644
--- a/examples/app/BUILD.bazel
+++ b/examples/app/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
+load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("//:defs.bzl", "ts_devserver")
load("//internal:defaults.bzl", "ts_library")
@@ -18,9 +18,6 @@
deps = [":app"],
)
-# Test for production mode
-load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "nodejs_binary")
-
rollup_bundle(
name = "bundle",
entry_point = "examples/app/app",
diff --git a/examples/es6_output/BUILD.bazel b/examples/es6_output/BUILD.bazel
index 207a48a..b5ff91c 100644
--- a/examples/es6_output/BUILD.bazel
+++ b/examples/es6_output/BUILD.bazel
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load(":es6_consumer.bzl", "es6_consumer")
+package(default_visibility = ["//visibility:public"])
+
es6_consumer(
name = "es6_output",
deps = ["//examples:bar_ts_library"],
diff --git a/examples/googmodule/BUILD.bazel b/examples/googmodule/BUILD.bazel
index 89beb25..5ed37cb 100644
--- a/examples/googmodule/BUILD.bazel
+++ b/examples/googmodule/BUILD.bazel
@@ -1,3 +1,5 @@
+load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
+load("//examples/es5_output:es5_consumer.bzl", "es5_consumer")
load("//internal:defaults.bzl", "ts_library")
ts_library(
@@ -6,15 +8,12 @@
tsconfig = "tsconfig.json",
)
-load("//examples/es5_output:es5_consumer.bzl", "es5_consumer")
es5_consumer(
name = "es5_output",
deps = [":googmodule"],
)
-load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
-
jasmine_node_test(
name = "googmodule_output_test",
srcs = ["googmodule_output_test.js"],
diff --git a/examples/protocol_buffers/BUILD.bazel b/examples/protocol_buffers/BUILD.bazel
index 5b82243..1cb2172 100644
--- a/examples/protocol_buffers/BUILD.bazel
+++ b/examples/protocol_buffers/BUILD.bazel
@@ -1,7 +1,8 @@
+load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load(
"//:defs.bzl",
- "ts_proto_library",
"ts_devserver",
+ "ts_proto_library",
)
load("//internal:defaults.bzl", "ts_library", "ts_web_test_suite")
@@ -63,8 +64,6 @@
)
# Test for production mode
-load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle", "nodejs_binary")
-
rollup_bundle(
name = "bundle",
entry_point = "examples/protocol_buffers/app",
diff --git a/examples/some_library/BUILD.bazel b/examples/some_library/BUILD.bazel
index cf42c76..2668d2c 100644
--- a/examples/some_library/BUILD.bazel
+++ b/examples/some_library/BUILD.bazel
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
ts_library(
name = "lib",
srcs = ["library.ts"],
diff --git a/examples/some_module/BUILD.bazel b/examples/some_module/BUILD.bazel
index 7ed381a..a6ff1bf 100644
--- a/examples/some_module/BUILD.bazel
+++ b/examples/some_module/BUILD.bazel
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
# We compile this library with the module name "sm" to make it possible to
# use `import {} from 'sm';` both at type-check time (we include the mapping in
# the paths map in tsconfig) as well as runtime (we patch the nodejs module
diff --git a/examples/testing/BUILD.bazel b/examples/testing/BUILD.bazel
index ca8dd3f..ee484a9 100644
--- a/examples/testing/BUILD.bazel
+++ b/examples/testing/BUILD.bazel
@@ -25,7 +25,7 @@
deps = [
"@npm//@types/jasmine",
"@npm//@types/node",
- ],
+ ],
)
ts_web_test_suite(
diff --git a/examples/tsconfig_extends/BUILD.bazel b/examples/tsconfig_extends/BUILD.bazel
index 609f1b5..5125897 100644
--- a/examples/tsconfig_extends/BUILD.bazel
+++ b/examples/tsconfig_extends/BUILD.bazel
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("//:defs.bzl", "ts_config")
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
# Because our tsconfig.json has an extends property, we must also tell the
# ts_library to include the extended tsconfig file in compilations.
# The ts_library rule will generate its own tsconfig which extends from the
diff --git a/internal/BUILD.bazel b/internal/BUILD.bazel
index 3d7b93f..5a4932c 100644
--- a/internal/BUILD.bazel
+++ b/internal/BUILD.bazel
@@ -14,6 +14,10 @@
# gazelle:exclude worker_protocol.proto
+load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "nodejs_binary", "npm_package")
+load("//internal:defaults.bzl", "ts_library")
+
package(default_visibility = ["//visibility:public"])
exports_files([
@@ -24,10 +28,6 @@
"tsetse/tsconfig.json",
])
-load("//internal:defaults.bzl", "ts_library")
-load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "jasmine_node_test", "npm_package")
-load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
-
# Vanilla typescript compiler: run the tsc.js binary distributed by TypeScript
nodejs_binary(
name = "tsc",
@@ -153,11 +153,11 @@
)
pkg_tar(
- name = "tsc_wrapped_pkg",
- srcs = glob([
- "tsc_wrapped/**",
- ]),
- package_dir = "tsc_wrapped",
+ name = "tsc_wrapped_pkg",
+ srcs = glob([
+ "tsc_wrapped/**",
+ ]),
+ package_dir = "tsc_wrapped",
)
pkg_tar(
@@ -172,20 +172,20 @@
)
pkg_tar(
- name = "package",
- srcs = [
- "build_defs.bzl",
- "ts_config.bzl",
- "ts_repositories.bzl",
- "BUILD.bazel",
- "package.json",
- ],
- package_dir = "internal",
- deps = [
- ":tsc_wrapped_pkg",
- ":common_pkg",
- "//internal/karma:package",
- "//internal/protobufjs:package",
- "//internal/devserver:package",
- ]
+ name = "package",
+ srcs = [
+ "BUILD.bazel",
+ "build_defs.bzl",
+ "package.json",
+ "ts_config.bzl",
+ "ts_repositories.bzl",
+ ],
+ package_dir = "internal",
+ deps = [
+ ":common_pkg",
+ ":tsc_wrapped_pkg",
+ "//internal/devserver:package",
+ "//internal/karma:package",
+ "//internal/protobufjs:package",
+ ],
)
diff --git a/internal/build_defs.bzl b/internal/build_defs.bzl
index f83c379..d194f7e 100644
--- a/internal/build_defs.bzl
+++ b/internal/build_defs.bzl
@@ -14,12 +14,13 @@
"TypeScript compilation"
+load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo", "collect_node_modules_aspect")
+
# pylint: disable=unused-argument
# pylint: disable=missing-docstring
load(":common/compilation.bzl", "COMMON_ATTRIBUTES", "DEPS_ASPECTS", "compile_ts", "ts_providers_dict_to_struct")
load(":common/tsconfig.bzl", "create_tsconfig")
load(":ts_config.bzl", "TsConfigInfo")
-load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo", "collect_node_modules_aspect")
_DEFAULT_COMPILER = "@build_bazel_rules_typescript//:@bazel/typescript/tsc_wrapped"
@@ -259,26 +260,6 @@
allow_files = [".ts", ".tsx"],
mandatory = True,
),
- "deps": attr.label_list(aspects = local_deps_aspects),
-
- # TODO(alexeagle): reconcile with google3: ts_library rules should
- # be portable across internal/external, so we need this attribute
- # internally as well.
- "tsconfig": attr.label(
- doc = """A tsconfig.json file containing settings for TypeScript compilation.
- Note that some properties in the tsconfig are governed by Bazel and will be
- overridden, such as `target` and `module`.
-
- The default value is set to `//:tsconfig.json` by a macro. This means you must
- either:
-
- - Have your `tsconfig.json` file in the workspace root directory
- - Use an alias in the root BUILD.bazel file to point to the location of tsconfig:
- `alias(name="tsconfig.json", actual="//path/to:tsconfig-something.json")`
- - Give an explicit `tsconfig` attribute to all `ts_library` targets
- """,
- allow_single_file = True,
- ),
"compiler": attr.label(
doc = """Sets a different TypeScript compiler binary to use for this library.
For example, we use the vanilla TypeScript tsc.js for bootstrapping,
@@ -296,14 +277,6 @@
executable = True,
cfg = "host",
),
- "supports_workers": attr.bool(
- doc = """Intended for internal use only.
- Allows you to disable the Bazel Worker strategy for this library.
- Typically used together with the "compiler" setting when using a
- non-worker aware compiler binary.""",
- default = True,
- ),
- "tsickle_typed": attr.bool(default = True),
"internal_testing_type_check_dependencies": attr.bool(default = False, doc = "Testing only, whether to type check inputs that aren't srcs."),
"node_modules": attr.label(
doc = """The npm packages which should be available during the compile.
@@ -368,6 +341,34 @@
""",
default = Label("@npm//typescript:typescript__typings"),
),
+ "supports_workers": attr.bool(
+ doc = """Intended for internal use only.
+ Allows you to disable the Bazel Worker strategy for this library.
+ Typically used together with the "compiler" setting when using a
+ non-worker aware compiler binary.""",
+ default = True,
+ ),
+
+ # TODO(alexeagle): reconcile with google3: ts_library rules should
+ # be portable across internal/external, so we need this attribute
+ # internally as well.
+ "tsconfig": attr.label(
+ doc = """A tsconfig.json file containing settings for TypeScript compilation.
+ Note that some properties in the tsconfig are governed by Bazel and will be
+ overridden, such as `target` and `module`.
+
+ The default value is set to `//:tsconfig.json` by a macro. This means you must
+ either:
+
+ - Have your `tsconfig.json` file in the workspace root directory
+ - Use an alias in the root BUILD.bazel file to point to the location of tsconfig:
+ `alias(name="tsconfig.json", actual="//path/to:tsconfig-something.json")`
+ - Give an explicit `tsconfig` attribute to all `ts_library` targets
+ """,
+ allow_single_file = True,
+ ),
+ "tsickle_typed": attr.bool(default = True),
+ "deps": attr.label_list(aspects = local_deps_aspects),
}),
outputs = {
"tsconfig": "%{name}_tsconfig.json",
diff --git a/internal/common/compilation.bzl b/internal/common/compilation.bzl
index 5c2e569..fa1878e 100644
--- a/internal/common/compilation.bzl
+++ b/internal/common/compilation.bzl
@@ -15,8 +15,8 @@
"""Used for compilation by the different implementations of build_defs.bzl.
"""
-load(":common/module_mappings.bzl", "module_mappings_aspect")
load(":common/json_marshal.bzl", "json_marshal")
+load(":common/module_mappings.bzl", "module_mappings_aspect")
BASE_ATTRIBUTES = dict()
@@ -28,31 +28,31 @@
# Attributes shared by any typescript-compatible rule (ts_library, ng_module)
COMMON_ATTRIBUTES = dict(BASE_ATTRIBUTES, **{
- "deps": attr.label_list(aspects = DEPS_ASPECTS),
"data": attr.label_list(
default = [],
allow_files = True,
),
- # TODO(evanm): make this the default and remove the option.
- "runtime": attr.string(default = "browser"),
+ # A list of diagnostics expected when compiling this library, in the form of
+ # "diagnostic:regexp", e.g. "TS1234:failed to quizzle the .* wobble".
+ # Useful to test for expected compilation errors.
+ "expected_diagnostics": attr.string_list(),
+ # Whether to generate externs.js from any "declare" statement.
+ "generate_externs": attr.bool(default = True),
# Used to determine module mappings
"module_name": attr.string(),
"module_root": attr.string(),
+ # TODO(evanm): make this the default and remove the option.
+ "runtime": attr.string(default = "browser"),
# TODO(radokirov): remove this attr when clutz is stable enough to consume
# any closure JS code.
"runtime_deps": attr.label_list(
default = [],
providers = ["js"],
),
+ "deps": attr.label_list(aspects = DEPS_ASPECTS),
"_additional_d_ts": attr.label_list(
allow_files = True,
),
- # Whether to generate externs.js from any "declare" statement.
- "generate_externs": attr.bool(default = True),
- # A list of diagnostics expected when compiling this library, in the form of
- # "diagnostic:regexp", e.g. "TS1234:failed to quizzle the .* wobble".
- # Useful to test for expected compilation errors.
- "expected_diagnostics": attr.string_list(),
})
COMMON_OUTPUTS = {
@@ -438,9 +438,18 @@
return {
"files": depset(transitive = files_depsets),
+ "instrumented_files": {
+ "dependency_attributes": ["deps", "runtime_deps"],
+ "extensions": ["ts"],
+ "source_attributes": ["srcs"],
+ },
+ # Expose the module_name so that packaging rules can access it.
+ # e.g. rollup_bundle under Bazel needs to convert this into a UMD global
+ # name in the Rollup configuration.
+ "module_name": ctx.attr.module_name,
"output_groups": {
- "es6_sources": es6_sources,
"es5_sources": es5_sources,
+ "es6_sources": es6_sources,
},
"runfiles": ctx.runfiles(
# Note: don't include files=... here, or they will *always* be built
@@ -449,29 +458,20 @@
collect_default = True,
collect_data = True,
),
+ # Expose the tags so that a Skylark aspect can access them.
+ "tags": ctx.attr.tags,
# TODO(martinprobst): Prune transitive deps, only re-export what's needed.
"typescript": {
"declarations": depset(transitive = declarations_depsets),
- "transitive_declarations": transitive_decls,
- "es6_sources": es6_sources,
- "transitive_es6_sources": transitive_es6_sources,
- "es5_sources": es5_sources,
- "transitive_es5_sources": transitive_es5_sources,
"devmode_manifest": devmode_manifest,
- "type_blacklisted_declarations": type_blacklisted_declarations,
- "tsickle_externs": tsickle_externs,
+ "es5_sources": es5_sources,
+ "es6_sources": es6_sources,
"replay_params": replay_params,
- },
- # Expose the tags so that a Skylark aspect can access them.
- "tags": ctx.attr.tags,
- # Expose the module_name so that packaging rules can access it.
- # e.g. rollup_bundle under Bazel needs to convert this into a UMD global
- # name in the Rollup configuration.
- "module_name": ctx.attr.module_name,
- "instrumented_files": {
- "extensions": ["ts"],
- "source_attributes": ["srcs"],
- "dependency_attributes": ["deps", "runtime_deps"],
+ "transitive_declarations": transitive_decls,
+ "transitive_es5_sources": transitive_es5_sources,
+ "transitive_es6_sources": transitive_es6_sources,
+ "tsickle_externs": tsickle_externs,
+ "type_blacklisted_declarations": type_blacklisted_declarations,
},
}
diff --git a/internal/devserver/BUILD b/internal/devserver/BUILD
index 0f72ac3..0f8171f 100644
--- a/internal/devserver/BUILD
+++ b/internal/devserver/BUILD
@@ -53,6 +53,6 @@
"BUILD",
],
package_dir = "devserver",
- deps = ["strip_workaround"],
visibility = ["//internal:__pkg__"],
+ deps = ["strip_workaround"],
)
diff --git a/internal/devserver/ts_devserver.bzl b/internal/devserver/ts_devserver.bzl
index fe4d254..90704f8 100644
--- a/internal/devserver/ts_devserver.bzl
+++ b/internal/devserver/ts_devserver.bzl
@@ -15,10 +15,6 @@
"Simple development server"
load(
- "@build_bazel_rules_nodejs//internal:node.bzl",
- "sources_aspect",
-)
-load(
"@build_bazel_rules_nodejs//internal/js_library:js_library.bzl",
"write_amd_names_shim",
)
@@ -26,6 +22,10 @@
"@build_bazel_rules_nodejs//internal/web_package:web_package.bzl",
"html_asset_inject",
)
+load(
+ "@build_bazel_rules_nodejs//internal:node.bzl",
+ "sources_aspect",
+)
def _ts_devserver(ctx):
files = depset()
@@ -136,55 +136,54 @@
ts_devserver = rule(
implementation = _ts_devserver,
attrs = {
- "deps": attr.label_list(
- doc = "Targets that produce JavaScript, such as `ts_library`",
- allow_files = True,
- aspects = [sources_aspect],
+ "additional_root_paths": attr.string_list(
+ doc = """Additional root paths to serve static_files from.
+ Paths should include the workspace name such as [\"__main__/resources\"]
+ """,
),
- "serving_path": attr.string(
- default = "/_ts_scripts.js",
- doc = """The path you can request from the client HTML which serves the JavaScript bundle.
- If you don't specify one, the JavaScript can be loaded at /_ts_scripts.js""",
+ "bootstrap": attr.label_list(
+ doc = "Scripts to include in the JS bundle before the module loader (require.js)",
+ allow_files = [".js"],
),
"data": attr.label_list(
doc = "Dependencies that can be require'd while the server is running",
allow_files = True,
),
- "index_html": attr.label(
- allow_single_file = True,
- doc = """An index.html file, we'll inject the script tag for the bundle,
- as well as script tags for .js static_files and link tags for .css
- static_files""",
- ),
- "static_files": attr.label_list(
- doc = """Arbitrary files which to be served, such as index.html.
- They are served relative to the package where this rule is declared.""",
- allow_files = True,
- ),
- "scripts": attr.label_list(
- doc = "User scripts to include in the JS bundle before the application sources",
- allow_files = [".js"],
- ),
"entry_module": attr.string(
doc = """The entry_module should be the AMD module name of the entry module such as `"__main__/src/index"`
ts_devserver concats the following snippet after the bundle to load the application:
`require(["entry_module"]);`
""",
),
- "bootstrap": attr.label_list(
- doc = "Scripts to include in the JS bundle before the module loader (require.js)",
- allow_files = [".js"],
- ),
- "additional_root_paths": attr.string_list(
- doc = """Additional root paths to serve static_files from.
- Paths should include the workspace name such as [\"__main__/resources\"]
- """,
+ "index_html": attr.label(
+ allow_single_file = True,
+ doc = """An index.html file, we'll inject the script tag for the bundle,
+ as well as script tags for .js static_files and link tags for .css
+ static_files""",
),
"port": attr.int(
doc = """The port that the devserver will listen on.""",
default = 5432,
),
- "_requirejs_script": attr.label(allow_single_file = True, default = Label("@build_bazel_rules_typescript_devserver_deps//node_modules/requirejs:require.js")),
+ "scripts": attr.label_list(
+ doc = "User scripts to include in the JS bundle before the application sources",
+ allow_files = [".js"],
+ ),
+ "serving_path": attr.string(
+ default = "/_ts_scripts.js",
+ doc = """The path you can request from the client HTML which serves the JavaScript bundle.
+ If you don't specify one, the JavaScript can be loaded at /_ts_scripts.js""",
+ ),
+ "static_files": attr.label_list(
+ doc = """Arbitrary files which to be served, such as index.html.
+ They are served relative to the package where this rule is declared.""",
+ allow_files = True,
+ ),
+ "deps": attr.label_list(
+ doc = "Targets that produce JavaScript, such as `ts_library`",
+ allow_files = True,
+ aspects = [sources_aspect],
+ ),
"_devserver": attr.label(
# For local development in rules_typescript, we build the devserver from sources.
# This requires that we have the go toolchain available.
@@ -200,6 +199,7 @@
executable = True,
cfg = "host",
),
+ "_requirejs_script": attr.label(allow_single_file = True, default = Label("@build_bazel_rules_typescript_devserver_deps//node_modules/requirejs:require.js")),
},
outputs = {
"manifest": "%{name}.MF",
diff --git a/internal/e2e/absolute_imports/BUILD.bazel b/internal/e2e/absolute_imports/BUILD.bazel
index b19d1ec..a9f216c 100644
--- a/internal/e2e/absolute_imports/BUILD.bazel
+++ b/internal/e2e/absolute_imports/BUILD.bazel
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
ts_library(
name = "absolute_imports",
srcs = glob(["*.ts"]),
diff --git a/internal/e2e/disable_tsetse_for_external/BUILD.bazel b/internal/e2e/disable_tsetse_for_external/BUILD.bazel
index aafff28..b626aaa 100644
--- a/internal/e2e/disable_tsetse_for_external/BUILD.bazel
+++ b/internal/e2e/disable_tsetse_for_external/BUILD.bazel
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("@build_bazel_rules_typescript//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
ts_library(
name = "main",
srcs = glob(["*.ts"]),
diff --git a/internal/e2e/errorchecks/BUILD.bazel b/internal/e2e/errorchecks/BUILD.bazel
index dfb8ae9..874aeb7 100644
--- a/internal/e2e/errorchecks/BUILD.bazel
+++ b/internal/e2e/errorchecks/BUILD.bazel
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package(default_visibility = ["//visibility:public"])
-
load("//internal:defaults.bzl", "ts_library")
+package(default_visibility = ["//visibility:public"])
+
ts_library(
name = "erroneous",
srcs = glob(["*.ts"]),
diff --git a/internal/e2e/package_karma/WORKSPACE b/internal/e2e/package_karma/WORKSPACE
index beeeec5..f8b1ad9 100644
--- a/internal/e2e/package_karma/WORKSPACE
+++ b/internal/e2e/package_karma/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,19 +32,21 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
-load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
+load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
+
go_register_toolchains()
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")
web_test_repositories()
+
browser_repositories(
chromium = True,
firefox = True,
diff --git a/internal/e2e/package_typescript_2.7/BUILD.bazel b/internal/e2e/package_typescript_2.7/BUILD.bazel
index 3c9602c..db3403d 100644
--- a/internal/e2e/package_typescript_2.7/BUILD.bazel
+++ b/internal/e2e/package_typescript_2.7/BUILD.bazel
@@ -26,9 +26,9 @@
srcs = glob(["*.spec.ts"]),
deps = [
":main",
+ "@npm//@bazel/typescript",
"@npm//@types/jasmine",
"@npm//@types/node",
- "@npm//@bazel/typescript",
],
)
diff --git a/internal/e2e/package_typescript_2.7/WORKSPACE b/internal/e2e/package_typescript_2.7/WORKSPACE
index 7cc306d..ec66313 100644
--- a/internal/e2e/package_typescript_2.7/WORKSPACE
+++ b/internal/e2e/package_typescript_2.7/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_2.8/BUILD.bazel b/internal/e2e/package_typescript_2.8/BUILD.bazel
index 3c9602c..db3403d 100644
--- a/internal/e2e/package_typescript_2.8/BUILD.bazel
+++ b/internal/e2e/package_typescript_2.8/BUILD.bazel
@@ -26,9 +26,9 @@
srcs = glob(["*.spec.ts"]),
deps = [
":main",
+ "@npm//@bazel/typescript",
"@npm//@types/jasmine",
"@npm//@types/node",
- "@npm//@bazel/typescript",
],
)
diff --git a/internal/e2e/package_typescript_2.8/WORKSPACE b/internal/e2e/package_typescript_2.8/WORKSPACE
index e383ed4..558b690 100644
--- a/internal/e2e/package_typescript_2.8/WORKSPACE
+++ b/internal/e2e/package_typescript_2.8/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_2.9/BUILD.bazel b/internal/e2e/package_typescript_2.9/BUILD.bazel
index 3c9602c..db3403d 100644
--- a/internal/e2e/package_typescript_2.9/BUILD.bazel
+++ b/internal/e2e/package_typescript_2.9/BUILD.bazel
@@ -26,9 +26,9 @@
srcs = glob(["*.spec.ts"]),
deps = [
":main",
+ "@npm//@bazel/typescript",
"@npm//@types/jasmine",
"@npm//@types/node",
- "@npm//@bazel/typescript",
],
)
diff --git a/internal/e2e/package_typescript_2.9/WORKSPACE b/internal/e2e/package_typescript_2.9/WORKSPACE
index 64fb599..bfc88db 100644
--- a/internal/e2e/package_typescript_2.9/WORKSPACE
+++ b/internal/e2e/package_typescript_2.9/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_3.0/BUILD.bazel b/internal/e2e/package_typescript_3.0/BUILD.bazel
index 3c9602c..db3403d 100644
--- a/internal/e2e/package_typescript_3.0/BUILD.bazel
+++ b/internal/e2e/package_typescript_3.0/BUILD.bazel
@@ -26,9 +26,9 @@
srcs = glob(["*.spec.ts"]),
deps = [
":main",
+ "@npm//@bazel/typescript",
"@npm//@types/jasmine",
"@npm//@types/node",
- "@npm//@bazel/typescript",
],
)
diff --git a/internal/e2e/package_typescript_3.0/WORKSPACE b/internal/e2e/package_typescript_3.0/WORKSPACE
index dcda248..6ac1953 100644
--- a/internal/e2e/package_typescript_3.0/WORKSPACE
+++ b/internal/e2e/package_typescript_3.0/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_3.1/BUILD.bazel b/internal/e2e/package_typescript_3.1/BUILD.bazel
index 3c9602c..db3403d 100644
--- a/internal/e2e/package_typescript_3.1/BUILD.bazel
+++ b/internal/e2e/package_typescript_3.1/BUILD.bazel
@@ -26,9 +26,9 @@
srcs = glob(["*.spec.ts"]),
deps = [
":main",
+ "@npm//@bazel/typescript",
"@npm//@types/jasmine",
"@npm//@types/node",
- "@npm//@bazel/typescript",
],
)
diff --git a/internal/e2e/package_typescript_3.1/WORKSPACE b/internal/e2e/package_typescript_3.1/WORKSPACE
index dcda248..6ac1953 100644
--- a/internal/e2e/package_typescript_3.1/WORKSPACE
+++ b/internal/e2e/package_typescript_3.1/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_3.1_no_npm/BUILD.bazel b/internal/e2e/package_typescript_3.1_no_npm/BUILD.bazel
index c5047f7..042f546 100644
--- a/internal/e2e/package_typescript_3.1_no_npm/BUILD.bazel
+++ b/internal/e2e/package_typescript_3.1_no_npm/BUILD.bazel
@@ -25,13 +25,13 @@
name = "test_lib",
testonly = True,
srcs = glob(["*.spec.ts"]),
+ compiler = "@build_bazel_rules_typescript//internal:tsc_wrapped_bin",
deps = [
":main",
"@npm//@types/jasmine",
"@npm//@types/node",
"@npm//typescript",
],
- compiler = "@build_bazel_rules_typescript//internal:tsc_wrapped_bin",
)
jasmine_node_test(
diff --git a/internal/e2e/package_typescript_3.1_no_npm/WORKSPACE b/internal/e2e/package_typescript_3.1_no_npm/WORKSPACE
index dcda248..6ac1953 100644
--- a/internal/e2e/package_typescript_3.1_no_npm/WORKSPACE
+++ b/internal/e2e/package_typescript_3.1_no_npm/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,9 +32,9 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
diff --git a/internal/e2e/package_typescript_karma/WORKSPACE b/internal/e2e/package_typescript_karma/WORKSPACE
index 0412d91..d30e254 100644
--- a/internal/e2e/package_typescript_karma/WORKSPACE
+++ b/internal/e2e/package_typescript_karma/WORKSPACE
@@ -20,9 +20,11 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
+
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -30,19 +32,21 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
-load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
+load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
+
go_register_toolchains()
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")
web_test_repositories()
+
browser_repositories(
chromium = True,
firefox = True,
diff --git a/internal/e2e/reference_types_directive/BUILD.bazel b/internal/e2e/reference_types_directive/BUILD.bazel
index 024fa65..44a396e 100644
--- a/internal/e2e/reference_types_directive/BUILD.bazel
+++ b/internal/e2e/reference_types_directive/BUILD.bazel
@@ -1,9 +1,9 @@
-load("//internal:defaults.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
+load("//internal:defaults.bzl", "ts_library")
ts_library(
name = "tsconfig_types",
- srcs = glob(["tsconfig_types.ts"]),
+ srcs = ["tsconfig_types.ts"],
expected_diagnostics = [
"TS2304: Cannot find name 'Hammer'",
],
diff --git a/internal/e2e/strict_deps/BUILD b/internal/e2e/strict_deps/BUILD
index 775c480..e2387a1 100644
--- a/internal/e2e/strict_deps/BUILD
+++ b/internal/e2e/strict_deps/BUILD
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("//internal:defaults.bzl", "ts_library")
+
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
-load("//internal:defaults.bzl", "ts_library")
-
ts_library(
name = "grandparent",
srcs = ["grandparent.ts"],
diff --git a/internal/e2e/ts_auto_deps/WORKSPACE b/internal/e2e/ts_auto_deps/WORKSPACE
index 71364b0..2fbfb88 100644
--- a/internal/e2e/ts_auto_deps/WORKSPACE
+++ b/internal/e2e/ts_auto_deps/WORKSPACE
@@ -20,10 +20,13 @@
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies", "rules_typescript_dev_dependencies")
+
rules_typescript_dependencies()
+
rules_typescript_dev_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
+
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -31,14 +34,15 @@
node_repositories(preserve_symlinks = True)
yarn_install(
- name = "npm",
- package_json = "//:package.json",
- yarn_lock = "//:yarn.lock",
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
)
-load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
+load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
+
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
diff --git a/internal/karma/BUILD.bazel b/internal/karma/BUILD.bazel
index 50f80bd..7852325 100644
--- a/internal/karma/BUILD.bazel
+++ b/internal/karma/BUILD.bazel
@@ -1,5 +1,8 @@
-package(default_visibility = ["//visibility:public"])
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "npm_package")
+load("//internal:defaults.bzl", "ts_library")
+
+package(default_visibility = ["//visibility:public"])
exports_files([
"test-main.js",
@@ -9,8 +12,6 @@
"ts_web_test_suite.bzl",
])
-load("//internal:defaults.bzl", "ts_library")
-
ts_library(
name = "karma_concat_js",
srcs = glob(["*.ts"]),
@@ -22,8 +23,6 @@
],
)
-load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "npm_package")
-
nodejs_binary(
name = "karma_bin",
data = [
@@ -61,8 +60,8 @@
name = "npm_package",
srcs = [
"README.md",
- "package.json",
"karma.js",
+ "package.json",
],
deps = [
":check_version_copy",
@@ -72,12 +71,11 @@
)
pkg_tar(
- name = "package",
- srcs = [
- "ts_web_test.bzl",
- "BUILD.bazel",
- "package.json",
- ],
- package_dir = "karma"
+ name = "package",
+ srcs = [
+ "BUILD.bazel",
+ "package.json",
+ "ts_web_test.bzl",
+ ],
+ package_dir = "karma",
)
-
diff --git a/internal/karma/ts_web_test.bzl b/internal/karma/ts_web_test.bzl
index d76703a..bcdee11 100644
--- a/internal/karma/ts_web_test.bzl
+++ b/internal/karma/ts_web_test.bzl
@@ -13,14 +13,14 @@
# limitations under the License.
"Unit testing with Karma"
+load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "write_amd_names_shim")
load(
"@build_bazel_rules_nodejs//internal:node.bzl",
"expand_path_into_runfiles",
"sources_aspect",
)
-load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "write_amd_names_shim")
-load("@io_bazel_rules_webtesting//web:web.bzl", "web_test_suite")
load("@io_bazel_rules_webtesting//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS")
+load("@io_bazel_rules_webtesting//web:web.bzl", "web_test_suite")
_CONF_TMPL = "//internal/karma:karma.conf.js"
_DEFAULT_KARMA_BIN = "@npm//@bazel/karma/bin:karma"
@@ -108,11 +108,11 @@
output = conf,
template = ctx.file._conf_tmpl,
substitutions = {
- "TMPL_runfiles_path": "/".join([".."] * config_segments),
"TMPL_bootstrap_files": "\n".join([" '%s'," % e for e in bootstrap_entries]),
- "TMPL_user_files": "\n".join([" '%s'," % e for e in user_entries]),
- "TMPL_static_files": "\n".join([" '%s'," % e for e in static_files]),
+ "TMPL_runfiles_path": "/".join([".."] * config_segments),
"TMPL_runtime_files": "\n".join([" '%s'," % e for e in runtime_files]),
+ "TMPL_static_files": "\n".join([" '%s'," % e for e in static_files]),
+ "TMPL_user_files": "\n".join([" '%s'," % e for e in user_entries]),
"TMPL_workspace_name": ctx.workspace_name,
},
)
@@ -184,27 +184,21 @@
doc = "JavaScript source files",
allow_files = [".js"],
),
- "deps": attr.label_list(
- doc = "Other targets which produce JavaScript such as `ts_library`",
- allow_files = True,
- aspects = [sources_aspect],
- ),
"bootstrap": attr.label_list(
doc = """JavaScript files to include *before* the module loader (require.js).
For example, you can include Reflect,js for TypeScript decorator metadata reflection,
or UMD bundles for third-party libraries.""",
allow_files = [".js"],
),
- "runtime_deps": attr.label_list(
- doc = """Dependencies which should be loaded after the module loader but before the srcs and deps.
- These should be a list of targets which produce JavaScript such as `ts_library`.
- The files will be loaded in the same order they are declared by that rule.""",
- allow_files = True,
- aspects = [sources_aspect],
- ),
"data": attr.label_list(
doc = "Runtime dependencies",
),
+ "karma": attr.label(
+ default = Label(_DEFAULT_KARMA_BIN),
+ executable = True,
+ cfg = "target",
+ allow_files = True,
+ ),
"static_files": attr.label_list(
doc = """Arbitrary files which are available to be served on request.
Files are served at:
@@ -212,11 +206,17 @@
`/base/build_bazel_rules_typescript/examples/testing/static_script.js`""",
allow_files = True,
),
- "karma": attr.label(
- default = Label(_DEFAULT_KARMA_BIN),
- executable = True,
- cfg = "target",
+ "runtime_deps": attr.label_list(
+ doc = """Dependencies which should be loaded after the module loader but before the srcs and deps.
+ These should be a list of targets which produce JavaScript such as `ts_library`.
+ The files will be loaded in the same order they are declared by that rule.""",
allow_files = True,
+ aspects = [sources_aspect],
+ ),
+ "deps": attr.label_list(
+ doc = "Other targets which produce JavaScript such as `ts_library`",
+ allow_files = True,
+ aspects = [sources_aspect],
),
"_conf_tmpl": attr.label(
default = Label(_CONF_TMPL),
diff --git a/internal/protobufjs/BUILD.bazel b/internal/protobufjs/BUILD.bazel
index 60085a7..9f8522e 100644
--- a/internal/protobufjs/BUILD.bazel
+++ b/internal/protobufjs/BUILD.bazel
@@ -1,7 +1,7 @@
-package(default_visibility = ["//visibility:public"])
-
-load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
+
+package(default_visibility = ["//visibility:public"])
exports_files([
"node_modules/protobufjs/dist/minimal/protobuf.min.js",
@@ -56,13 +56,12 @@
)
pkg_tar(
- name = "package",
- srcs = [
- "ts_proto_library.bzl",
- "BUILD.bazel",
- "yarn.lock",
- "package.json",
- ],
- package_dir = "protobufjs"
+ name = "package",
+ srcs = [
+ "BUILD.bazel",
+ "package.json",
+ "ts_proto_library.bzl",
+ "yarn.lock",
+ ],
+ package_dir = "protobufjs",
)
-
diff --git a/internal/protobufjs/ts_proto_library.bzl b/internal/protobufjs/ts_proto_library.bzl
index 8abb241..07ae0d3 100644
--- a/internal/protobufjs/ts_proto_library.bzl
+++ b/internal/protobufjs/ts_proto_library.bzl
@@ -118,11 +118,11 @@
ts_proto_library = rule(
implementation = _ts_proto_library,
attrs = {
- "deps": attr.label_list(doc = "proto_library targets"),
"output_name": attr.string(
doc = """Name of the resulting module, which you will import from.
If not specified, the name will match the target's name.""",
),
+ "deps": attr.label_list(doc = "proto_library targets"),
"_pbjs": attr.label(
default = Label("//internal/protobufjs:pbjs"),
executable = True,
diff --git a/internal/ts_repositories.bzl b/internal/ts_repositories.bzl
index afefa44..87327f9 100644
--- a/internal/ts_repositories.bzl
+++ b/internal/ts_repositories.bzl
@@ -14,8 +14,8 @@
"Install toolchain dependencies"
-load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version", "yarn_install")
load("@bazel_gazelle//:deps.bzl", "go_repository")
+load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version", "yarn_install")
def ts_setup_workspace():
"""This repository rule should be called from your WORKSPACE file.
diff --git a/internal/tsetse/tests/ban_expect_truthy_promise/BUILD b/internal/tsetse/tests/ban_expect_truthy_promise/BUILD
index dc328a1..46b5590 100644
--- a/internal/tsetse/tests/ban_expect_truthy_promise/BUILD
+++ b/internal/tsetse/tests/ban_expect_truthy_promise/BUILD
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-licenses(["notice"]) # Apache 2.0
-
load("//internal:defaults.bzl", "ts_library")
+licenses(["notice"]) # Apache 2.0
+
error_message = "error TS21224: Value passed.*"
ts_library(
@@ -29,7 +29,6 @@
ts_library(
name = "positives",
testonly = 1,
- tsconfig = "//internal:tsetse/tsconfig.json",
srcs = [
"positives.ts",
],
@@ -42,6 +41,7 @@
"\(34,5\).*" + error_message,
"\(35,5\).*" + error_message,
],
+ tsconfig = "//internal:tsetse/tsconfig.json",
deps = [
":jasmine",
],
@@ -50,10 +50,10 @@
ts_library(
name = "negatives",
testonly = 1,
- tsconfig = "//internal:tsetse/tsconfig.json",
srcs = [
"negatives.ts",
],
+ tsconfig = "//internal:tsetse/tsconfig.json",
deps = [
":jasmine",
],
diff --git a/internal/tsetse/tests/ban_promise_as_condition/BUILD b/internal/tsetse/tests/ban_promise_as_condition/BUILD
index 5907da5..83817bd 100644
--- a/internal/tsetse/tests/ban_promise_as_condition/BUILD
+++ b/internal/tsetse/tests/ban_promise_as_condition/BUILD
@@ -12,16 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-licenses(["notice"]) # Apache 2.0
-
load("//internal:defaults.bzl", "ts_library")
+licenses(["notice"]) # Apache 2.0
+
error_message = "error TS21226: Found a thenable.*"
ts_library(
name = "positives",
testonly = 1,
- tsconfig = "//internal:tsetse/tsconfig.json",
srcs = [
"positives.ts",
],
@@ -37,6 +36,7 @@
"\(44,34\).*" + error_message,
"\(45,34\).*" + error_message,
],
+ tsconfig = "//internal:tsetse/tsconfig.json",
deps = [
],
)
@@ -44,8 +44,8 @@
ts_library(
name = "negatives",
testonly = 1,
- tsconfig = "//internal:tsetse/tsconfig.json",
srcs = ["negatives.ts"],
+ tsconfig = "//internal:tsetse/tsconfig.json",
deps = [
],
)
diff --git a/internal/tsetse/tests/check_return_value/BUILD b/internal/tsetse/tests/check_return_value/BUILD
index be2414a..1e7188d 100644
--- a/internal/tsetse/tests/check_return_value/BUILD
+++ b/internal/tsetse/tests/check_return_value/BUILD
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-licenses(["notice"]) # Apache 2.0
-
load("//internal:defaults.bzl", "ts_library")
+licenses(["notice"]) # Apache 2.0
+
error_message = "TS21222: return value is unused.\\n\\tSee http://tsetse.info/check-return-value"
diff --git a/internal/tsetse/tests/equals_nan/BUILD b/internal/tsetse/tests/equals_nan/BUILD
index dd08612..db8a287 100644
--- a/internal/tsetse/tests/equals_nan/BUILD
+++ b/internal/tsetse/tests/equals_nan/BUILD
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-licenses(["notice"]) # Apache 2.0
-
load("//internal:defaults.bzl", "ts_library")
+licenses(["notice"]) # Apache 2.0
+
ts_library(
name = "positives",
diff --git a/internal/tsetse/tests/must_use_promises/BUILD b/internal/tsetse/tests/must_use_promises/BUILD
index 16dddf4..cc73c8a 100644
--- a/internal/tsetse/tests/must_use_promises/BUILD
+++ b/internal/tsetse/tests/must_use_promises/BUILD
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-licenses(["notice"]) # Apache 2.0
-
load("//internal:defaults.bzl", "ts_library")
+licenses(["notice"]) # Apache 2.0
+
error_message = "TS21225: All Promises in async functions must either be awaited or used in an expression."
@@ -25,7 +25,6 @@
srcs = [
"positives.ts",
],
- tsconfig = "//internal:tsetse/tsconfig.json",
expected_diagnostics = [
"\(29,3\)" + error_message,
"\(30,3\)" + error_message,
@@ -33,6 +32,7 @@
"\(32,3\)" + error_message,
"\(34,3\)" + error_message,
],
+ tsconfig = "//internal:tsetse/tsconfig.json",
deps = [
],
)
diff --git a/package.json b/package.json
index 2dd3061..77ac9cd 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
},
"devDependencies": {
"@bazel/ibazel": "^0.2.0",
+ "@bazel/buildifier": "^0.20.0",
"@bazel/typescript": "0.19.1",
"@types/jasmine": "^2.8.2",
"@types/long": "^4.0.0",
@@ -56,6 +57,9 @@
"//": "disable deprecated-api skylint check because we must make legacy-style providers for TS interop in google3",
"skylint": "find . -type f -name \"*.bzl\" ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/io_bazel/src/tools/skylark/java/com/google/devtools/skylark/skylint/Skylint --disable-checks=deprecated-api",
"skydoc": "bazel build //docs && unzip -o -d docs/api bazel-bin/docs/docs-skydoc.zip",
- "version": "node ./on-version.js && git stage package.bzl"
+ "version": "node ./on-version.js && git stage package.bzl",
+ "bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=args-order,attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable",
+ "bazel:lint": "yarn bazel:format --lint=warn",
+ "bazel:lint-fix": "yarn bazel:format --lint=fix"
}
}
diff --git a/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel b/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel
index 3b835fd..ce4c415 100644
--- a/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel
+++ b/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel
@@ -1,8 +1,8 @@
-package(default_visibility = ["//:__pkg__"])
-
+load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
+
+package(default_visibility = ["//:__pkg__"])
licenses(["notice"]) # Apache 2.0
@@ -30,11 +30,10 @@
)
pkg_tar(
- name = "package",
- srcs = [
- "BUILD.bazel",
- "worker_protocol.proto",
- ],
- package_dir = "third_party/github.com/bazelbuild/bazel/src/main/protobuf",
+ name = "package",
+ srcs = [
+ "BUILD.bazel",
+ "worker_protocol.proto",
+ ],
+ package_dir = "third_party/github.com/bazelbuild/bazel/src/main/protobuf",
)
-
diff --git a/yarn.lock b/yarn.lock
index 8d09cb4..b7f47a0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,6 +2,24 @@
# yarn lockfile v1
+"@bazel/buildifier-darwin_x64@0.20.0":
+ version "0.20.0"
+ resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.20.0.tgz#1aeceb5a1a57a62eef6415377dbe95091781a7d4"
+ integrity sha512-yV7niwbdpDDPUw1vgyk1wIjPl3+YOM4o5FPgFmnFgzf48JUqrF3PK6Blg95Z8SqGOVoJAOChRC1GvopzEUzwZA==
+
+"@bazel/buildifier-linux_x64@0.20.0":
+ version "0.20.0"
+ resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.20.0.tgz#8cb6c8f999dbd8a9ee183906f202b698571d771b"
+ integrity sha512-djbBtcacgERWZoxjEm8lGmMyEaOYB3moiz0kioHTQc2F96wNLfm6Cikd4Ojrcj5VNQCMW9oy3YFTu+c5mIrCcA==
+
+"@bazel/buildifier@^0.20.0":
+ version "0.20.0"
+ resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.20.0.tgz#24a10e485fe65dbd75ef812cf37635df1fb91d0d"
+ integrity sha512-dahQRtE1KEp+efUV23q/JtOCSbQEk5C/+H3J33g8wP5roxMUa8mfDto85eloJ+gRPW7yOybxknuRYc4KSpgT7w==
+ optionalDependencies:
+ "@bazel/buildifier-darwin_x64" "0.20.0"
+ "@bazel/buildifier-linux_x64" "0.20.0"
+
"@bazel/ibazel@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.2.0.tgz#c119aef4344a789cef5e792caaee52264123e71c"