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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rollup-plugin-wit-component

v0.2.6

Published

A rollup plugin to bundle transpiled webassembly components

Readme

Rollup Plugin WIT (WebAssembly Interface Types) Component

When jco transpiles a WebAssembly Interface Types (WIT) component for wasm32-wasi target, it generates a number of .js and .wasm files if you use the wasi shims (like clocks, random, etc.). These files need to be bundled together to be used in the browser. Notably, the .wasm file needs to be converted to a Blob URL and the .js files need to be bundled together. This package includes a plugin which finds the .wasm files and transforms them into Blob URLs so they can be resolved by fetching that URL in the bundled .js file.

Thus, this plugin allows you to take WebAssembly component bytes and import it into the browser.

In the end, you get an ES Module with your Wasm functions exported.

Usage

See the example for the latest usage.

There is a convenience function call load that is exported from this library which makes combining .wasm bytes and importables easy. All you need are your wasm bytes and your importable functions.

Demo usage is at src/routes/+page.svelte.

To bundle your wit-component for the browser:

// You need to give the JavaScript code to `jco` so it can wire it up to the wasm component
let importableCode = `export function prnt(string) {
console.log('from imported code: ', string);
};`

// Make sure you're in the Browser environment when importing the plugin
// The Vite bundler bundles this library for the Browser environment
const { load } = await import('rollup-plugin-wit-component');

// Load the wasm component bytes as an array buffer
let wasmBytes = await fetch(wasmURL).then((res) => res.arrayBuffer());

// Map the WIT interface name to the code that implements the interface
let importables = [{ 'component:cargo-comp/imports': importableCode }];

// Load the wasm component + imports to get the exported module functions
let mod = await load(wasmBytes, importables);

// mod.an_export_function() is now available and can call prnt function.

Demo

  1. First you need a Wasm Interface Type Component to load. A demo component written in Rust is located at crates/demo.

  2. The component from 1) needs to implement the interface, which is defined in the wit file crates/demo/wit/world.wit.

More details located in README.md.

Developing

Ensure you have cargo-component installed:

cargo install cargo-component

Just Commands

You can bundle, build, and run preview all with a single just command from the justfile:

just preview

Manual Build:

Build the demo crate with

cargo component build --package demo --release

This will generate the wasm bytes at target/wasm32-wasi/release/demo.wasm.

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run build

# start the server and open the app in a new browser tab
npm run preview

Note that due to the way Vite handles dynamic wasm, we cannot (yet?) use npm run dev to start the server.

Publish

Up rev the version in package.json and then run:

# up revs the version in package-lock.json
npm install

# builds the dist folder
npm run package

# publishes to npm
npm publish