๐Putout-based JavaScript minifier.
npm i @putout/minify
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
;
import {minify} from '@putout/minify';
minify(`
const a = 5;
const b = 6;
fn(a, b);
`);
// returns
var a=5,b=6;fn(a,b);
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,
});
MIT