Registry / devops / butternut

butternut

JSON →
library0.4.6jsnpmunverified

Butternut is an experimental ES2015-aware JavaScript minifier that uses a novel approach: instead of manipulating an AST, it edits code in place using magic-string, resulting in significantly faster minification. It is typically 3x faster than UglifyJS and 10-15x faster than Babili. However, it is alpha software (v0.4.6) and should be thoroughly tested before production use. It supports the check option to parse output for correctness. Note: the package is deprecated; users are advised to migrate to modern minifiers like terser or uglify-es.

npm install butternut
INSTALL
IMPORT
SIG · BUTTERNUT
B
butternut
devopsjavascriptv0.4.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

butternut
import butternut from 'butternut'
const butternut = require('butternut')
Package is CJS-only, but ESM import works in bundlers.
squash
import { squash } from 'butternut'
const { squash } = require('butternut')
Named export works in both CJS and ESM.
default
import butternut from 'butternut'
const butternut = require('butternut').default
No .default needed; package exports squash directly as default.

Minify a simple JavaScript string using butternut.squash with the check option enabled.

const butternut = require('butternut'); const { code, map } = butternut.squash('const x = 1;', { check: true }); console.log(code); // 'const x=1'
Debug
Known issues
breakingPackage is deprecated and no longer maintained. Do not use in new projects.
fix
Migrate to terser (npm install terser) or uglify-es.
affects: >=0.0.1
deprecatedbutternut is alpha software and may produce incorrect output.
fix
Always use the check option to validate output, or switch to a stable minifier.
affects: >=0.0.1
gotchaThe CLI command 'squash' clashes with other tools; ensure global install is isolated.
fix
Use npx butternut or local installation.
affects: >=0.0.1
gotchaDefault export is the squash function, not a namespace.
fix
Use default import or require; no named imports except squash.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'butternut'
Package not installed or misspelled.
fix
npm install butternut --save-dev
butternut.squash is not a function
Incorrect import: using barrel import instead of default.
fix
Use require('butternut') or import butternut from 'butternut'.
Cannot read property 'code' of undefined
squash returned nothing due to invalid options or empty input.
fix
Ensure input is a string and options object is correct; check for errors.
Upgrade
Version history
0.4.6latest on npm
Audit
Dependencies
acornrequiredUsed to generate AST for minification
magic-stringrequiredUsed for in-place code editing
Agent activity
4 hits · last 30 days
node
4
Resources
butternut — npm install butternut · libregistry