babel-plugin-minify-type-constructors
Example
In
JavaScript
Boolean(x);
Number(x);
String(x);
Array(3);
Array(3,1);
Object({foo: 'bar'});
Out
JavaScript
!!x;
+x;
x + "";
[,,,];
[3, 1];
{foo: 'bar'};
Installation
- npm
- Yarn
- pnpm
npm install babel-plugin-minify-type-constructors --save-dev
yarn add babel-plugin-minify-type-constructors --dev
pnpm add babel-plugin-minify-type-constructors --save-dev
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["minify-type-constructors"]
}
Via CLI
Shell
babel --plugins minify-type-constructors script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["minify-type-constructors"]
});
Options
array
- prevent plugin from minifying arraysboolean
- prevent plugin from minifying booleansnumber
— prevent plugin from minifying numbersobject
— prevent plugin from minifying objectsstring
— prevent plugin from minifying strings
提示
You can read more about configuring plugin options here