npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remix-wasm-plugin

v0.3.6

Published

A simple plugin to add WASM capabilities to your remix app

Downloads

9

Readme

remix-wasm-plugin

This is a Remix plugin that allows you to use WASM modules in remix with no hassle by bundling them as static assets at compile time, improving the speed of your app and allowing for caching of *.wasm files.

Currently doesn't support wasm in the server. Only client-side packages that run in the browser.

Installation

npm i -D remix-wasm-plugin

After installation, run:

npx remix-wasm-plugin init

This command initialises a wasm.config.js file in your remix root that allows you to further configure your Remix + WASM experience.

Add this scripts to your package.json to build your wasm modules when your app is built:

{
  "scripts": {
    "build:wasm": "remix-wasm-plugin build",
    "dev:wasm": "remix-wasm-plugin build"
  }
}

Usage

To use remix-wasm-plugin in your application after initializing you config. file, update your the modules field in the config. with your wasm packages.

The name of the packages should be the same as it appears in your package.json.

/* WASM.config */
module.exports = {
  enabled: true,
  modules: ["my-wasm-package", "my-wasm-package-2", "@remix-run/wasm"]
}

If the package is scoped, include it together in the field. e.g @remix-pwa/client

Import initWithProps from remix-wasm-plugin into your entry.client.{tsx|jsx} file. Wrap the hydrateRoot function with the initWithProps function. After that, you can call functions from your wasm package like any native JS module.

import { initWithProps } from "remix-wasm-plugin";
// importing these should be documented in the wasm package
import init, { wasm } from "my-wasm-package"; 
import init2, { wasm2 } from "my-wasm-package-2";

initWithProps([init, wasm], [init2, wasm2]).then(() => {
  hydrateRoot(
    document, 
    <RemixBrowser />
  );
})

API

initWithProps

This function is used to initialize wasm modules in your application. It takes in arrays of the init function and the wasm file of your wasm package and returns a promise. After initialization, you can call functions from your wasm package anywhere in your Remix application.

import { initWithProps } from "remix-wasm-plugin";
import init, { wasm } from "my-wasm-package";
import init2, { wasm2 } from "my-wasm-package-2";
import init3, { wasm3 } from "my-wasm-package-3";

initWithProps([init, wasm], [init2, wasm2], [init3, wasm3]).then(() => {
  hydrateRoot(
    document, 
    <RemixBrowser />
  );
})

Configuration

Currently there are two configuration options you can set.

enabled: boolean

This option is for wether you want to enable wasm capabilities in your application

modules: string[]

This is an array of wasm modules you want to bundle into your app.