pkgroll: Zero-Config Rollup Bundler

2.27.0 · active · verified Sun Apr 19

pkgroll is a robust JavaScript package bundler built on Rollup, designed for zero-configuration builds by leveraging existing `package.json` fields like `main`, `module`, `types`, and `exports`. It streamlines the process of transforming TypeScript/ESM source code into various output formats, including ESM, CommonJS, and TypeScript declaration files (`.d.ts`). Currently stable at version 2.27.0, pkgroll maintains a frequent release cadence, with multiple bug fixes and minor feature additions observed monthly. Its key differentiators include automatic dependency externalization, built-in minification, comprehensive TypeScript support with `.d.ts` bundling, watch mode for development, and intelligent CLI output features such as hashbang insertion for executables. It simplifies package publishing by reducing the need for extensive build configurations.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to configure `package.json` for `pkgroll` to define entry points and output formats, then run the build.

{
    "name": "my-package",
    "version": "1.0.0",
    "type": "module",
    "main": "./dist/index.cjs",
    "module": "./dist/index.mjs",
    "types": "./dist/index.d.ts",
    "exports": {
        ".": {
            "require": {
                "types": "./dist/index.d.cts",
                "default": "./dist/index.cjs"
            },
            "import": {
                "types": "./dist/index.d.mts",
                "default": "./dist/index.mjs"
            }
        },
        "./foo": {
            "import": "./dist/foo.mjs",
            "require": "./dist/foo.cjs"
        }
    },
    "scripts": {
        "build": "pkgroll"
    },
    "devDependencies": {
        "pkgroll": "^2.0.0",
        "typescript": "^5.0.0"
    }
}
// To run the build:
npm install
npm run build

view raw JSON →