1.3.5 • Published 6 years ago

razzle-plugin-wasm v1.3.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

npm version

razzle-plugin-wasm

This package contains a plugin to load wasm files with razzle

Usage in Razzle Projects

yarn add razzle-plugin-wasm --dev

create a razzle.config.js file in root directory of project (next to the package.json) and put this content inside it

Using the plugin with the default options

// razzle.config.js

module.exports = {
  plugins: ['wasm'],
};

Usage

import('./add.wasm').then(addModule=>{
  console.log(addModule(5, 6));
})

Usage with emscripten modules, built without SINGLE_FILE

// modulename.mjs renamed from module.js
import moduleLoader from './modulename.mjs'; // important, use .mjs 
import moduleWasm from './modulename.wasm';

// Since webpack will change the name and potentially the path of the 
// `.wasm` file, we have to provide a `locateFile()` hook to redirect
// to the appropriate URL.
// More details: https://kripken.github.io/emscripten-site/docs/api_reference/module.html
const mod = moduleLoader({
  locateFile(path) {
    if(path.endsWith('.wasm')) {
      return moduleWasm;
    }
    return path;
  }
});

mod.onRuntimeInitialized = async () => {
 console.log('Emscripten runtime loaded');
};

Usage with emscripten modules, built with SINGLE_FILE

// modulename.mjs renamed from module.js
import mod from './modulename.mjs'; // important, use .mjs 

mod.onRuntimeInitialized = async () => {
 console.log('Emscripten runtime loaded');
};
1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago