babel-plugin-minify-type-constructors

Example

In

  1. Boolean(x);
  2. Number(x);
  3. String(x);
  4. Array(3);
  5. Array(3,1);
  6. Object({foo: 'bar'});

Out

  1. !!x;
  2. +x;
  3. x + "";
  4. [,,,];
  5. [3, 1];
  6. {foo: 'bar'};

Installation

  1. npm install babel-plugin-minify-type-constructors --save-dev

Usage

.babelrc

  1. {
  2. "plugins": ["minify-type-constructors"]
  3. }

Via CLI

  1. babel --plugins minify-type-constructors script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["minify-type-constructors"]
  3. });

Options

  • array - prevent plugin from minifying arrays
  • boolean - prevent plugin from minifying booleans
  • number — prevent plugin from minifying numbers
  • object — prevent plugin from minifying objects
  • string — prevent plugin from minifying strings

You can read more about configuring plugin options here