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

vite-plugin-wat2wasm

v2.0.0

Published

A simple Vite plugin that enables `.wat` (WebAssembly Text Format) compilation and allows usage of WebAssembly within your codebase/library

Downloads

739

Readme

vite-plugin-wat2wasm

A simple Vite plugin that enables .wat (WebAssembly Text Format) compilation and allows usage of WebAssembly within your codebase/library.

Installation

$ <your-preferred-package-manager> install -D vite-plugin-wat2wasm

Usage

Adding into your Vite configuration

import { defineConfig } from "vite";
import wat2WasmPlugin from "vite-plugin-wat2wasm";

export default defineConfig({
    plugins: [
        wat2WasmPlugin({ /* Refer to the API docs below for options */ }),
        /* ...other plugins */
    ],

    // ... other configuration settings
});

Adding types for import statements

Reference it as a comment...

/// <reference types="vite-plugin-wat2wasm/types" />

or include it in your tsconfig.json file

{
    "include": ["src"],
    "compilerOptions": {
        "types": ["vite-plugin-wat2wasm/types", /* ... other type files/packages */]
        // ... other options for Typescript
    }
}

Using it in your application/library

import initFoo from "./foo.wat"

const bar = new WebAssembly.Global("i32", { value: 13 });
const foo = await initFoo<FooExports, FooImports>({
    bar: { val: bar },

    console: {
        log(a: number) {
            console.log(a);
        }
    }
});

console.log(foo.add(21, 46)); // returns 67
foo.logBar(); // logs 13

// In Typescript, you can also specify the types of your .wat file module.
interface FooExports {
    add(a: number, b: number): number;
    logBar(): void;
}

interface FooImports {
    bar: { val: WebAssembly.Global<"i32">; };
    console: { log(a: number): void; };
}

Reference

This section contains more in-depth details about the vite-plugin-wat2wasm library and how to make use of what vite-plugin-wat2wasm offers.

wat2WasmPlugin

Enables compilation of .wat files and generation of .wasm, with modifiable settings.

wat2WasmPlugin(options: Wat2WasmOptions):Plugin

Parameters

  • options: Wat2WasmOptions = {} - the configuration options for vite-plugin-wat2wasm.

Returns

  • Plugin - a Vite plugin object that allows for compilation of .wat files.

Wat2WasmOptions

The configuration settings for vite-plugin-wat2wasm.

Properties

  • parser?: WasmParserOptions = {} - Configures .wasm features you wish to enable for vite-plugin-wat2wasm.

  • generator?: WasmGeneratorOptions = {} - Configures how vite-plugin-wat2wasm to generate .wasm files.

WasmParserOptions

See wabt.WasmFeatures for more info.

WasmGeneratorOptions

See wabt.ToBinaryOptions for more info.