pkg-bundler
raw JSON → 1.0.0-1 verified Fri May 01 auth: no javascript maintenance
pkg-bundler is a zero-configuration Rollup bundler for npm packages, pre-configured with Babel, that automatically generates CommonJS and ES module bundles from a single entry point. Version 1.0.0-1 is the current stable release, with no active development observed. It differentiates from similar tools like microbundle or rollup-starter by enforcing a specific project structure (`.babelrc`, `main`/`module` fields) and providing a single CLI command with no configuration files required. However, its dependency on `rollup` and `babel` is opaque, and there is no support for TypeScript or modern bundling needs. Release cadence is low; the package is largely untended.
Common errors
error Error: Could not find any entry point. Check the path. ↓
cause CLI argument points to non-existent file or directory.
fix
Provide the correct path to your source entry file, e.g., pkg-bundler src/index.js
error Error: Missing .babelrc or babel configuration. ↓
cause No babel config found; pkg-bundler expects a .babelrc file.
fix
Create a .babelrc file with presets like [['env', {modules: false}], 'react'].
error Error: 'main' field missing in package.json. ↓
cause pkg-bundler checks for main and module fields in package.json to determine output paths.
fix
Add \"main\": \"dist/index.cjs.js\" and optionally \"module\": \"dist/index.es.js\" to package.json.
Warnings
deprecated Package is effectively unmaintained; no updates since 2018. ↓
fix Consider migrating to a maintained bundler like microbundle or rollup with manual config.
gotcha Requires specific file structure: .babelrc, main/module fields in package.json, and entry file must exist. ↓
fix Ensure all required fields and files are present before running.
gotcha Babel preset 'env' must have { modules: false } to allow Rollup tree-shaking. ↓
fix Set { modules: false } in the preset configuration.
gotcha CLI only accepts exactly one entry file; no glob support. ↓
fix Use a single entry point. For multiple entries, consider a different tool.
Install
npm install pkg-bundler yarn add pkg-bundler pnpm add pkg-bundler Imports
- pkg-bundler wrong
No programmatic API; cannot be required or imported in code.correctInstall as dev dependency and use via CLI: `pkg-bundler src/index.js`
Quickstart
npm i -D pkg-bundler
# .babelrc
cat > .babelrc << 'EOF'
{
"presets": [
["env", { "modules": false }],
"react"
]
}
EOF
# package.json (add fields)
cat package.json | jq '. + {"main": "dist/index.cjs.js", "module": "dist/index.es.js", "scripts": {"prepare": "pkg-bundler src/index.js"}}' > package.json
# src/index.js
mkdir -p src
echo 'export default function hello() { return "Hello World"; }' > src/index.js
npm run prepare