wasm-tool / wasi

Import WebAssembly modules that expose the WebAssembly System Interface (WASI).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wasm-tool/wasi

Import WebAssembly modules that expose the WebAssembly System Interface (WASI).

Installation

npm install --save-dev @wasm-tool/wasi

In JavaScript:

import("./example.wasm")
  .then(exports => {
      exports.someFunc();
   });

Usage: webpack

Include the following rule in your webpack configuration:

{
  // ...
  module: {
    rules: [
      {
        test: /\.wasm/,
        type: "javascript/auto",
        use: {
          loader: "@wasm-tool/wasi"
        }
      }
    ]
  }
  // ...
}

We need to set the type to JavaScript to bypass webpack's wasm support (as a workaround, for now). Which will also prevent the loading to work correclty in non-web environements.

About

Import WebAssembly modules that expose the WebAssembly System Interface (WASI).

License:MIT License


Languages

Language:JavaScript 87.0%Language:HTML 6.6%Language:Makefile 3.8%Language:C 2.6%