Skip to content

Commit 40b6077

Browse files
committed
Optimize types/definitions build process
Improve the build system to only rebuild types when source files change, rather than rebuilding for every build. This is accomplished by: 1. Adding explicit file dependencies to the types target 2. Creating a new build_types_when_needed target that tracks source files 3. Adding a convenient alias in the root BUILD.bazel
1 parent ca2132f commit 40b6077

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ js_library(
9898
srcs = [".prettierrc.json"],
9999
visibility = ["//visibility:public"],
100100
)
101+
102+
# Smart types target that only rebuilds when necessary
103+
alias(
104+
name = "types",
105+
actual = "//types:build_types_when_needed",
106+
visibility = ["//visibility:public"],
107+
)

types/BUILD.bazel

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ js_run_binary(
3737
":types_worker",
3838
"//:node_modules/prettier",
3939
"//src/workerd/server:workerd",
40-
],
40+
# Add explicit dependencies on type definition files
41+
] + glob(["defines/**/*.d.ts"]),
4142
out_dirs = ["definitions"],
4243
silent_on_success = False, # Always enable logging for debugging
44+
tags = ["manual"], # Add manual tag so it doesn't build by default
4345
tool = ":build_types_bin",
4446
visibility = ["//visibility:public"],
4547
)
@@ -53,6 +55,20 @@ js_binary(
5355
node_options = ["--enable-source-maps"],
5456
)
5557

58+
# This is a wrapper target that only rebuilds the types when necessary
59+
js_run_binary(
60+
name = "build_types_when_needed",
61+
srcs = [
62+
"scripts/config.capnp",
63+
":types_worker",
64+
"//:node_modules/prettier",
65+
"//src/workerd/server:workerd",
66+
] + glob(["defines/**/*.d.ts"]) + glob(["src/transforms/**/*.ts"]),
67+
out_dirs = ["definitions"],
68+
tool = ":build_types_bin",
69+
visibility = ["//visibility:public"],
70+
)
71+
5672
js_run_binary(
5773
name = "types_worker",
5874
srcs = [

0 commit comments

Comments
 (0)