Skip to content

Commit

Permalink
chore: cleanups on ts_project worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eagle committed Sep 7, 2020
1 parent a57a342 commit d533f52
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 59 deletions.
26 changes: 15 additions & 11 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,11 @@ def ts_project_macro(
)
extra_deps.append("_validate_%s_options" % name)

is_windows = select({
"@bazel_tools//src/conditions:host_windows": True,
"//conditions:default": False,
})
supports_workers = supports_workers and not is_windows
if supports_workers:
worker_name = name + "_worker"
if not tsc:
tsc = _DEFAULT_TSC
nodejs_binary(
name = worker_name,
name = "%s_worker" % name,
data = [
tsconfig,
"//packages/typescript/internal/worker:copy_worker_js",
Expand All @@ -568,15 +564,16 @@ def ts_project_macro(
entry_point = "//packages/typescript/internal/worker:worker_adapter",
templated_args = [
"--nobazel_patch_module_resolver",
"$(rootpath {tsc})".format(tsc = tsc),
"$(rootpaths {})".format(tsc),
"--project",
"$(execpath {tsconfig})".format(tsconfig = tsconfig),
"$(execpath {})".format(tsconfig),
# FIXME: should take out_dir into account
"--outDir",
"$(RULEDIR)",
# FIXME: what about other settings like declaration_dir, root_dir, etc
"--watch",
],
)
tsc = ":" + worker_name

typings_out_dir = declaration_dir if declaration_dir else out_dir
tsbuildinfo_path = ts_build_info_file if ts_build_info_file else name + ".tsbuildinfo"
Expand All @@ -600,6 +597,13 @@ def ts_project_macro(
typings_outs = _out_paths(srcs, typings_out_dir, root_dir, ".d.ts") if declaration or composite else [],
typing_maps_outs = _out_paths(srcs, typings_out_dir, root_dir, ".d.ts.map") if declaration_map else [],
buildinfo_out = tsbuildinfo_path if composite or incremental else None,
tsc = tsc,
tsc = select({
"@bazel_tools//src/conditions:host_windows": tsc,
"//conditions:default": "%s_worker" % name if supports_workers else tsc,
}),
supports_workers = select({
"@bazel_tools//src/conditions:host_windows": False,
"//conditions:default": supports_workers,
}),
**kwargs
)
6 changes: 5 additions & 1 deletion packages/typescript/test/ts_project/worker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
load("//packages/typescript:index.bzl", "ts_project")

ts_project(
declaration = True,
supports_workers = True,
tsconfig = {
"compilerOptions": {
"declaration": True,
},
},
)
2 changes: 1 addition & 1 deletion packages/typescript/test/ts_project/worker/big.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// TODO: make it big enough to slow down tsc

export const a: number = 45;
export const a: number = 47;
6 changes: 0 additions & 6 deletions packages/typescript/test/ts_project/worker/tsconfig.json

This file was deleted.

40 changes: 0 additions & 40 deletions packages/typescript/test/ts_project/worker/worker_adapter.js

This file was deleted.

0 comments on commit d533f52

Please sign in to comment.