Awesome
@putout/minify
🐊Putout-based JavaScript minifier.
Install
npm i @putout/minify
Supported minifier transforms
Here is list of supported 🐊Putout transformations:
- ✅
apply-template-literals
; - ✅
apply-optional-chaining
; - ✅
conditions
; - ✅
convert-to-arrow-function
; - ✅
convert-arguments-to-rest
; - ✅
declare
; - ✅
for-of
; - ✅
logical-expressions
; - ✅
merge-duplicate-functions
; - ✅
merge-duplicate-imports
; - ✅
merge-destructuring-properties
; - ✅
minify
; - ✅
new
; - ✅
regexp
; - ✅
reuse-duplicate-init
; - ✅
remove-empty
; - ✅
remove-nested-blocks
; - ✅
remove-unused-variables
; - ✅
remove-unused-expressions
; - ✅
remove-unreferenced-variables
; - ✅
remove-useless-arguments
; - ✅
remove-useless-else
; - ✅
remove-useless-return
; - ✅
remove-useless-spread
; - ✅
remove-useless-variables
; - ✅
remove-console
; - ✅
remove-debugger
; - ✅
remove-unreachable-code
; - ✅
simplify-ternary
; - ✅
types
;
API
import {minify} from '@putout/minify';
minify(`
const a = 5;
const b = 6;
fn(a, b);
`);
// returns
var a=5,b=6;fn(a,b);
Options
You can also pass options to minify
. Here is list of default options:
({
quotes: `'`,
fixCount: 1, // the more fixCount - less output size
conditions: false,
mangleClassNames: true,
mangle: true,
mergeVariables: true,
removeUnusedVariables: false,
removeConsole: false,
removeUselessSpread: true,
applyTemplateLiterals: true,
convertStrictEqualToEqual: false,
});
And usage example:
import {minify} from '@putout/minify';
const source = `
const a = 5;
const b = 6;
`;
minify(source, {
removeUnusedVariables: false,
});
How it's compared to X(your benchmark)?
License
MIT