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.
npm install pkgrollNo compatibility data collected yet for this library.
This quickstart demonstrates how to configure `package.json` for `pkgroll` to define entry points and output formats, then run the build.
Install a compatible TypeScript version: `npm install --save-dev typescript@"^5.0"` or `npm install --save-dev typescript@"^4.1"` as required by your pkgroll version.
Place source files corresponding to `dist` outputs in a `src` directory (e.g., `src/index.ts` for `dist/index.cjs`), or use `pkgroll --srcdist 'my-src:my-dist'` to define custom mappings.
Always specify a file extension in wildcard export patterns: `"./utils/*": "./dist/utils/*.mjs"`.
Consult Node.js documentation on `package.json#exports` and ensure all required conditions (`import`, `require`, `types`) are correctly specified for each entry point to support all target environments.
Install TypeScript: `npm install --save-dev typescript` or `pnpm add -D typescript`.
Modify the `exports` entry to include a file extension, for example: `"./utils/*": "./dist/utils/*.mjs"`.
Update Node.js to a version that fully supports `package.json#exports` (Node.js 14.13+ for most features, 16+ for full stable support). Review `package.json` for syntax errors.