Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMitchell-at committed Oct 2, 2024
1 parent 2ae08ff commit e0b00bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
15 changes: 9 additions & 6 deletions ts/private/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,18 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
args = ctx.actions.args()
args.add_all(common_args)

args.add("--noEmit")

env = {
"BAZEL_BINDIR": ctx.bin_dir.path,
}

if supports_workers:
args.use_param_file("@%s", use_always = True)
args.set_param_file_format("multiline")
args.add("--bazelValidationFile", typecheck_output.short_path)

args.add("--noEmit")
else:
env["JS_BINARY__STDOUT_OUTPUT_FILE"] = typecheck_output.path

ctx.actions.run(
executable = executable,
Expand All @@ -253,10 +259,7 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
ctx.label,
tsconfig_path,
),
env = {
"BAZEL_BINDIR": ctx.bin_dir.path,
"JS_BINARY__STDOUT_OUTPUT_FILE": typecheck_output.path,
},
env = env,
)
else:
typecheck_outs.extend(output_types)
Expand Down
20 changes: 11 additions & 9 deletions ts/private/ts_project_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function createFilesystemTree(root, inputs) {
if (typeof node == "object" && node[Type] == TYPE.SYMLINK) {
return parents.join(path.sep);
}

return undefined;
}

Expand Down Expand Up @@ -881,9 +881,11 @@ async function emit(request) {
debug(`# Beginning new work`);
debug(`arguments: ${request.arguments.join(' ')}`)

const validationPath = request.arguments[request.arguments.indexOf('--bazelValidationFile') + 1]
fs.writeFileSync(path.resolve(process.cwd(), validationPath), '');

if (request.arguments.includes('--bazelValidationFile')) {
const [, validationPath] = request.arguments.splice(request.arguments.indexOf('--bazelValidationFile'), 2);
fs.writeFileSync(path.resolve(process.cwd(), validationPath), '');
}

const inputs = Object.fromEntries(
request.inputs.map(input => [
input.path,
Expand Down Expand Up @@ -946,22 +948,22 @@ async function emit(request) {
const diagnostics = ts.getPreEmitDiagnostics(program, undefined, cancellationToken).concat(result?.diagnostics);
timingEnd('diagnostics');

const succeded = diagnostics.length === 0;
const succeeded = diagnostics.length === 0;

if (!succeded) {
if (!succeeded) {
request.output.write(worker.formatDiagnostics(diagnostics));
VERBOSE && worker.printFSTree()
}

if (ts.performance && ts.performance.isEnabled()) {
ts.performance.forEachMeasure((name, duration) => request.output.write(`${name} time: ${duration}\n`));
}

worker.previousInputs = inputs;
worker.postRun();

debug(`# Finished the work`);
return succeded ? 0 : 1;
return succeeded ? 0 : 1;
}


Expand Down Expand Up @@ -998,7 +1000,7 @@ if (require.main === module && worker_protocol.isPersistentWorker(process.argv))
const args = fs.readFileSync(p).toString().trim().split('\n');

if (args.includes('--bazelValidationFile')) {
const [, validationPath] = args.splice(args.indexOf('--bazelValidationFile'), 2);
const [, validationPath] = args.splice(args.indexOf('--bazelValidationFile'), 2);
fs.writeFileSync(path.resolve(process.cwd(), validationPath), '');
}

Expand Down

0 comments on commit e0b00bf

Please sign in to comment.