Skip to content

rosen-bridge/rollup-plugin-node-wasm

Repository files navigation

@rosen-bridge/rollup-plugin-node-wasm

Table of contents

Introduction

@rosen-bridge/rollup-plugin-node-wasm is a rollup plugin to inline packages that are built using wasm-pack for with node target.

This plugin is needed because the official wasm plugin doesn't support wasm packages that are build for node target. If you want to use that package, you should use the browser version of the package (if present) and change your source code a bit, which may not be what you want.

The reason why the official wasm plugin doesn't support node-targetted packages is that, it uses node file system apis to read the contents of .wasm file (instead of importing it using js syntax, which happens in browser builds). This plugin parses any js file that contains special wasm-pack js statements (which try to read contents of wasm file through node api) and try to put an inline base64 version of the wasm file inside the bundle instead. Please note that this inlining comes with a bundle size cost.

Installation

npm:

npm i @rosen-bridge/rollup-plugin-node-wasm

yarn:

yarn add @rosen-bridge/rollup-plugin-node-wasm

Usage

Simply import the plugin and add it to your rollup config:

import nodeWasm from '@rosen-bridge/rollup-plugin-node-wasm';

export default {
  // your options
  plugins: [nodeWasm()],
};

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published