Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    babel-plugin-minify-simplifypublic

    babel-plugin-minify-simplify

    Simplifies code for minification by reducing statements into expressions and making expressions uniform where possible.

    Example

    Reduce statement into expression

    In

    function foo() {
      if (x) a();
    }
    function foo2() {
      if (x) a();
      else b();
    }

    Out

    function foo() {
      x && a();
    }
    function foo2() {
      x ? a() : b();
    }

    Make expression as uniform as possible for better compressibility

    In

    undefined
    foo['bar']
    Number(foo)

    Out

    void 0
    foo.bar
    +foo

    Installation

    npm install babel-plugin-minify-simplify

    Usage

    Via .babelrc (Recommended)

    .babelrc

    {
      "plugins": ["minify-simplify"]
    }

    Via CLI

    babel --plugins minify-simplify script.js

    Via Node API

    require("@babel/core").transform("code", {
      plugins: ["minify-simplify"]
    });

    Keywords

    install

    npm i babel-plugin-minify-simplify

    Downloadsweekly downloads

    309,221

    version

    0.4.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar