Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BundlerInBrowser
✓ import { BundlerInBrowser } from 'bundler-in-browser'
✗ const BundlerInBrowser = require('bundler-in-browser')
ESM-only package; require will fail in Node. Use import.
wrapCommonJS
✓ import { wrapCommonJS } from 'bundler-in-browser'
✗ import wrapCommonJS from 'bundler-in-browser'
wrapCommonJS is a named export, not default. ESM-only.
installSassPlugin
✓ import { installSassPlugin } from 'bundler-in-browser'
Named export for optional Sass support. Requires 'sass' package installed.
installVuePlugin
✓ import { installVuePlugin } from 'bundler-in-browser'
Named export for Vue 3 SFC support. Requires 'vue' package installed.
Shows initialization, virtual filesystem setup, bundling, and executing CommonJS output with CSS injection.
import { BundlerInBrowser, wrapCommonJS } from 'bundler-in-browser';
import { fs } from '@zenfs/core';
fs.mkdirSync('/src');
fs.writeFileSync(
'/src/index.js',
`
import confetti from "canvas-confetti";
confetti();
const elt = document.createElement('h1');
elt.textContent = 'BundlerInBrowser!';
document.body.appendChild(elt);
`
);
const bundler = new BundlerInBrowser(fs);
await bundler.initialize();
bundler.config.entrypoint = '/src/index.js';
const buildResult = await bundler.build();
const run = new Function('return ' + wrapCommonJS(buildResult.js));
const userExports = run();
if (buildResult.css) {
const style = document.createElement('style');
style.textContent = buildResult.css;
document.head.appendChild(style);
}
Errors
Common errors & fixes
Error: Cannot find module 'path'
Browser environment lacks Node.js 'path' module
fixAdd resolve alias: 'path': 'path-browserify' in your bundler config (Vite/Webpack/Rollup).
TypeError: bundler.initialize is not a function
Incorrect import; likely default import instead of named
fixUse import { BundlerInBrowser } from 'bundler-in-browser' (named export). Error: esbuild-wasm not found
Missing esbuild-wasm peer dependency
fixRun npm install esbuild-wasm.
ReferenceError: wrapCommonJS is not defined
wrapCommonJS is a named export, not default
fixUse import { wrapCommonJS } from 'bundler-in-browser'. Audit
Dependencies
@zenfs/corerequiredvirtual filesystem required for source code and node_modules
esbuild-wasmrequiredcore bundling engine
sassoptionaloptional Sass plugin dependency
vueoptionaloptional Vue SFC plugin dependency
path-browserifyoptionalpolyfill for Node.js path module (needed in browser)