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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bundler-in-browser

v0.3.0

Published

a bundler in browser, auto install npm packages, powered by esbuild-wasm

Downloads

17

Readme

bundler-in-browser

npm version github example

A powerful in-browser bundler that automatically installs npm packages, powered by esbuild-wasm. Perfect for building interactive code playgrounds, live demos, and browser-based development environments.

Features

  • 🚀 Fast Bundling: Powered by esbuild-wasm for high-performance bundling
  • 📦 Auto NPM Install: Automatically installs and bundles npm dependencies
  • 🔌 Plugin System: Support for TailwindCSS, Sass, Vue 3 SFC, and more
  • 🗄️ Vendor Caching: Smart caching of vendor bundles for better performance
  • 🌐 Browser-Native: Runs entirely in the browser - no server required

Installation

npm install bundler-in-browser esbuild-wasm

# Optional but recommended for virtual filesystem support
npm install @zenfs/core path-browserify

Then, configure your project, alias path to path-browserify:

  • Vite: open vite.config.ts, add "path": "path-browserify" into resolve.alias
  • Webpack: open webpack.config.js, add "path": "path-browserify" into resolve.alias
  • Rollup: refer to @rollup/plugin-alias

Quick Start

Here's a simple example that bundles and runs code with a third-party package:

import { BundlerInBrowser, wrapCommonJS } from "bundler-in-browser";
import { fs } from "@zenfs/core";

// Create a virtual filesystem with your source code
fs.mkdirSync("/src");
fs.writeFileSync(
  "/src/index.js",
  `
    import confetti from "canvas-confetti";

    confetti();
    setInterval(() => { confetti() }, 3000);

    const elt = document.createElement('h1');
    elt.textContent = 'BundlerInBrowser! ' + FOO;
    elt.style.cssText = 'text-align: center; font-size: 32px; margin-top: 30vh;';
    document.body.appendChild(elt);
  `
);

// Initialize the bundler
const bundler = new BundlerInBrowser(fs);
await bundler.initialize();

// Build your code
bundler.config.entrypoint = "/src/index.js";
bundler.config.define.FOO = '"awesome!"'; // Define global constants

// if failed, may throw Error with { errors }
const buildResult = await bundler.build();

// it returns { js, css } and the `js` is a CommonJS module
// Execute the js (use `wrapCommonJS()` to convert CommonJS into IIFE function)
const run = new Function("return " + wrapCommonJS(buildResult.js));
const userExports = run();

console.log("user code exports:", userExports);

// Apply any generated CSS
if (buildResult.css) {
  const style = document.createElement("style");
  style.textContent = buildResult.css;
  document.head.appendChild(style);
}

Plugins

TailwindCSS Support

See tailwindcss plugin for more details.

Sass Support

Add support for .scss and .sass files:

import { BundlerInBrowser, installSassPlugin } from "bundler-in-browser";

const bundler = new BundlerInBrowser(fs);
await bundler.initialize();

// Install Sass support
await installSassPlugin(bundler);

// Now you can compile files with .scss/.sass extensions

Vue 3 Support

Add support for Vue 3 Single File Components (.vue files). More details can be found here.

import { BundlerInBrowser, installVuePlugin } from "bundler-in-browser";

const bundler = new BundlerInBrowser(fs);
await bundler.initialize();

// Install Vue support with options
await installVuePlugin(bundler, {
  disableOptionsApi: false, // Set true to reduce vendor bundle size
  enableProdDevTools: false, // Set true if production build needs devtools
});

// Now you can compile .vue files

Cookbook

📘 Use External Libraries

↑ click title to see more details.

bundler-in-browser allows user to import from npm, or your pre-defined modules.

  • add pre-defined modules (use bundler.config.externals)
  • configure npm, blocklist, custom registry
  • vendor bundle (dll cache)

📘 Under the Hood

↑ click title to learn how bundler.build() works.

📘 Vue

↑ click title to learn how to use Vue SFC, including options, HMR etc.