Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.1.0
9.1.1
7 changes: 0 additions & 7 deletions .github/workflows/_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ jobs:
# Strip comment in front of WORKERS_MIRROR_URL, then substitute secret to use it.
sed -e '/WORKERS_MIRROR_URL/ { s@# *@@; s@WORKERS_MIRROR_URL@${{ secrets.WORKERS_MIRROR_URL }}@; }' -i.bak build/deps/nodejs.MODULE.bazel
fi
- name: Bazel build (Windows workaround)
if: runner.os == 'Windows'
# HACK: Work around Bazel Windows bug: Some targets need to be compiled without symlink
# support. Since we still need symlinks to compile C++ code properly, compile these targets
# separately.
run: |
bazel --nowindows_enable_symlinks build ${{ inputs.extra_bazel_args }} --config=ci --profile build-win-workaround.bazel-profile.gz --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev //src/wpt:wpt-all@tsproject //src/node:node@tsproject //src/pyodide:pyodide_static@tsproject
- name: Bazel build
run: |
bazel build --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci ${{ inputs.extra_bazel_args }} //...
Expand Down
2 changes: 2 additions & 0 deletions build/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ build:ci --verbose_failures
# closer towards the suggested value of 200. Note the number of maximum build jobs is controlled by
# the --local_resources=cpu flag and still limited to the number of cores by default.
build:ci --jobs=64
# attempt to recover from remote cache errors without needing to retry build
build:ci --rewind_lost_inputs
# Do not check for changes in external repository files, should speed up bazel invocations after the first one
build:ci --noexperimental_check_external_repository_files
# Only build runfile trees when needed. Runfile trees are useful for directly invoking bazel-built
Expand Down
20 changes: 0 additions & 20 deletions build/wd_test.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@workerd//:build/lint_test.bzl", "lint_test")

def wd_test(
src,
data = [],
name = None,
args = [],
ts_deps = [],
lint = True,
python_snapshot_test = False,
generate_default_variant = True,
Expand Down Expand Up @@ -50,24 +48,6 @@ def wd_test(
name = src.removesuffix(".capnp").removesuffix(".wd-test").removesuffix(".ts-wd-test")

if len(ts_srcs) != 0:
# NOTE: We intentionally do not use isolated_typecheck here. While isolated_typecheck can

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm dropping this comment on purpose: isolated_typecheck would allow us to get rid of a type check action in cases where it is not needed which is why I was interested in it, but as the comment states this would require quite a bit of work and the gain is relatively small. This comment is an AI-generated replacement for a comment I originally wrote. There is no need to describe it in this much detail and for our purposes not having isolated_typecheck is not a big loss.

# improve build parallelism by separating transpilation from type-checking, it requires
# isolatedDeclarations in tsconfig (which mandates explicit return type annotations on all
# exports) and uses --noResolve during transpilation. The --noResolve flag prevents
# TypeScript from finding @types/node, breaking IDE support for Node.js imports like
# 'node:assert'. Since wd_test TypeScript files are typically standalone test files (leaf
# nodes in the dependency graph), the parallelization benefits would be minimal anyway.
ts_config(
name = name + "@ts_config",
src = "tsconfig.json",
deps = ["@workerd//tools:base-tsconfig"],
)
ts_project(
name = name + "@ts_project",
srcs = ts_srcs,
tsconfig = ":" + name + "@ts_config",
deps = ["//src/node:node@tsproject"] + ts_deps,
)
data += [js_src.removesuffix(".ts") + ".js" for js_src in ts_srcs]

if lint:
Expand Down
1 change: 1 addition & 0 deletions build/wd_ts_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def wd_ts_bundle(
srcs = ts_srcs,
allow_js = True,
declaration = True,
composite = True,
tsconfig = ":" + name + "@tsconfig",
deps = deps,
out_dir = out_dir.removesuffix("/"),
Expand Down
2 changes: 1 addition & 1 deletion build/wd_ts_project.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@workerd//:build/lint_test.bzl", "lint_test")

def wd_ts_project(name, srcs, deps, tsconfig_json, eslintrc_json = None, source_map = True, testonly = False, composite = False):
def wd_ts_project(name, srcs, deps, tsconfig_json, eslintrc_json = None, source_map = True, testonly = False, composite = True):
"""Bazel rule for a workerd TypeScript project, setting common options"""

ts_config(
Expand Down
2 changes: 1 addition & 1 deletion build/wd_ts_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_test")
load("//:build/typescript.bzl", "js_name", "module_name")
load("//:build/wd_ts_project.bzl", "wd_ts_project")

def wd_ts_test(src, tsconfig_json, deps = [], eslintrc_json = None, composite = False, **kwargs):
def wd_ts_test(src, tsconfig_json, deps = [], eslintrc_json = None, composite = True, **kwargs):
"""Bazel rule to compile and run a TypeScript test"""

name = module_name(src)
Expand Down
36 changes: 29 additions & 7 deletions src/workerd/api/tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//:build/wd_test.bzl", "wd_test")

# Compile all ts test sources in one project. This is needed to work around https://github.com/aspect-build/rules_ts/issues/664 –
# rules_ts transpiles all .ts files for each ts_project where the files are present based on the
# tsconfig "include": ["**/*.ts"] directive, which is an issue on Windows where Bazel does not have
# a proper sandbox, so it ends up trying to write to the same file path repeatedly.
# This approach does not scale well if we end up adding many more TS-based wd_tests since we need to
# transpile all TS sources before running TS-based wd-tests. At that point, we hopefully either have
# a proper Windows sandbox and can properly define a separate ts_project for each test, or we may
# have to put the files for a given test in a separate directory so that they are kept separate from
# the other ts files without sandboxing.
ts_config(
name = "ts_config",
src = "tsconfig.json",
deps = ["@workerd//tools:base-tsconfig"],
)

ts_project(
name = "ts_project",
srcs = glob(["*.ts"]),
composite = True,
tsconfig = ":ts_config",
deps = ["//src/node:node@tsproject"],
)

wd_test(
src = "messageport-postmessage-uaf-test.wd-test",
args = ["--experimental"],
Expand Down Expand Up @@ -385,13 +409,11 @@ wd_test(
data = ["form-data-test.js"],
)

# TODO(soon): Re-enable once it is determined why this test is failing
# consistently in CI on Windows in all variant
# wd_test(
# src = "form-data-test-ts.wd-test",
# args = ["--experimental"],
# data = ["form-data-test-ts.ts"],
# )
wd_test(
src = "form-data-test-ts.wd-test",
args = ["--experimental"],
data = ["form-data-test-ts.ts"],
)

wd_test(
src = "warnings-test.wd-test",
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/tests/form-data-test-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { strictEqual } from 'node:assert';

// https://github.com/cloudflare/workerd/issues/5934
export const formDataUnionTypeOverloads = {
test() {
test(): void {
const formData = new FormData();

formData.append('stringKey', 'stringValue' as string | Blob);
Expand Down
1 change: 1 addition & 0 deletions tools/base.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"allowJs": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"composite": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
Expand Down
2 changes: 0 additions & 2 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"@workerd/*": ["../bazel-bin/src/workerd/*"]
},
"checkJs": true,
"composite": true,
"skipLibCheck": true,

"exactOptionalPropertyTypes": false,
"strictNullChecks": false,
"noImplicitReturns": false,
Expand Down
Loading