File
Blob: types/BUILD.bazel
| 1 | load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary") |
| 2 | load("//:build/wd_ts_project.bzl", "wd_ts_project") |
| 3 | load("//:build/wd_ts_test.bzl", "wd_ts_test") |
| 4 | load("//:build/wd_ts_type_test.bzl", "wd_ts_type_test") |
| 5 | |
| 6 | wd_ts_project( |
| 7 | name = "types_lib", |
| 8 | srcs = glob( |
| 9 | [ |
| 10 | "src/**/*", |
| 11 | "scripts/*.ts", |
| 12 | ], |
| 13 | exclude = ["src/worker/**/*"], |
| 14 | ), |
| 15 | composite = True, |
| 16 | eslintrc_json = "eslint.config.mjs", |
| 17 | tsconfig_json = "//types:tsconfig.json", |
| 18 | deps = [ |
| 19 | "//:node_modules/@types/node", |
| 20 | "//:node_modules/@workerd/jsg", |
| 21 | "//:node_modules/capnp-es", |
| 22 | "//:node_modules/esbuild", |
| 23 | "//:node_modules/prettier", |
| 24 | "//:node_modules/typescript", |
| 25 | ], |
| 26 | ) |
| 27 | |
| 28 | js_binary( |
| 29 | name = "build_types_bin", |
| 30 | data = [ |
| 31 | ":types_lib", |
| 32 | ], |
| 33 | entry_point = "scripts/build-types.js", |
| 34 | tags = ["manual"], |
| 35 | ) |
| 36 | |
| 37 | js_run_binary( |
| 38 | name = "types", |
| 39 | srcs = [ |
| 40 | "scripts/config.capnp", |
| 41 | ":types_worker", |
| 42 | "//:node_modules/prettier", |
| 43 | "//src/workerd/server:workerd", |
| 44 | ], |
| 45 | out_dirs = ["definitions"], |
| 46 | silent_on_success = False, # Always enable logging for debugging |
| 47 | # Exclude from wildcard builds (//...) - type generation is expensive and only needed |
| 48 | # for the check-snapshot job which explicitly builds //types. |
| 49 | tags = ["manual"], |
| 50 | tool = ":build_types_bin", |
| 51 | visibility = ["//visibility:public"], |
| 52 | ) |
| 53 | |
| 54 | js_binary( |
| 55 | name = "build_worker_bin", |
| 56 | data = [ |
| 57 | ":types_lib", |
| 58 | ], |
| 59 | entry_point = "scripts/build-worker.js", |
| 60 | node_options = ["--enable-source-maps"], |
| 61 | tags = ["manual"], |
| 62 | ) |
| 63 | |
| 64 | js_run_binary( |
| 65 | name = "types_worker", |
| 66 | srcs = [ |
| 67 | "//:node_modules/@workerd/jsg", |
| 68 | "//:node_modules/capnp-es", |
| 69 | "//:node_modules/esbuild", |
| 70 | "//:node_modules/typescript", |
| 71 | "//src/workerd/tools:param_extractor", |
| 72 | ] + glob( |
| 73 | [ |
| 74 | "src/**/*.ts", |
| 75 | "defines/**/*.ts", |
| 76 | ], |
| 77 | exclude = ["src/cli/**/*"], |
| 78 | ), |
| 79 | outs = ["dist/index.mjs"], |
| 80 | # Only used by //types:types which is also manual |
| 81 | tags = ["manual"], |
| 82 | tool = ":build_worker_bin", |
| 83 | ) |
| 84 | |
| 85 | [ |
| 86 | wd_ts_test( |
| 87 | src = src, |
| 88 | composite = True, |
| 89 | node_options = ["--enable-source-maps"], |
| 90 | tsconfig_json = "//types:tsconfig.json", |
| 91 | deps = [":types_lib"], |
| 92 | ) |
| 93 | for src in glob(["test/**/*.spec.ts"]) |
| 94 | ] |
| 95 | |
| 96 | [ |
| 97 | wd_ts_type_test(src = src) |
| 98 | for src in glob(["test/types/**/*.ts"]) |
| 99 | ] |