Skip to content

Commit

Permalink
fix: log on standalone failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Muller committed Nov 5, 2020
1 parent a69c6cd commit 83f8d37
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
23 changes: 21 additions & 2 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ _DEFAULT_TSC_BIN = (
"//:node_modules/typescript/bin/tsc"
)

_DEFAULT_TYPESCRIP_MODULE = (
# BEGIN-INTERNAL
"@npm" +
# END-INTERNAL
"//typescript"
)

_ATTRS = {
"args": attr.string_list(),
"declaration_dir": attr.string(),
Expand Down Expand Up @@ -314,6 +321,8 @@ def ts_project_macro(
emit_declaration_only = False,
ts_build_info_file = None,
tsc = None,
worker_tsc_bin = _DEFAULT_TSC_BIN,
worker_typescript_module = _DEFAULT_TYPESCRIP_MODULE,
validate = True,
supports_workers = False,
declaration_dir = None,
Expand Down Expand Up @@ -481,6 +490,15 @@ def ts_project_macro(
For example, `tsc = "@my_deps//typescript/bin:tsc"`
Or you can pass a custom compiler binary instead.
worker_tsc_bin: Label of the TypeScript compiler binary to run when running in worker mode.
For example, `tsc = "@my_deps//node_modules/typescript/bin/tsc"`
Or you can pass a custom compiler binary instead.
worker_typescript_module: Label of the package containing all data deps of worker_tsc_bin.
For example, `tsc = "@my_deps//typescript"`
validate: boolean; whether to check that the tsconfig settings match the attributes.
supports_workers: Experimental! Use only with caution.
Expand Down Expand Up @@ -604,14 +622,15 @@ def ts_project_macro(
name = tsc_worker,
data = [
Label("//packages/typescript/internal/worker:worker"),
Label(_DEFAULT_TSC_BIN),
Label(worker_tsc_bin),
Label(worker_typescript_module),
Label(protobufjs),
tsconfig,
],
entry_point = Label("//packages/typescript/internal/worker:worker_adapter"),
templated_args = [
"--nobazel_patch_module_resolver",
"$(execpath {})".format(Label(_DEFAULT_TSC_BIN)),
"$(execpath {})".format(Label(worker_tsc_bin)),
"--project",
"$(execpath {})".format(tsconfig),
# FIXME: should take out_dir into account
Expand Down
20 changes: 19 additions & 1 deletion packages/typescript/internal/worker/worker_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,25 @@ async function main() {
`Started a new process to perform this action. Your build might be misconfigured, try
--strategy=${MNEMONIC}=worker`);

child.on('exit', code => process.exit(code));
const stdoutbuffer = [];
child.stdout.on('data', data => stdoutbuffer.push(data));

const stderrbuffer = [];
child.stderr.on('data', data => stderrbuffer.push(data));

child.on('exit', code => {
if (code !== 0) {
console.error(
`\nstdout from tsc:\n\n ${
stdoutbuffer.map(s => s.toString()).join('').replace(/\n/g, '\n ')}`,
)
console.error(
`\nstderr from tsc:\n\n ${
stderrbuffer.map(s => s.toString()).join('').replace(/\n/g, '\n ')}`,
)
}
process.exit(code)
});
}
}

Expand Down

0 comments on commit 83f8d37

Please sign in to comment.