Respect "--no-typescript" flag in wasm_bindgen (#2765)

Don't expect typescript outputs if this flag is set.

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
This commit is contained in:
Duarte Nunes 2024-07-29 19:05:24 -03:00 committed by GitHub
parent f0276ea585
commit b5ecaea4b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -58,6 +58,15 @@ js_rust_wasm_bindgen(
wasm_file = ":hello_world_lib_wasm",
)
js_rust_wasm_bindgen(
name = "hello_world_nodejs_no_typescript_wasm_bindgen",
bindgen_flags = [
"--no-typescript",
],
target = "nodejs",
wasm_file = ":hello_world_lib_wasm",
)
_WASM_DATA = [
":hello_world_bundler_wasm_bindgen",
":hello_world_deno_wasm_bindgen",

View File

@ -53,11 +53,14 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f
bindgen_wasm_module = ctx.actions.declare_file(ctx.label.name + "_bg.wasm")
js_out = [ctx.actions.declare_file(ctx.label.name + ".js")]
ts_out = [ctx.actions.declare_file(ctx.label.name + ".d.ts")]
ts_out = []
if not "--no-typescript" in bindgen_flags:
ts_out.append(ctx.actions.declare_file(ctx.label.name + ".d.ts"))
if target_output == "bundler":
js_out.append(ctx.actions.declare_file(ctx.label.name + "_bg.js"))
ts_out.append(ctx.actions.declare_file(ctx.label.name + "_bg.wasm.d.ts"))
if not "--no-typescript" in bindgen_flags:
ts_out.append(ctx.actions.declare_file(ctx.label.name + "_bg.wasm.d.ts"))
outputs = [bindgen_wasm_module] + js_out + ts_out