Skip to content

Commit 8824341

Browse files
committed
feat: use uint8array to facilitate browser use
1 parent 61b4cca commit 8824341

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
@@ -310,7 +310,7 @@ impl<'a> Context<'a> {
310310

311311
let buf = self.module.emit_wasm();
312312

313-
let mut serialized = "const bytes = Buffer.from([".to_string();
313+
let mut serialized = "const bytes = new Uint8Array([".to_string();
314314
let (last, bytes) = buf.split_last().unwrap();
315315
for byte in bytes {
316316
serialized.push_str(&format!("{},", byte));
@@ -320,7 +320,7 @@ impl<'a> Context<'a> {
320320
shim.push_str(&serialized);
321321
shim.push_str(
322322
"
323-
const wasmModule = new WebAssembly.Module(bytes);
323+
const wasmModule = new WebAssembly.Module(bytes.buffer);
324324
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
325325
wasm = wasmInstance.exports;
326326
module.exports.__wasm = wasm;

0 commit comments

Comments
 (0)