Skip to content

Commit 323f2fa

Browse files
committed
feat: use uint8array to facilitate browser use
1 parent cb8a1f1 commit 323f2fa

File tree

1 file changed

+2
-2
lines changed
  • crates/cli-support/src/js

1 file changed

+2
-2
lines changed

crates/cli-support/src/js/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<'a> Context<'a> {
296296

297297
let buf = self.module.emit_wasm();
298298

299-
let mut serialized = "const bytes = Buffer.from([".to_string();
299+
let mut serialized = "const bytes = new Uint8Array([".to_string();
300300
let (last, bytes) = buf.split_last().unwrap();
301301
for byte in bytes {
302302
serialized.push_str(&format!("{},", byte));
@@ -306,7 +306,7 @@ impl<'a> Context<'a> {
306306
shim.push_str(&serialized);
307307
shim.push_str(
308308
"
309-
const wasmModule = new WebAssembly.Module(bytes);
309+
const wasmModule = new WebAssembly.Module(bytes.buffer);
310310
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
311311
wasm = wasmInstance.exports;
312312
module.exports.__wasm = wasm;

0 commit comments

Comments
 (0)