- mode 1: call putImageData from rust/wasm. This involves copying the image data via the wasm-bindgen API. - mode 2: allocating memory in rust/wasm and returning reference to it for JS code. JS code calls draw2 using the reference so now image data is copying in either direction. - mode 3: same as mode 2 but the draw3 function treats the memory as a vector of u32 instead of a vector of u8.
12 lines
376 B
JavaScript
12 lines
376 B
JavaScript
// Currently WebAssembly modules cannot be synchronously imported in the main
|
|
// chunk: https://github.com/webpack/webpack/issues/6615
|
|
//
|
|
// By dynamically importing index.js webpack will split it into a separate chunk
|
|
// automatically, where synchronous imports of WebAssembly is allowed.
|
|
|
|
const index = import("./index");
|
|
index.then(() => {
|
|
console.log("Loaded...");
|
|
});
|
|
|