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

emsdk-env

v0.10.0

Published

Emscripten environment builder

Readme

emsdk-env

A Vite plugin that automatically builds WASM C/C++ source code using the Emscripten SDK.

emsdk-env

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. License: MIT


What is this?

This is a Vite plugin that automatically downloads and manages the Emscripten SDK, and makes it possible to automatically build WASM C/C++ code in your project. With this plugin, you can easily set up a WASM C/C++ development environment in your Vite project.

Usage is simple. Just add this Vite plugin package to your project and initialize the plugin in vite.config like this:

// `vite.config.ts`
import { defineConfig } from 'vite';

// Refer to the emsdk-env Vite plugin
import emsdkEnv from 'emsdk-env/vite';

export default defineConfig({
  plugins: [
    // Add as a plugin
    emsdkEnv({
      // Generate a runtime loader code
      generatedLoader: { enable: true },
      // Build targets
      targets: {
        // Generate "add.wasm"
        add: {
          // Compiler options
          options: ['-O3', '-std=c99'],
          // Linker options
          linkOptions: ['--no-entry'],
          // Linker directives
          linkDirectives: { STANDALONE_WASM: 1 },
          // Exported symbols
          exports: ['_add'],
        },
      },
    }),
  ],
});

If the source code changes, it will automatically rebuild and reload the page. You can focus on writing C/C++ code just like you would TypeScript/JavaScript code!

Features

  • Automatic setup and caching of the Emscripten SDK
  • HMR support via Vite plugin (Note: C/C++ code requires a full build)
  • Support for parallel builds
  • Simplified specification of export symbols
  • Ability to generate multiple target WASM binaries
  • Customizable directory paths, compile options, and linker options
  • Archive libraries (*.a) can be built and referenced
  • WASM libraries can be distributed and referenced via NPM packages

Usage

Installation

Add to devDependencies (emsdk-env itself does not require runtime code):

$ npm install -D emsdk-env
  • emsdk-env automatically downloads and caches the Emscripten SDK (located under ~/.cache/emsdk-env/). Therefore, you do not need to manually set up the Emscripten SDK.

C/C++ Source Code and Binary Placement

By default, C/C++ source code is placed in the wasm/ directory under your project, and the built WASM binaries are placed in the src/wasm/ directory.

A typical directory structure looks like this:

project/
├── package.json
├── vite.config.ts
├── src/
│   ├── generated/
│   │   └── wasm-loader.ts   // (Generate automatically)
│   └── wasm/
│       └── add.wasm         // (Built WASM binary)
└── wasm/
    └── add.c
  • wasm-loader.ts is helper code that loads and makes WASM binaries usable.
  • In addition to the above, a temporary build directory is created under the OS temp directory. The default location is ${TMPDIR}/emsdk-env (typically /tmp/emsdk-env on Unix). This directory is used during the build process and is typically deleted after the build completes. If you override buildDir to point inside the project, add it to .gitignore.

Of course, you can change these. Specify them in the Vite plugin options.

You might find it odd that the built binary is placed in src/wasm/, but this is because the Vite server defaults to a path where it can easily access WASM binaries.

If generatedLoader.enable is set to true, emsdk-env also generates a WASM loader helper code by default at src/generated/wasm-loader.ts. That loader can call the final WASM exports directly:

import { loadAddWasm } from './generated/wasm-loader';

// WASM exported function declaration (You need to define it)
interface AddExports {
  add?: (a: number, b: number) => number;
}

// Load WASM binary and instantiates it
const wasm = await loadAddWasm<AddExports>();

// Get `add()` function entry point
const add = wasm.exports.add;
if (typeof add !== 'function') {
  throw new Error('add function not found in wasm exports.');
}

// Then use it now
const result = add(1, 2);
  • You need to define WASM export functions yourself. When doing so, the symbol name for the exported function is the same as the C/C++ function name in TypeScript, but the symbol name specified in exports: [...] typically requires an underscore prefix (add() --> _add).

If you plan to operate with the default settings, there is essentially no configuration work required.

Other topics include features such as explicitly specifying source files, applying multiple compile options separately, handling multiple target outputs, generating and referencing archive library files, and compilation and referencing NPM packages.

Documents

For more information, please visit repository and refer README: emsdk-env


License

Under MIT.