JSPM

  • Created
  • Published
  • Downloads 107
  • Score
    100M100P100Q85167F
  • License MIT

🐊Putout plugin contains minifiers

Package Exports

  • @putout/plugin-minify
  • @putout/plugin-minify/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/plugin-minify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/plugin-minify NPM version

🐊Putout plugin adds support of minifiers used in @putout/minify and minify.

Install

npm i @putout/plugin-putout -D

Rules

{
    "rules": {
        "minify/convert-if-to-logical": "on",
        "minify/extract-body": "on",
        "minify/remove-return-undefined": "on",
        "minify/mangle-names": "on",
        "minify/types": "on"
    }
}

convert-if-to-logical

Check out in 🐊Putout Editor.

❌ Example of incorrect code

if (a)
    console.log('hello');

if (b) {
    console.log('hello');
    console.log('world');
}

βœ… Example of correct code

a && console.log('hello');

b && (console.log('hello'), console.log('world'));

extract-body

Check out in 🐊Putout Editor.

❌ Example of incorrect code

if (x) {
    return;
}

const hello = () => {
    return 'world';
};

βœ… Example of correct code

if (x)
    return;

const hello = () => 'world';

remove-return-undefined

❌ Example of incorrect code

const fn = () => {
    if (a)
        return undefined;
    
    return undefined;
};

βœ… Example of correct code

const fn = () => {
    if (a)
        return;
};

mangle-names

Check out in 🐊Putout Editor.

❌ Example of incorrect code

function generate() {
    const hello = 'hi';
    return hello;
}

βœ… Example of correct code

function generate() {
    const a = 'hi';
    return a;
}

types

Check out in 🐊Putout Editor.

❌ Example of incorrect code

const a = undefined;
const b = true;
const c = false;

βœ… Example of correct code

const a = void 0;
const b = !0;
const c = !1;

License

MIT