Microbundle

0.15.1 · active · verified Sun Apr 19

Microbundle is a zero-configuration bundler for small JavaScript libraries, currently at version 0.15.1. Powered by Rollup, it simplifies the build process by automatically generating optimized bundles in multiple formats: CommonJS (CJS), ECMAScript Modules (ESM), Universal Module Definition (UMD), and a 'modern' ESM bundle for contemporary browsers. It supports ESnext features, async/await, multiple entry points, TypeScript out-of-the-box, built-in Terser compression, and gzipped bundle size tracking. While not adhering to a strict release cadence, it receives frequent updates, often in the form of patch releases, indicating active maintenance. Key differentiators include its minimal setup (often just `package.json` configuration) and focus on producing tiny, performant outputs with modern browser targets by default.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a typical `package.json` setup for Microbundle, defining input/output paths for CJS, ESM, UMD, and modern bundles, along with example source code. Shows how to integrate Microbundle into `npm` scripts for building and watching files.

{
  "name": "my-tiny-lib",
  "version": "1.0.0",
  "type": "module",
  "source": "src/index.js",
  "exports": {
    "require": "./dist/index.cjs",
    "default": "./dist/index.modern.js"
  },
  "main": "./dist/index.cjs",
  "module": "./dist/index.module.js",
  "unpkg": "./dist/index.umd.js",
  "scripts": {
    "build": "microbundle",
    "dev": "microbundle watch"
  },
  "devDependencies": {
    "microbundle": "^0.15.0"
  }
}

// src/index.js
export const greet = (name) => `Hello, ${name}!`;
export default function sum(a, b) {
  return a + b;
}

// To run: 
// 1. npm install
// 2. npm run build
// This will generate dist/index.cjs, dist/index.modern.js, dist/index.module.js, dist/index.umd.js

view raw JSON →