From 45295180de8b3fec3f4321eb01c4bde1b02ea534 Mon Sep 17 00:00:00 2001 From: Geordi Dearns Date: Mon, 5 Dec 2016 18:44:31 +0100 Subject: [PATCH] Update babel.github.io babili plugin docs (#1029) --- docs/plugins/minify-constant-folding.md | 9 ++++ docs/plugins/minify-dead-code-elimination.md | 9 ++++ docs/plugins/minify-empty-function.md | 9 ++++ docs/plugins/minify-flip-comparisons.md | 9 ++++ docs/plugins/minify-guarded-expressions.md | 9 ++++ docs/plugins/minify-infinity.md | 9 ++++ docs/plugins/minify-mangle-names.md | 9 ++++ docs/plugins/minify-numeric-literals.md | 9 ++++ docs/plugins/minify-replace.md | 9 ++++ docs/plugins/minify-simplify.md | 9 ++++ docs/plugins/minify-type-constructors.md | 9 ++++ .../transform-inline-consecutive-adds.md | 9 ++++ .../transform-inline-environment-variables.md | 50 +------------------ .../transform-member-expression-literals.md | 34 +------------ .../transform-merge-sibling-variables.md | 36 +------------ docs/plugins/transform-minify-booleans.md | 2 +- docs/plugins/transform-node-env-inline.md | 41 +-------------- docs/plugins/transform-property-literals.md | 38 +------------- docs/plugins/transform-regexp-constructors.md | 9 ++++ docs/plugins/transform-remove-console.md | 34 +------------ docs/plugins/transform-remove-debugger.md | 33 +----------- ...transform-simplify-comparison-operators.md | 37 ++------------ docs/plugins/transform-undefined-to-void.md | 36 +------------ 23 files changed, 137 insertions(+), 321 deletions(-) create mode 100644 docs/plugins/minify-constant-folding.md create mode 100644 docs/plugins/minify-dead-code-elimination.md create mode 100644 docs/plugins/minify-empty-function.md create mode 100644 docs/plugins/minify-flip-comparisons.md create mode 100644 docs/plugins/minify-guarded-expressions.md create mode 100644 docs/plugins/minify-infinity.md create mode 100644 docs/plugins/minify-mangle-names.md create mode 100644 docs/plugins/minify-numeric-literals.md create mode 100644 docs/plugins/minify-replace.md create mode 100644 docs/plugins/minify-simplify.md create mode 100644 docs/plugins/minify-type-constructors.md create mode 100644 docs/plugins/transform-inline-consecutive-adds.md create mode 100644 docs/plugins/transform-regexp-constructors.md diff --git a/docs/plugins/minify-constant-folding.md b/docs/plugins/minify-constant-folding.md new file mode 100644 index 0000000000..4134fcc67b --- /dev/null +++ b/docs/plugins/minify-constant-folding.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify constant folding +description: Tries to evaluate expressions and inline the result. For now only deals with numbers and strings +permalink: /docs/plugins/minify-constant-folding/ +package: babel-plugin-minify-constant-folding +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-dead-code-elimination.md b/docs/plugins/minify-dead-code-elimination.md new file mode 100644 index 0000000000..8c20ebc550 --- /dev/null +++ b/docs/plugins/minify-dead-code-elimination.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify dead code elimination +description: Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result +permalink: /docs/plugins/minify-dead-code-elimination/ +package: babel-plugin-minify-dead-code-elimination +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-empty-function.md b/docs/plugins/minify-empty-function.md new file mode 100644 index 0000000000..0208d4f9c9 --- /dev/null +++ b/docs/plugins/minify-empty-function.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify empty function +description: This is mostly a Facebook-specific transform that removes noop function calls. However, can be generalized to detect and remove noops +permalink: /docs/plugins/minify-empty-function/ +package: babel-plugin-minify-empty-function +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-flip-comparisons.md b/docs/plugins/minify-flip-comparisons.md new file mode 100644 index 0000000000..681015c480 --- /dev/null +++ b/docs/plugins/minify-flip-comparisons.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify flip comparisons +description: While this plugin doesn’t shorten the output in any way, it does optimize it for repetition-based compression algorithms such as gzip +permalink: /docs/plugins/minify-flip-comparisons/ +package: babel-plugin-minify-flip-comparisons +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-guarded-expressions.md b/docs/plugins/minify-guarded-expressions.md new file mode 100644 index 0000000000..032723040c --- /dev/null +++ b/docs/plugins/minify-guarded-expressions.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify guarded expressions +description: +permalink: /docs/plugins/minify-guarded-expressions/ +package: babel-plugin-minify-guarded-expressions +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-infinity.md b/docs/plugins/minify-infinity.md new file mode 100644 index 0000000000..a091ea0853 --- /dev/null +++ b/docs/plugins/minify-infinity.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify infinity +description: +permalink: /docs/plugins/minify-infinity/ +package: babel-plugin-minify-infinity +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-mangle-names.md b/docs/plugins/minify-mangle-names.md new file mode 100644 index 0000000000..670fd4e07b --- /dev/null +++ b/docs/plugins/minify-mangle-names.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify mangle names +description: Context - and scope - aware variable renaming +permalink: /docs/plugins/minify-mangle-names/ +package: babel-plugin-minify-mangle-names +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-numeric-literals.md b/docs/plugins/minify-numeric-literals.md new file mode 100644 index 0000000000..daec17c88f --- /dev/null +++ b/docs/plugins/minify-numeric-literals.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify numeric literals +description: Shortening of numeric literals via scientific notation +permalink: /docs/plugins/minify-numeric-literals/ +package: babel-plugin-minify-numeric-literals +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-replace.md b/docs/plugins/minify-replace.md new file mode 100644 index 0000000000..48fa759f75 --- /dev/null +++ b/docs/plugins/minify-replace.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify replace +description: Configurable "search and replace" plugin. Replaces matching nodes in the tree with a given replacement node +permalink: /docs/plugins/minify-replace/ +package: babel-plugin-minify-replace +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-simplify.md b/docs/plugins/minify-simplify.md new file mode 100644 index 0000000000..f0a63fbdbf --- /dev/null +++ b/docs/plugins/minify-simplify.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify simplify +description: This plugin will transform code in mainly two ways - 1) Reduce as much statements as possible into expressions, and 2) Make expressions as uniform as possible for better compressibility +permalink: /docs/plugins/minify-simplify/ +package: babel-plugin-minify-simplify +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/minify-type-constructors.md b/docs/plugins/minify-type-constructors.md new file mode 100644 index 0000000000..053d9fba04 --- /dev/null +++ b/docs/plugins/minify-type-constructors.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Minify type constructors +description: Not recommended if full support for IE8 and lower is required +permalink: /docs/plugins/minify-type-constructors/ +package: babel-plugin-minify-type-constructors +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/transform-inline-consecutive-adds.md b/docs/plugins/transform-inline-consecutive-adds.md new file mode 100644 index 0000000000..8cbd570f25 --- /dev/null +++ b/docs/plugins/transform-inline-consecutive-adds.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Inline consecutive adds transform +description: This plugin inlines consecutive property assignments, array pushes, etc +permalink: /docs/plugins/transform-inline-consecutive-adds/ +package: babel-plugin-transform-inline-consecutive-adds +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/transform-inline-environment-variables.md b/docs/plugins/transform-inline-environment-variables.md index e13687b36e..3ccee63a80 100644 --- a/docs/plugins/transform-inline-environment-variables.md +++ b/docs/plugins/transform-inline-environment-variables.md @@ -1,55 +1,9 @@ --- layout: docs title: Inline environment variables transform -description: +description: Inline environment variables permalink: /docs/plugins/transform-inline-environment-variables/ package: babel-plugin-transform-inline-environment-variables --- -This plugin allows Babel to transform inlines environment variables. - -## Example - -For example compiling the following file: - -**script.js** - -```javascript -if (process.env.NODE_ENV === "development") { - development(); -} else { - production(); -} -``` - -with the command: - -```sh -$ NODE_ENV=development babel --plugins transform-inline-environment-variables script.js -``` - -outputs: - -```javascript -if ("development" === "development") { - development(); -} else { - production(); -} -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-inline-environment-variables -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-inline-environment-variables"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-member-expression-literals.md b/docs/plugins/transform-member-expression-literals.md index d66a7292a1..9a829ef0d9 100644 --- a/docs/plugins/transform-member-expression-literals.md +++ b/docs/plugins/transform-member-expression-literals.md @@ -1,39 +1,9 @@ --- layout: docs title: Member expression literals transform -description: +description: Turn valid member expression property literals into plain identifiers permalink: /docs/plugins/transform-member-expression-literals/ package: babel-plugin-transform-member-expression-literals --- -This plugin allows Babel to transform member expression valid identifier literal properties into identifiers. - -## Example - -**In** - -```javascript -foo["bar"]; -``` - -**Out** - -```javascript -foo.bar; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-member-expression-literals -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-member-expression-literals"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-merge-sibling-variables.md b/docs/plugins/transform-merge-sibling-variables.md index d0efd92f4c..a85e21f582 100644 --- a/docs/plugins/transform-merge-sibling-variables.md +++ b/docs/plugins/transform-merge-sibling-variables.md @@ -1,41 +1,9 @@ --- layout: docs title: Merge sibling variables transform -description: +description: Merge sibling variables into one permalink: /docs/plugins/transform-merge-sibling-variables/ package: babel-plugin-transform-merge-sibling-variables --- -This plugin allows Babel to merge sibling variable declarations. - -## Example - -**In** - -```javascript -var foo = "bar"; -var bar = "foo"; -``` - -**Out** - -```javascript -var foo = "bar", - bar = "foo"; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-merge-sibling-variables -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-merge-sibling-variables"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-minify-booleans.md b/docs/plugins/transform-minify-booleans.md index 5198b6fc66..ed082a6a30 100644 --- a/docs/plugins/transform-minify-booleans.md +++ b/docs/plugins/transform-minify-booleans.md @@ -1,7 +1,7 @@ --- layout: docs title: Minify booleans transform -description: +description: This plugin allows Babel to transform boolean literals into !0 for true and !1 for false permalink: /docs/plugins/transform-minify-booleans/ package: babel-plugin-transform-minify-booleans --- diff --git a/docs/plugins/transform-node-env-inline.md b/docs/plugins/transform-node-env-inline.md index fcb1ca0c26..6748165dc7 100644 --- a/docs/plugins/transform-node-env-inline.md +++ b/docs/plugins/transform-node-env-inline.md @@ -1,46 +1,9 @@ --- layout: docs title: NODE_ENV inline transform -description: +description: Inline the NODE_ENV environment variable and if it's a part of a binary expression permalink: /docs/plugins/transform-node-env-inline/ package: babel-plugin-transform-node-env-inline --- -Inline the `NODE_ENV` environment variable and if it's a part of a binary expression -(eg. `process.env.NODE_ENV === "development"`) then statically evaluate and replace it. - -## Example - -**In** - -```javascript -process.env.NODE_ENV === "development"; -process.env.NODE_ENV === "production"; -``` - -**Out** - -```sh -$ NODE_ENV=development babel in.js --plugins transform-node-env-inline -``` - -```javascript -true; -false; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-node-env-inline -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-node-env-inline"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-property-literals.md b/docs/plugins/transform-property-literals.md index 3cd14007b2..1f6bfa7baf 100644 --- a/docs/plugins/transform-property-literals.md +++ b/docs/plugins/transform-property-literals.md @@ -1,43 +1,9 @@ --- layout: docs title: Property literals transform -description: +description: This plugin allows Babel to transform valid identifier property key literals into identifiers permalink: /docs/plugins/transform-property-literals/ package: babel-plugin-transform-property-literals --- -This plugin allows Babel to transform valid identifier property key literals into identifiers. - -## Example - -**In** - -```javascript -var foo = { - "bar": function () {} -}; -``` - -**Out** - -```javascript -var foo = { - bar: function () {} -}; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-property-literals -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-property-literals"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-regexp-constructors.md b/docs/plugins/transform-regexp-constructors.md new file mode 100644 index 0000000000..48fbb0cb83 --- /dev/null +++ b/docs/plugins/transform-regexp-constructors.md @@ -0,0 +1,9 @@ +--- +layout: docs +title: Regexp constructors transform +description: This changes RegExp constructors into literals if the RegExp arguments are strings +permalink: /docs/plugins/transform-regexp-constructors/ +package: babel-plugin-transform-regexp-constructors +--- + +{% include package_readme.html from="babili" %} \ No newline at end of file diff --git a/docs/plugins/transform-remove-console.md b/docs/plugins/transform-remove-console.md index f3906fcd54..653e7911ee 100644 --- a/docs/plugins/transform-remove-console.md +++ b/docs/plugins/transform-remove-console.md @@ -1,39 +1,9 @@ --- layout: docs title: Remove console transform -description: +description: This plugin removes all console.* calls permalink: /docs/plugins/transform-remove-console/ package: babel-plugin-transform-remove-console --- -This plugin removes all `console.*` calls. - -## Example - -**In** - -```javascript -console.log("foo"); -console.error("bar"); -``` - -**Out** - -```javascript -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-remove-console -``` - -## Usage - -Add the following line to your `.babelrc`: - -```json -{ - "plugins": ["transform-remove-console"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-remove-debugger.md b/docs/plugins/transform-remove-debugger.md index b52884e884..2e5113fbe0 100644 --- a/docs/plugins/transform-remove-debugger.md +++ b/docs/plugins/transform-remove-debugger.md @@ -1,38 +1,9 @@ --- layout: docs title: Remove debugger transform -description: +description: This plugin removes all debugger; statements permalink: /docs/plugins/transform-remove-debugger/ package: babel-plugin-transform-remove-debugger --- -This plugin removes all `debugger;` statements. - -## Example - -**In** - -```javascript -debugger; -``` - -**Out** - -```javascript -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-remove-debugger -``` - -## Usage - -Add the following line to your `.babelrc`: - -```json -{ - "plugins": ["transform-remove-debugger"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-simplify-comparison-operators.md b/docs/plugins/transform-simplify-comparison-operators.md index 471048b53c..4d172d2a4b 100644 --- a/docs/plugins/transform-simplify-comparison-operators.md +++ b/docs/plugins/transform-simplify-comparison-operators.md @@ -1,40 +1,9 @@ --- layout: docs -title: Simplfy comparison operator transform -description: +title: Simplify comparison operator transform +description: Convert === and !== to == and != if their types are inferred to be the same permalink: /docs/plugins/transform-simplify-comparison-operators/ package: babel-plugin-transform-simplify-comparison-operators --- -This plugin simplifies comparisons from strict `===` to `==` when each side is inferred -to always be the same type. - -## Example - -**In** - -```javascript -"foo" === "bar"; -``` - -**Out** - -```javascript -"foo" == "bar"; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-simplify-comparison-operators -``` - -## Usage - -Add the following line to your `.babelrc` file: - -```json -{ - "plugins": ["transform-simplify-comparison-operators"] -} -``` +{% include package_readme.html from="babili" %} diff --git a/docs/plugins/transform-undefined-to-void.md b/docs/plugins/transform-undefined-to-void.md index f8dfd76541..f9b2159473 100644 --- a/docs/plugins/transform-undefined-to-void.md +++ b/docs/plugins/transform-undefined-to-void.md @@ -1,41 +1,9 @@ --- layout: docs title: Undefined to void transform -description: +description: This plugin transforms undefined into void 0 which returns undefined regardless of if it's been reassigned permalink: /docs/plugins/transform-undefined-to-void/ package: babel-plugin-transform-undefined-to-void --- -Some JavaScript implementations allow undefined to be overwritten, this may lead to peculiar bugs that are extremely hard to track down. - -This plugin transforms `undefined` into `void 0` which returns undefined regardless of if it's been reassigned. - -## Example - -**In** - -```javascript -foo === undefined; -``` - -**Out** - -```javascript -foo === void 0; -``` - -## Installation - -```sh -$ npm install --save-dev babel-plugin-transform-undefined-to-void -``` - -## Usage - -Add the following line to your `.babelrc`: - -```json -{ - "plugins": ["transform-undefined-to-void"] -} -``` +{% include package_readme.html from="babili" %}