mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-21 07:15:09 +00:00
| .. | ||
| lib | ||
| .npmignore | ||
| package.json | ||
| README.md | ||
babel-preset-babili
Babel preset for all minify plugins.
Install
npm install --save-dev babel-preset-babili
Usage
Via .babelrc (Recommended)
.babelrc
{
"presets": ["babili"]
}
or pass in options -
{
"presets": [["babili", {
"mangle": {
"blacklist": ["MyCustomError"]
},
"unsafe": {
"typeConstructors": false
},
"keepFnName": true
}]]
}
Via CLI
babel script.js --presets babili
Via Node API
require("babel-core").transform("code", {
presets: ["babili"]
});
Options
All options are enabled by default except the ones with an explicit mention - (Default: false)
Three types of options:
1-1 mapping with plugin
falseto disable the plugintrueto enable the plugin with default plugin specific options{ ...pluginOpts }to enable the plugin with custom plugin options
The following options have 1-1 mapping with a plugin,
evaluate- babel-plugin-minify-constant-foldingdeadcode- babel-plugin-minify-dead-code-eliminationinfinity- babel-plugin-minify-infinitymangle- babel-plugin-minify-mangle-namesnumericLiterals- babel-plugin-minify-numeric-literalsreplace- babel-plugin-minify-replacesimplify- babel-plugin-minify-simplifymergeVars- babel-plugin-transform-merge-sibling-variablesbooleans- babel-plugin-transform-minify-booleansregexpConstructors- babel-plugin-transform-regexp-constructorsremoveConsole-(Default: false)- babel-plugin-transform-remove-consoleremoveDebugger-(Default: false)- babel-plugin-transform-remove-debuggerremoveUndefined- babel-plugin-transform-remove-undefinedundefinedToVoid- babel-plugin-transform-undefined-to-void
Examples
{
"presets": [["babili", {
"evaluate": false,
"mangle": true
}]]
}
{
"presets": [["babili", {
"mangle": {
"blacklist": {
"ParserError": true,
"NetworkError": false
}
}
}]]
}
Option groups
falseto disable the entire grouptrueto enable every plugin in the group{ pluginKey: <1-1 mapping> }- enable/disable a particular plugin in a group (or) pass options to that plugin
The following are groups of plugins -
unsafeflipComparisons- babel-plugin-minify-flip-comparisonssimplifyComparisons- babel-plugin-transform-simplify-comparison-operatorsguards- babel-plugin-minify-guarded-expressionstypeConstructors- babel-plugin-minify-type-constructors
propertiesmemberExpressions- babel-plugin-transform-member-expression-literalspropertyLiterals- babel-plugin-transform-property-literals
Examples
Disables all unsafe plugins:
{
"presets": [["babili", {
"unsafe": false
}]]
}
Disables only minify-guarded-expressions, and enable all other unsafe plugins:
{
"presets": [["babili", {
"unsafe": {
"guards": false
}
}]]
}
Passing same plugin options to multiple plugins
In babili, multiple plugins require the same set of options and it is easier to mention it in one place instead of two.
keepFnName- This will be passed tomangleanddeadcodeand will NOT be overriden if the same option exists under either mangle or deadcode.
Examples
{
"presets": [["babili", {
"keepFnName": true
}]]
}
is the same as,
Plugins applied:
{
"presets": [["babili", {
"mangle": {
"keepFnName": true
},
"deadcode": {
"keepFnName": true
}
}]]
}