pakit
raw JSON → 2.3.0 verified Sat Apr 25 auth: no javascript
pakit is an opinionated JavaScript bundler (v2.3.0) that provides out-of-the-box linting, transpilation, minification, and sourcemaps with minimal configuration. It supports CommonJS and ES2015 modules, bundle splitting via shards, file watching, caching, and configuration through .pakit.json, .pakit.js, or .pakit directory. Integrates with eslint, babel, and uglify, respecting their rc files for non-invasiveness. Differentiated by its strong defaults and modular configuration approach. Release cadence is sporadic; latest stable is v2.3.0.
Common errors
error Error: Cannot find module 'eslint' ↓
cause eslint is not installed when using pakit, but required for linting.
fix
Install eslint as a dev dependency: npm install eslint --save-dev
error Error: Could not find configuration file .pakit.json, .pakit.js, or .pakit directory ↓
cause pakit cannot find any configuration file in the project root.
fix
Create a .pakit.json file or use the programmatic API with explicit options.
error TypeError: pakit is not a function ↓
cause Misimporting pakit (e.g., using named import instead of default).
fix
Use import pakit from 'pakit' or const pakit = require('pakit').
error Unexpected token: keyword «import» ↓
cause pakit requires babel to transpile ES6 modules if using .babelrc; if not configured, babel may not be active.
fix
Ensure babel-core is installed and .babelrc is present, or use CommonJS require syntax.
Warnings
deprecated .bundlerrc configuration files are deprecated. Please rename to .pakit file. ↓
fix Rename .bundlerrc to .pakit.json, .pakit.js, or .pakit directory.
breaking In v0.6.0, bundlerrc support was removed without warning. Recovery release v0.6.2 added deprecation warning. ↓
fix Upgrade to v0.6.2 or later. Rename .bundlerrc to .pakit.
gotcha ESLint config detection uses glob for .eslintrc files; ensure your config file is named correctly (e.g., .eslintrc.json). ↓
fix Use a supported .eslintrc file (json, js, yaml) in project root.
gotcha Bundle splitting shard matchers are internally converted to regular expressions. Escape special characters if matching literal strings. ↓
fix Use proper regex escaping in shard match patterns.
Install
npm install pakit yarn add pakit pnpm add pakit Imports
- pakit wrong
const pakit = require('pakit')correctimport pakit from 'pakit' - pakit wrong
import { pakit } from 'pakit'correctconst pakit = require('pakit') - Bundle wrong
import Bundle from 'pakit'correctimport { Bundle } from 'pakit'
Quickstart
import pakit from 'pakit';
import path from 'path';
pakit({
entries: ['./src/index.js'],
out: path.resolve('dist/bundle.js'),
watch: false,
minify: true,
sourcemap: true,
shards: {
'dist/vendor.js': ['/node_modules/']
}
}).then(result => {
console.log('Build succeeded:', result);
}).catch(err => {
console.error('Build failed:', err);
});