From 60a3e9ff5c31cdb454ef91e327672dc3964163d5 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 1 Nov 2024 15:43:27 -0700 Subject: [PATCH] fix: support --incompatible_disallow_empty_glob (#731) * fix: support --incompatible_disallow_empty_glob This flag was flipped for Bazel 8 * switch our flag setting * chore(deps): upgrade stardoc * chore: docgen * chore: bump rules_proto --- .bazelrc | 4 ++-- MODULE.bazel | 9 +-------- docs/proto.md | 2 ++ docs/repositories.md | 2 ++ docs/rules.md | 9 ++++++++- internal_deps.bzl | 13 ++++++++----- ts/defs.bzl | 4 ++-- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.bazelrc b/.bazelrc index 8939867b..5cf8b495 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,8 +11,8 @@ import %workspace%/.aspect/bazelrc/performance.bazelrc common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig common --@aspect_rules_ts//ts:default_to_tsc_transpiler -# We have some empty globs in this repo -common --noincompatible_disallow_empty_glob +# opt-in to flag that is on by default in Bazel 8 +common --incompatible_disallow_empty_glob # Never Compile protoc Again common --incompatible_enable_proto_toolchain_resolution diff --git a/MODULE.bazel b/MODULE.bazel index 3d1704f3..845f2fef 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -27,7 +27,7 @@ bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True, repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True) -bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") +bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True, repo_name = "io_bazel_stardoc") bazel_dep(name = "toolchains_protoc", version = "0.3.0", dev_dependency = True) # Should not be required, stardoc leaks a dependency @@ -38,13 +38,6 @@ register_toolchains( dev_dependency = True, ) -# pick up fix: https://github.com/bazelbuild/stardoc/pull/221 -git_override( - module_name = "stardoc", - commit = "3baa5d1761970c6285d2ac9c3adccfaac42f54c5", - remote = "https://github.com/bazelbuild/stardoc.git", -) - npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( name = "npm", diff --git a/docs/proto.md b/docs/proto.md index 1b388763..25aaf3a2 100644 --- a/docs/proto.md +++ b/docs/proto.md @@ -47,6 +47,8 @@ Future work ## ts_proto_library
+load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
+
 ts_proto_library(name, node_modules, proto, protoc_gen_options, gen_connect_es, gen_connect_query,
                  gen_connect_query_service_mapping, copy_files, proto_srcs, files_to_copy, kwargs)
 
diff --git a/docs/repositories.md b/docs/repositories.md index 5d774343..0c133cc4 100644 --- a/docs/repositories.md +++ b/docs/repositories.md @@ -10,6 +10,8 @@ See https://docs.bazel.build/versions/main/skylark/deploying.html#dependencies ## rules_ts_dependencies
+load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
+
 rules_ts_dependencies(name, ts_version_from, ts_version, ts_integrity)
 
diff --git a/docs/rules.md b/docs/rules.md index 2ed71fb0..7dbfa0a9 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -10,6 +10,8 @@ inputs and produces JavaScript or declaration (.d.ts) outputs. ## ts_config
+load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
+
 ts_config(name, deps, src)
 
@@ -35,6 +37,8 @@ extended configuration file as well, to pass them both to the TypeScript compile ## ts_project_rule
+load("@aspect_rules_ts//ts:defs.bzl", "ts_project_rule")
+
 ts_project_rule(name, deps, srcs, data, allow_js, args, assets, buildinfo_out, composite,
                 declaration, declaration_dir, declaration_map, declaration_transpile,
                 emit_declaration_only, extends, incremental, is_typescript_5_or_greater,
@@ -101,6 +105,8 @@ for srcs and tsconfig, and pre-declaring output files.
 ## TsConfigInfo
 
 
+load("@aspect_rules_ts//ts:defs.bzl", "TsConfigInfo")
+
 TsConfigInfo(deps)
 
@@ -110,7 +116,6 @@ along with any transitively referenced tsconfig.json files chained by the **FIELDS** - | Name | Description | | :------------- | :------------- | | deps | all tsconfig.json files needed to configure TypeScript | @@ -121,6 +126,8 @@ along with any transitively referenced tsconfig.json files chained by the ## ts_project
+load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
+
 ts_project(name, tsconfig, srcs, args, data, deps, assets, extends, allow_js, isolated_typecheck,
            declaration, source_map, declaration_map, resolve_json_module, preserve_jsx, composite,
            incremental, no_emit, emit_declaration_only, transpiler, declaration_transpiler,
diff --git a/internal_deps.bzl b/internal_deps.bzl
index a6d74d1c..51359e13 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -33,8 +33,11 @@ def rules_ts_internal_deps():
 
     http_archive(
         name = "io_bazel_stardoc",
-        sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432",
-        urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz"],
+        sha256 = "fabb280f6c92a3b55eed89a918ca91e39fb733373c81e87a18ae9e33e75023ec",
+        urls = [
+            "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.7.1/stardoc-0.7.1.tar.gz",
+            "https://github.com/bazelbuild/stardoc/releases/download/0.7.1/stardoc-0.7.1.tar.gz",
+        ],
     )
 
     http_archive(
@@ -46,9 +49,9 @@ def rules_ts_internal_deps():
 
     http_archive(
         name = "rules_proto",
-        sha256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d",
-        strip_prefix = "rules_proto-6.0.0",
-        url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0/rules_proto-6.0.0.tar.gz",
+        sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
+        strip_prefix = "rules_proto-6.0.2",
+        url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
     )
 
     http_archive(
diff --git a/ts/defs.bzl b/ts/defs.bzl
index 648cc739..9ff154d6 100644
--- a/ts/defs.bzl
+++ b/ts/defs.bzl
@@ -23,7 +23,7 @@ def _is_file_missing(label):
     """
     file_abs = "%s/%s" % (label.package, label.name)
     file_rel = file_abs[len(native.package_name()) + 1:]
-    file_glob = native.glob([file_rel])
+    file_glob = native.glob([file_rel], allow_empty = True)
     return len(file_glob) == 0
 
 _tsc = "@npm_typescript//:tsc"
@@ -475,7 +475,7 @@ def _default_srcs(allow_js, resolve_json_module):
         include.append("**/*.json")
         exclude.extend(["**/package.json", "**/package-lock.json", "**/tsconfig*.json"])
 
-    return native.glob(include, exclude)
+    return native.glob(include, exclude, allow_empty = True)
 
 def _invoke_custom_transpiler(type_str, transpiler, transpile_target_name, srcs, common_kwargs):
     if type(transpiler) == "function" or type(transpiler) == "rule":