1load("@aspect_rules_js//js:defs.bzl", "js_library", "js_test") 2load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 3load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library") 4load("@rules_rust//wasm_bindgen/rules_js:defs.bzl", "js_rust_wasm_bindgen") 5 6package(default_visibility = ["//visibility:public"]) 7 8copy_file( 9 name = "hello_world_wasm_test.src", 10 src = "//wasm_bindgen:hello_world_wasm_test.js", 11 out = "hello_world_wasm_test.js", 12) 13 14rust_binary( 15 name = "hello_world_bin_wasm", 16 srcs = ["//wasm_bindgen:main.rs"], 17 edition = "2018", 18 deps = [ 19 "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen", 20 ], 21) 22 23rust_shared_library( 24 name = "hello_world_lib_wasm", 25 srcs = ["//wasm_bindgen:main.rs"], 26 edition = "2018", 27 deps = [ 28 "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen", 29 ], 30) 31 32js_rust_wasm_bindgen( 33 name = "hello_world_bundler_wasm_bindgen", 34 wasm_file = ":hello_world_bin_wasm", 35) 36 37js_rust_wasm_bindgen( 38 name = "hello_world_web_wasm_bindgen", 39 target = "web", 40 wasm_file = ":hello_world_lib_wasm", 41) 42 43js_rust_wasm_bindgen( 44 name = "hello_world_deno_wasm_bindgen", 45 target = "deno", 46 wasm_file = ":hello_world_lib_wasm", 47) 48 49js_rust_wasm_bindgen( 50 name = "hello_world_nomodules_wasm_bindgen", 51 target = "no-modules", 52 wasm_file = ":hello_world_lib_wasm", 53) 54 55js_rust_wasm_bindgen( 56 name = "hello_world_nodejs_wasm_bindgen", 57 target = "nodejs", 58 wasm_file = ":hello_world_lib_wasm", 59) 60 61js_rust_wasm_bindgen( 62 name = "hello_world_nodejs_no_typescript_wasm_bindgen", 63 bindgen_flags = [ 64 "--no-typescript", 65 ], 66 target = "nodejs", 67 wasm_file = ":hello_world_lib_wasm", 68) 69 70_WASM_DATA = [ 71 ":hello_world_bundler_wasm_bindgen", 72 ":hello_world_deno_wasm_bindgen", 73 ":hello_world_nodejs_wasm_bindgen", 74 ":hello_world_nomodules_wasm_bindgen", 75 ":hello_world_web_wasm_bindgen", 76] 77 78js_test( 79 name = "hello_world_wasm_direct_test", 80 data = _WASM_DATA, 81 entry_point = ":hello_world_wasm_test.js", 82) 83 84js_library( 85 name = "hello_world_wasm_lib", 86 srcs = [ 87 ":hello_world_wasm_test.js", 88 ], 89 data = _WASM_DATA, 90 deps = [], 91) 92 93js_test( 94 name = "hello_world_wasm_lib_test", 95 data = [ 96 ":hello_world_wasm_lib", 97 ], 98 entry_point = ":hello_world_wasm_lib", 99) 100