npm.io
1.9.5 • Published yesterday

@hpcc-js/esbuild-plugins

Licence
Apache-2.0
Version
1.9.5
Deps
7
Size
923 kB
Vulns
0
Weekly
0
Stars
386

esbuild-plugin-sfx-wasm

Installation

With npm:

npm i -D esbuild-plugin-sfx-wasm

Use-cases

The primary motivation for this plugin is to simplify the bundling and distribution of web assembly modules

  • Compresses the wasm module using Zstd
  • Encodes the compressed wasm module as a base91 string
  • Generates a standalone module that decodes and instantiates the wasm module on demand

Usage

Build Config
import esbuild from "esbuild";
import sfxWasm from "esbuild-plugin-sfx-wasm";

esbuild.build({
  /* ... */
  plugins: [
    sfxWasm()
  ],
  /* ... */
});
Usage in your code
import loadCalculator from "../build/calculator.wasm";

async function add(a, b) {
  const calc = await loadCalculator();
  return calc.add(1, 2);
}

Keywords