diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1fd756194..ac5127e6a 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,7 +5,7 @@ Search open/closed issues before submitting since someone might have asked the s If you have a support request or question please submit them to the #minify channel on babeljs slack: https://babeljs.slack.com/messages/minify -Also have a look at the Debugging guidelines: https://github.com/babel/babili/blob/master/CONTRIBUTING.md#debugging +Also have a look at the Debugging guidelines: https://github.com/babel/minify/blob/master/CONTRIBUTING.md#debugging Things required: @@ -13,7 +13,7 @@ For a bug: 1. Minimal code to reproduce the bug 2. Stack Trace if there is an Error thrown during minification -3. Configuration - babili configuration or babelrc +3. Configuration - babel-minify configuration or babelrc 4. Whether you used it with other presets/plugins - like es2015 or env 5. Environment: gulp, rollup, webpack, babel-cli, etc...? diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01cb08f45..b9f045fa0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,8 +2,8 @@ ### Setup ```sh -$ git clone https://github.com/babel/babili -$ cd babili +$ git clone https://github.com/babel/minify +$ cd minify $ npm install $ npm run bootstrap ``` @@ -71,7 +71,7 @@ npm test To run tests for a specific package, ```sh -npm test packages/babel-preset-babili +npm test packages/babel-preset-minify ``` #### Smoke Tests @@ -119,19 +119,19 @@ node smoke/run.js -ib lodash #### Benchmarks -[benchmark.js](https://github.com/babel/babili/blob/master/scripts/benchmark.js) compares Babili with [Uglify](https://github.com/mishoo/UglifyJS2), [Closure Compiler](https://github.com/google/closure-compiler) and [Closure Compiler JS](https://github.com/google/closure-compiler-js) +[benchmark.js](https://github.com/babel/minify/blob/master/scripts/benchmark.js) compares BabelMinify with [Uglify](https://github.com/mishoo/UglifyJS2), [Closure Compiler](https://github.com/google/closure-compiler) and [Closure Compiler JS](https://github.com/google/closure-compiler-js) ```sh ./scripts/benchmark.js [file...] ``` -[plugin-timing.js](https://github.com/babel/babili/blob/master/scripts/plugin-timing.js) is used to calculate and compare the time spent in each plugin. +[plugin-timing.js](https://github.com/babel/minify/blob/master/scripts/plugin-timing.js) is used to calculate and compare the time spent in each plugin. ```sh ./scripts/plugin-timing.js file.js ``` -[plugin-contribution.js](https://github.com/babel/babili/blob/master/scripts/plugin-contribution.js) calculates how much each plugin of babili contributes to size reduction. +[plugin-contribution.js](https://github.com/babel/minify/blob/master/scripts/plugin-contribution.js) calculates how much each plugin of babel-minify contributes to size reduction. ```sh ./scripts/plugin-contribution.js file.js @@ -139,7 +139,7 @@ node smoke/run.js -ib lodash ### Debugging -In your project, if you find that there is a bug that appears ONLY when you use Babili, it's most likely that there is a bug in Babili and you should definitely report it. Here are some guidelines that might help you drill down the issue. If it doesn't help you, you can of course create a minimal repro project with the bug and report it. +In your project, if you find that there is a bug that appears ONLY when you use BabelMinify, it's most likely that there is a bug in BabelMinify and you should definitely report it. Here are some guidelines that might help you drill down the issue. If it doesn't help you, you can of course create a minimal repro project with the bug and report it. #### Compile time Errors @@ -156,13 +156,13 @@ If the syntax error occurs at runtime, it likely means the code generator ([bab When you run your minified code in the browser, 1. If there is an error in the console, as a first step, look around the code block where the error happens, and the code block of a few steps up in the stack. -2. Try to predict what caused the error and try relating it to some of the plugin names in the [packages/](https://github.com/babel/babili/tree/master/packages) directory. The major ones (that do a lot of transformations) are - mangle, deadcode-elimination and simplify. -3. Every plugin that Babili uses has an option in preset to toggle it on/off - [preset-options](https://github.com/babel/babili/tree/master/packages/babel-preset-babili#options) +2. Try to predict what caused the error and try relating it to some of the plugin names in the [packages/](https://github.com/babel/minify/tree/master/packages) directory. The major ones (that do a lot of transformations) are - mangle, deadcode-elimination and simplify. +3. Every plugin that Babel-Minify uses has an option in preset to toggle it on/off - [preset-options](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#options) 4. Disable any transformation(s) that you suspect are causing problems. Turning OFF mangling (`mangle: false`) is a good practice if you don't think it's related to a mangling bug, since unmangled variable names will make debugging easier. 5. Sometimes it might NOT be a bug with one plugin but a combination of plugins. Again, `deadcode-elimination` and `simplify` maybe good candidates to start with here as they perform many transformations. -6. Sometimes it might because of the [unsafe transformations](https://github.com/babel/babili/tree/master/packages/babel-preset-babili#option-groups). Some of them are grouped into a single option named `unsafe`. This option can help you identify it sooner if the bug is in one these plugins. +6. Sometimes it might because of the [unsafe transformations](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#option-groups). Some of them are grouped into a single option named `unsafe`. This option can help you identify it sooner if the bug is in one these plugins. 7. Produce a minimal repro of the same issue - the function block containing the bug should be enough to help reproduce the bug. -8. [Report it 🙂](https://github.com/babel/babili/issues/new) +8. [Report it 🙂](https://github.com/babel/minify/issues/new) 9. You're awesome. Thanks! ### Releasing diff --git a/README.md b/README.md index 705c13d8c..58685d307 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,28 @@ -

babili (babel-minify)

+

babel-minify

An ES6+ aware minifier based on the Babel toolchain.

- NPM Version - Travis Status - CircleCI Status - Code Coverage + NPM Version + Travis Status + CircleCI Status + Code Coverage Slack Status - NPM Downloads + NPM Downloads

- Checkout our [CONTRIBUTING.md](/CONTRIBUTING.md) if you want to help out! -- Babili is consumable via API, CLI, or Babel preset. +- Babel-Minify is consumable via API, CLI, or Babel preset. - Try it online - [babeljs.io/repl](http://babeljs.io/repl/#?babili=true&evaluate=false&lineWrap=false&presets=react%2Cstage-2&code=%2F%2F%20Example%20ES2015%20Code%0Aclass%20Mangler%20%7B%0A%20%20constructor(program)%20%7B%0A%20%20%20%20this.program%20%3D%20program%3B%0A%20%20%7D%0A%7D%0Anew%20Mangler()%3B%20%2F%2F%20without%20this%20it%20would%20just%20output%20nothing%20since%20Mangler%20isn%27t%20used) +## Note + +Babili has been now renamed to Babel-Minify :). + ## Table of Contents - [Requirements](#requirements) @@ -37,7 +41,7 @@ ## Why Current tools don't support targeting the latest version of ECMAScript. (yet) -- Babili can because it is just a set of Babel plugins, and Babel already understands new syntax with our parser [Babylon](https://github.com/babel/babylon). +- BabelMinify can because it is just a set of Babel plugins, and Babel already understands new syntax with our parser [Babylon](https://github.com/babel/babylon). - When it's possible to only target browsers that support newer ES features, code sizes can be smaller because you don't have to transpile and then minify. Check out our [blog post](http://babeljs.io/blog/2016/08/30/babili) for more info! @@ -54,14 +58,14 @@ new Mangler(); // without this it would just output nothing since Mangler isn't Before ```js -// ES2015+ code -> Babel -> Babili/Uglify -> Minified ES5 Code +// ES2015+ code -> Babel -> BabelMinify/Uglify -> Minified ES5 Code var a=function a(b){_classCallCheck(this,a),this.program=b};new a; ``` After ```js -// ES2015+ code -> Babili -> Minified ES2015+ Code +// ES2015+ code -> BabelMinify -> Minified ES2015+ Code class a{constructor(b){this.program=b}}new a; ``` @@ -69,40 +73,32 @@ class a{constructor(b){this.program=b}}new a; | Package | Version | Dependencies | |--------|-------|------------| -| [`babili`](/packages/babili) | [![npm](https://img.shields.io/npm/v/babili.svg?maxAge=86400)](https://www.npmjs.com/package/babili) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babili)](https://david-dm.org/babel/babili?path=packages/babili) | +| [`babel-minify`](/packages/babel-minify) | [![npm](https://img.shields.io/npm/v/babel-minify.svg?maxAge=86400)](https://www.npmjs.com/package/babel-minify) | [![Dependency Status](https://david-dm.org/babel/babel-minify.svg?path=packages/babel-minify)](https://david-dm.org/babel/babel-minify?path=packages/babel-minify) | This is simple wrapper around the regular `babel-cli` and thus takes in the same [cli options](http://babeljs.io/docs/usage/cli/#options) as running babel on its own. You can use this if you don't already use babel or want to run it standalone. ### Install ```sh -npm install babili --save-dev +npm install babel-minify --save-dev ``` ### Usage ```sh -babili src -d lib +minify src -d lib ``` -Equivalent to: - -```sh -babel src -d lib --presets=babili --no-babelrc -``` - -Note that, because the `babili` command uses the default preset with `no-babelrc`, you cannot set any non-default options in the preset's plugins with this command. To do this, you can use the `babel` command with the options set in a `.babelrc`. See the preset docs for more information on how to do this. - ## [Babel preset](http://babeljs.io/docs/plugins/#presets) | Package | Version | Dependencies | |--------|-------|------------| -| [`babel-preset-babili`](/packages/babel-preset-babili) | [![npm](https://img.shields.io/npm/v/babel-preset-babili.svg?maxAge=86400)](https://www.npmjs.com/package/babel-preset-babili) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-preset-babili)](https://david-dm.org/babel/babili?path=packages/babel-preset-babili) | +| [`babel-preset-minify`](/packages/babel-preset-minify) | [![npm](https://img.shields.io/npm/v/babel-preset-minify.svg?maxAge=86400)](https://www.npmjs.com/package/babel-preset-minify) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-preset-minify)](https://david-dm.org/babel/minify?path=packages/babel-preset-minify) | ### Install ```sh -npm install babel-preset-babili --save-dev +npm install babel-preset-minify --save-dev ``` ### Usage @@ -118,7 +114,7 @@ You'll most likely want to use it only in the production environment. Check out "presets": ["es2015"], "env": { "production": { - "presets": ["babili"] + "presets": ["minify"] } } } @@ -128,27 +124,27 @@ Then you'll need to set the env variable which could be something like `BABEL_EN ## Individual Plugins -The `babili` repo is comprised of many npm packages. It is a [lerna](https://github.com/lerna/lerna) monorepo similar to [babel](https://github.com/babel/babel) itself. +The `minify` repo is comprised of many npm packages. It is a [lerna](https://github.com/lerna/lerna) monorepo similar to [babel](https://github.com/babel/babel) itself. -The npm package `babel-preset-babili` is at the path `packages/babel-preset-babili` +The npm package `babel-preset-minify` is at the path `packages/babel-preset-minify` | Package | Version | Dependencies | |--------|-------|------------| -| [`babel-plugin-minify-constant-folding`](/packages/babel-plugin-minify-constant-folding) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-constant-folding.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-constant-folding) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-constant-folding)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-constant-folding) | -| [`babel-plugin-minify-dead-code-elimination`](/packages/babel-plugin-minify-dead-code-elimination) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-dead-code-elimination.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-dead-code-elimination) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-dead-code-elimination)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-dead-code-elimination) | -| [`babel-plugin-minify-flip-comparisons`](/packages/babel-plugin-minify-flip-comparisons) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-flip-comparisons.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-flip-comparisons) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-flip-comparisons)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-flip-comparisons) | -| [`babel-plugin-minify-guarded-expressions`](/packages/babel-plugin-minify-guarded-expressions) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-guarded-expressions.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-guarded-expressions) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-guarded-expressions)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-guarded-expressions) | -| [`babel-plugin-minify-infinity`](/packages/babel-plugin-minify-infinity) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-infinity.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-infinity) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-infinity)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-infinity) | -| [`babel-plugin-minify-mangle-names`](/packages/babel-plugin-minify-mangle-names) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-mangle-names.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-mangle-names) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-mangle-names)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-mangle-names) | -| [`babel-plugin-minify-replace`](/packages/babel-plugin-minify-replace) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-replace.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-replace) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-replace)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-replace) | -| [`babel-plugin-minify-simplify`](/packages/babel-plugin-minify-simplify) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-simplify.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-simplify) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-simplify)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-simplify) | -| [`babel-plugin-minify-type-constructors`](/packages/babel-plugin-minify-type-constructors) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-type-constructors.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-type-constructors) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-minify-type-constructors)](https://david-dm.org/babel/babili?path=packages/babel-plugin-minify-type-constructors) | -| [`babel-plugin-transform-member-expression-literals`](/packages/babel-plugin-transform-member-expression-literals) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-member-expression-literals.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-member-expression-literals) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-member-expression-literals)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-member-expression-literals) | -| [`babel-plugin-transform-merge-sibling-variables`](/packages/babel-plugin-transform-merge-sibling-variables) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-merge-sibling-variables.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-merge-sibling-variables) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-merge-sibling-variables)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-merge-sibling-variables) | -| [`babel-plugin-transform-minify-booleans`](/packages/babel-plugin-transform-minify-booleans) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-minify-booleans.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-minify-booleans) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-minify-booleans)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-minify-booleans) | -| [`babel-plugin-transform-property-literals`](/packages/babel-plugin-transform-property-literals) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-property-literals.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-property-literals) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-property-literals)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-property-literals) | -| [`babel-plugin-transform-simplify-comparison-operators`](/packages/babel-plugin-transform-simplify-comparison-operators) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-simplify-comparison-operators.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-simplify-comparison-operators) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-simplify-comparison-operators)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-simplify-comparison-operators) | -| [`babel-plugin-transform-undefined-to-void`](/packages/babel-plugin-transform-undefined-to-void) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-undefined-to-void.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-undefined-to-void) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-undefined-to-void)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-undefined-to-void) | +| [`babel-plugin-minify-constant-folding`](/packages/babel-plugin-minify-constant-folding) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-constant-folding.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-constant-folding) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-constant-folding)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-constant-folding) | +| [`babel-plugin-minify-dead-code-elimination`](/packages/babel-plugin-minify-dead-code-elimination) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-dead-code-elimination.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-dead-code-elimination) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-dead-code-elimination)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-dead-code-elimination) | +| [`babel-plugin-minify-flip-comparisons`](/packages/babel-plugin-minify-flip-comparisons) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-flip-comparisons.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-flip-comparisons) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-flip-comparisons)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-flip-comparisons) | +| [`babel-plugin-minify-guarded-expressions`](/packages/babel-plugin-minify-guarded-expressions) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-guarded-expressions.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-guarded-expressions) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-guarded-expressions)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-guarded-expressions) | +| [`babel-plugin-minify-infinity`](/packages/babel-plugin-minify-infinity) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-infinity.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-infinity) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-infinity)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-infinity) | +| [`babel-plugin-minify-mangle-names`](/packages/babel-plugin-minify-mangle-names) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-mangle-names.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-mangle-names) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-mangle-names)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-mangle-names) | +| [`babel-plugin-minify-replace`](/packages/babel-plugin-minify-replace) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-replace.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-replace) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-replace)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-replace) | +| [`babel-plugin-minify-simplify`](/packages/babel-plugin-minify-simplify) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-simplify.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-simplify) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-simplify)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-simplify) | +| [`babel-plugin-minify-type-constructors`](/packages/babel-plugin-minify-type-constructors) | [![npm](https://img.shields.io/npm/v/babel-plugin-minify-type-constructors.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-minify-type-constructors) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-minify-type-constructors)](https://david-dm.org/babel/minify?path=packages/babel-plugin-minify-type-constructors) | +| [`babel-plugin-transform-member-expression-literals`](/packages/babel-plugin-transform-member-expression-literals) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-member-expression-literals.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-member-expression-literals) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-member-expression-literals)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-member-expression-literals) | +| [`babel-plugin-transform-merge-sibling-variables`](/packages/babel-plugin-transform-merge-sibling-variables) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-merge-sibling-variables.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-merge-sibling-variables) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-merge-sibling-variables)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-merge-sibling-variables) | +| [`babel-plugin-transform-minify-booleans`](/packages/babel-plugin-transform-minify-booleans) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-minify-booleans.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-minify-booleans) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-minify-booleans)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-minify-booleans) | +| [`babel-plugin-transform-property-literals`](/packages/babel-plugin-transform-property-literals) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-property-literals.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-property-literals) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-property-literals)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-property-literals) | +| [`babel-plugin-transform-simplify-comparison-operators`](/packages/babel-plugin-transform-simplify-comparison-operators) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-simplify-comparison-operators.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-simplify-comparison-operators) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-simplify-comparison-operators)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-simplify-comparison-operators) | +| [`babel-plugin-transform-undefined-to-void`](/packages/babel-plugin-transform-undefined-to-void) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-undefined-to-void.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-undefined-to-void) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-undefined-to-void)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-undefined-to-void) | ### Usage @@ -166,10 +162,10 @@ Add to your `.babelrc`'s plugins array. | Package | Version | Dependencies | |--------|-------|------------| -| [`babel-plugin-transform-inline-environment-variables`](/packages/babel-plugin-transform-inline-environment-variables) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-inline-environment-variables.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-inline-environment-variables) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-inline-environment-variables)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-inline-environment-variables) | -| [`babel-plugin-transform-node-env-inline`](/packages/babel-plugin-transform-node-env-inline) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-node-env-inline.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-node-env-inline) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-node-env-inline)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-node-env-inline) | -| [`babel-plugin-transform-remove-console`](/packages/babel-plugin-transform-remove-console) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-remove-console.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-remove-console) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-remove-console)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-remove-console) | -| [`babel-plugin-transform-remove-debugger`](/packages/babel-plugin-transform-remove-debugger) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-remove-debugger.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-remove-debugger) | [![Dependency Status](https://david-dm.org/babel/babili.svg?path=packages/babel-plugin-transform-remove-debugger)](https://david-dm.org/babel/babili?path=packages/babel-plugin-transform-remove-debugger) | +| [`babel-plugin-transform-inline-environment-variables`](/packages/babel-plugin-transform-inline-environment-variables) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-inline-environment-variables.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-inline-environment-variables) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-inline-environment-variables)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-inline-environment-variables) | +| [`babel-plugin-transform-node-env-inline`](/packages/babel-plugin-transform-node-env-inline) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-node-env-inline.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-node-env-inline) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-node-env-inline)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-node-env-inline) | +| [`babel-plugin-transform-remove-console`](/packages/babel-plugin-transform-remove-console) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-remove-console.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-remove-console) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-remove-console)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-remove-console) | +| [`babel-plugin-transform-remove-debugger`](/packages/babel-plugin-transform-remove-debugger) | [![npm](https://img.shields.io/npm/v/babel-plugin-transform-remove-debugger.svg?maxAge=86400)](https://www.npmjs.com/package/babel-plugin-transform-remove-debugger) | [![Dependency Status](https://david-dm.org/babel/minify.svg?path=packages/babel-plugin-transform-remove-debugger)](https://david-dm.org/babel/minify?path=packages/babel-plugin-transform-remove-debugger) | ## Benchmarks @@ -239,7 +235,7 @@ Input Size (gzip): 200.53kB ## Browser support -Babili is best at targeting latest browsers ([with full ES6+ support](https://kangax.github.io/compat-table/es6/)) but can also be used with the usual Babel es2015 preset to transpile down the code first. +Babel Minify is best at targeting latest browsers ([with full ES6+ support](https://kangax.github.io/compat-table/es6/)) but can also be used with the usual Babel es2015 preset to transpile down the code first. ## Team diff --git a/lerna.json b/lerna.json index 12f0b0612..21003ca1b 100644 --- a/lerna.json +++ b/lerna.json @@ -12,7 +12,7 @@ } }, "changelog": { - "repo": "babel/babili", + "repo": "babel/minify", "labels": { "Tag: Spec Compliancy": ":eyeglasses: Spec Compliancy", "Tag: Breaking Change": ":boom: Breaking Change", diff --git a/package.json b/package.json index 402d44f8c..36d1b3bb5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,4 @@ { - "private": true, "license": "MIT", "author": "amasad", "scripts": { @@ -12,8 +11,8 @@ "eslint": "eslint packages/*/src/ packages/*/__tests__/ utils/*.js scripts/*.js", "eslint-fix": "eslint --fix packages/*/src/ packages/*/__tests__/ utils/*.js scripts/*.js", "fix": "npm run format && npm run eslint-fix", - "format-check": "git ls-files | egrep '\\.js$' | xargs prettier -l --print-width 80", "format": "git ls-files | egrep '\\.js$' | xargs prettier --write --print-width 80", + "format-check": "git ls-files | egrep '\\.js$' | xargs prettier -l --print-width 80", "lint": "npm run format-check && npm run eslint", "publish": "git pull origin master --rebase && npm run build && npm test && lerna publish", "publish-internal": "git pull origin master --rebase && npm run build && NPM_DIST_TAG=internal ./node_modules/.bin/lerna publish --skip-git", @@ -22,20 +21,6 @@ "updated": "lerna updated", "watch": "gulp watch" }, - "jest": { - "transform": { - ".*": "/node_modules/babel-jest" - }, - "testEnvironment": "node", - "testPathIgnorePatterns": [ - "/node_modules/", - "/fixtures/" - ], - "roots": [ - "packages" - ], - "coverageDirectory": "./coverage/" - }, "devDependencies": { "babel-core": "^6.25.0", "babel-eslint": "^7.2.3", @@ -68,6 +53,21 @@ "through2": "^2.0.3", "uglify-js": "^3.0.27" }, + "private": true, + "jest": { + "transform": { + ".*": "/node_modules/babel-jest" + }, + "testEnvironment": "node", + "testPathIgnorePatterns": [ + "/node_modules/", + "/fixtures/" + ], + "roots": [ + "packages" + ], + "coverageDirectory": "./coverage/" + }, "workspaces": [ "packages/*" ] diff --git a/packages/babel-helper-evaluate-path/package.json b/packages/babel-helper-evaluate-path/package.json index 943c5a813..7e35c340a 100644 --- a/packages/babel-helper-evaluate-path/package.json +++ b/packages/babel-helper-evaluate-path/package.json @@ -2,16 +2,16 @@ "name": "babel-helper-evaluate-path", "version": "0.1.0", "description": "path.evaluate wrapped in a try catch", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-evaluate-path", - "bugs": "https://github.com/babel/babili/issues", - "author": "boopathi", - "license": "MIT", - "main": "lib/index.js", "keywords": [ - "babel-plugin", - "babili" + "babel-minify", + "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "boopathi", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-evaluate-path", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-helper-evaluate-path/src/index.js b/packages/babel-helper-evaluate-path/src/index.js index debf58588..b8ae48c4e 100644 --- a/packages/babel-helper-evaluate-path/src/index.js +++ b/packages/babel-helper-evaluate-path/src/index.js @@ -44,7 +44,7 @@ module.exports = function evaluate(path) { // Original Source: // https://github.com/babel/babel/blob/master/packages/babel-traverse/src/path/evaluation.js -// modified for Babili use +// modified for Babel-minify use function evaluateIdentifier(path) { if (!path.isReferencedIdentifier()) { throw new Error(`Expected ReferencedIdentifier. Got ${path.type}`); diff --git a/packages/babel-helper-flip-expressions/package.json b/packages/babel-helper-flip-expressions/package.json index ddfffb2be..937a51656 100644 --- a/packages/babel-helper-flip-expressions/package.json +++ b/packages/babel-helper-flip-expressions/package.json @@ -2,13 +2,13 @@ "name": "babel-helper-flip-expressions", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-flip-expressions", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-flip-expressions" } diff --git a/packages/babel-helper-is-void-0/package.json b/packages/babel-helper-is-void-0/package.json index c719bf2bf..5e6eaf6c5 100644 --- a/packages/babel-helper-is-void-0/package.json +++ b/packages/babel-helper-is-void-0/package.json @@ -2,15 +2,15 @@ "name": "babel-helper-is-void-0", "version": "0.1.1", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-is-void-0", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-is-void-0", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-helper-mark-eval-scopes/package.json b/packages/babel-helper-mark-eval-scopes/package.json index 6f9e80fd4..fad8cf5de 100644 --- a/packages/babel-helper-mark-eval-scopes/package.json +++ b/packages/babel-helper-mark-eval-scopes/package.json @@ -2,16 +2,16 @@ "name": "babel-helper-mark-eval-scopes", "version": "0.1.1", "description": "Mark scopes for deopt which contain a direct eval call", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-mark-eval-scopes", - "bugs": "https://github.com/babel/babili/issues", - "author": "boopathi", - "license": "MIT", - "main": "lib/index.js", "keywords": [ - "babel-plugin", - "babili" + "babel-minify", + "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "boopathi", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-mark-eval-scopes", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-helper-remove-or-void/package.json b/packages/babel-helper-remove-or-void/package.json index 46a2135df..52f938b1a 100644 --- a/packages/babel-helper-remove-or-void/package.json +++ b/packages/babel-helper-remove-or-void/package.json @@ -2,15 +2,15 @@ "name": "babel-helper-remove-or-void", "version": "0.1.1", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-remove-or-void", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-remove-or-void", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-helper-to-multiple-sequence-expressions/package.json b/packages/babel-helper-to-multiple-sequence-expressions/package.json index a3391dc14..10a2e8b5a 100644 --- a/packages/babel-helper-to-multiple-sequence-expressions/package.json +++ b/packages/babel-helper-to-multiple-sequence-expressions/package.json @@ -2,15 +2,15 @@ "name": "babel-helper-to-multiple-sequence-expressions", "version": "0.1.1", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-helper-to-multiple-sequence-expressions", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-to-multiple-sequence-expressions", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-minify/README.md b/packages/babel-minify/README.md new file mode 100644 index 000000000..6f0d70392 --- /dev/null +++ b/packages/babel-minify/README.md @@ -0,0 +1,87 @@ +# babel-minify + +Node API and CLI + +[`babel-minify`](/packages/babel-minify) [![npm](https://img.shields.io/npm/v/babel-minify.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-minify) + +Use `babel-minify` if you don't already use babel (as a preset) or want to run it standalone. + +## Installation + +```sh +npm install babel-minify --save-dev +``` + +## Usage + +### Node API + +```js +const minify = require("babel-minify"); + +const {code, map} = minify("input code", { + mangle: { + keepClassName: true + } +}); +``` + +### CLI + +```sh +minify input.js --out-file input.min.js --mangle.keepClassName +``` + +## Node API + +```js +const minify = require("babel-minify"); + +minify(input, minifyOptions, overrides) +``` + +### minifyOptions + +Refer [babel-preset-minify options](../babel-preset-minify#options) + +### overrides + ++ `babel`: Custom babel ++ `minifyPreset`: Custom minify preset ++ `inputSourceMap`: Input Sourcemap ++ `sourceMaps`: [Boolean] + +## CLI Options + +``` +minify input.js [options] +``` + +### Simple preset options + +For simple options, use `--optionName` in CLI + +Refer [preset's 1-1 options](../babel-preset-minify#1-1-mapping-with-plugin) for the list of options + +Example: + +``` +minify input.js --mangle false +``` + +### Nested preset options + +Usage: `--optionName.featureName` + +Example: + +```sh +minify input.js --mangle.keepClassName --deadcode.keepFnArgs --outFile input.min.js +``` + +Refer the corresponding plugins to know the list of options it takes + +### IO options + ++ `--out-file path/to/file.min.js`: Output filename. Used only when reading from STDIN / a single input file ++ `--out-dir path/to/dir`: Output Directory. diff --git a/packages/babel-minify/__tests__/__snapshots__/cli-tests.js.snap b/packages/babel-minify/__tests__/__snapshots__/cli-tests.js.snap new file mode 100644 index 000000000..5eb1e2ce4 --- /dev/null +++ b/packages/babel-minify/__tests__/__snapshots__/cli-tests.js.snap @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`babel-minify CLI input dir + outdir 1`] = `"let foo=10;"`; + +exports[`babel-minify CLI input file + outDir 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; + +exports[`babel-minify CLI input file + outFile 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; + +exports[`babel-minify CLI input file + stdout 1`] = ` +Object { + "stderr": "", + "stdout": "function foo(){const a=x(1),b=y(2);return z(a,b)}", +} +`; + +exports[`babel-minify CLI should throw on all invalid options 1`] = ` +Object { + "code": 1, + "stderr": "Error: Invalid Options passed: foo,bar +", +} +`; + +exports[`babel-minify CLI stdin + outFile 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; + +exports[`babel-minify CLI stdin + stdout 1`] = ` +Object { + "stderr": "", + "stdout": "function a(){const a=x(1),b=y(2);return z(a,b)}", +} +`; diff --git a/packages/babel-minify/__tests__/__snapshots__/node-api-tests.js.snap b/packages/babel-minify/__tests__/__snapshots__/node-api-tests.js.snap new file mode 100644 index 000000000..d2538af39 --- /dev/null +++ b/packages/babel-minify/__tests__/__snapshots__/node-api-tests.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`babel-minify Node API override default minify options 1`] = `"function foo(){const bar=x(1),baz=y(2);return z(bar,baz)}"`; + +exports[`babel-minify Node API override nested minify options 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; + +exports[`babel-minify Node API simple usage 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; diff --git a/packages/babili/__tests__/cli-tests.js b/packages/babel-minify/__tests__/cli-tests.js similarity index 95% rename from packages/babili/__tests__/cli-tests.js rename to packages/babel-minify/__tests__/cli-tests.js index 31bdb48d9..db3f227d4 100644 --- a/packages/babili/__tests__/cli-tests.js +++ b/packages/babel-minify/__tests__/cli-tests.js @@ -5,7 +5,7 @@ const path = require("path"); const fs = require("fs"); const promisify = require("util.promisify"); const rimraf = require("rimraf"); -const babiliCli = require.resolve("../bin/babili"); +const minifyCli = require.resolve("../bin/minify"); const readFileAsync = promisify(fs.readFile); const readFile = file => readFileAsync(file).then(out => out.toString()); @@ -13,7 +13,7 @@ const unlink = promisify(rimraf); function runCli(args = [], stdin) { return new Promise((resolve, reject) => { - const child = spawn(babiliCli, args, { + const child = spawn(minifyCli, args, { stdio: [stdin ? "pipe" : "inherit", "pipe", "pipe"], shell: true }); @@ -50,7 +50,7 @@ const tempOutFile = path.join(__dirname, "fixtures/out-file/foo.min.js"); const tempOutDir = path.join(__dirname, "fixtures/out-dir/min"); const tempOutDirFile = path.join(__dirname, "fixtures/out-dir/min/foo.js"); -describe("Babili CLI", () => { +describe("babel-minify CLI", () => { afterEach(async () => { await unlink(tempOutDir); await unlink(tempOutFile); diff --git a/packages/babili/__tests__/fixtures/.eslintrc b/packages/babel-minify/__tests__/fixtures/.eslintrc similarity index 100% rename from packages/babili/__tests__/fixtures/.eslintrc rename to packages/babel-minify/__tests__/fixtures/.eslintrc diff --git a/packages/babili/__tests__/fixtures/out-dir/a/foo.js b/packages/babel-minify/__tests__/fixtures/out-dir/a/foo.js similarity index 100% rename from packages/babili/__tests__/fixtures/out-dir/a/foo.js rename to packages/babel-minify/__tests__/fixtures/out-dir/a/foo.js diff --git a/packages/babili/__tests__/fixtures/out-file/foo.js b/packages/babel-minify/__tests__/fixtures/out-file/foo.js similarity index 100% rename from packages/babili/__tests__/fixtures/out-file/foo.js rename to packages/babel-minify/__tests__/fixtures/out-file/foo.js diff --git a/packages/babel-minify/__tests__/node-api-tests.js b/packages/babel-minify/__tests__/node-api-tests.js new file mode 100644 index 000000000..ea4783418 --- /dev/null +++ b/packages/babel-minify/__tests__/node-api-tests.js @@ -0,0 +1,31 @@ +jest.autoMockOff(); + +const minify = require("../src/index"); + +const sampleInput = ` +function foo() { + const bar = x(1); + const baz = y(2); + return z(bar, baz); +} +`; + +describe("babel-minify Node API", () => { + it("simple usage", () => { + expect(minify(sampleInput).code).toMatchSnapshot(); + }); + + it("throw on invalid options", () => { + expect(() => minify(sampleInput, { foo: false, bar: true }).code).toThrow(); + }); + + it("override default minify options", () => { + const minifyOpts = { mangle: false }; + expect(minify(sampleInput, minifyOpts).code).toMatchSnapshot(); + }); + + it("override nested minify options", () => { + const minifyOpts = { mangle: { keepFnName: false } }; + expect(minify(sampleInput, minifyOpts).code).toMatchSnapshot(); + }); +}); diff --git a/packages/babili/bin/babili.js b/packages/babel-minify/bin/minify.js similarity index 100% rename from packages/babili/bin/babili.js rename to packages/babel-minify/bin/minify.js diff --git a/packages/babel-minify/package.json b/packages/babel-minify/package.json new file mode 100644 index 000000000..aefcb097a --- /dev/null +++ b/packages/babel-minify/package.json @@ -0,0 +1,28 @@ +{ + "name": "babel-minify", + "version": "0.1.4", + "description": "✂️ An ES6+ aware minifier based on the Babel toolchain (beta)", + "keywords": [ + "babel-minify", + "babel-preset", + "minify" + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "bin": { + "babel-minify": "./bin/minify.js", + "minify": "./bin/minify.js" + }, + "repository": "https://github.com/babel/minify/tree/master/packages/babel-minify", + "dependencies": { + "babel-core": "^6.24.1", + "babel-preset-minify": "^0.1.4", + "fs-readdir-recursive": "^1.0.0", + "mkdirp": "^0.5.1", + "util.promisify": "^1.0.0", + "yargs-parser": "^5.0.0" + } +} diff --git a/packages/babili/src/cli.js b/packages/babel-minify/src/cli.js similarity index 96% rename from packages/babili/src/cli.js rename to packages/babel-minify/src/cli.js index d12693835..8274d0dfa 100644 --- a/packages/babili/src/cli.js +++ b/packages/babel-minify/src/cli.js @@ -70,7 +70,7 @@ function aliasArr(obj) { function printHelpInfo({ exitCode = 0 } = {}) { const msg = ` - Usage: babili index.js [options] + Usage: minify index.js [options] Options: --out-file, -o Output to a specific file @@ -109,7 +109,7 @@ function printHelpInfo({ exitCode = 0 } = {}) { --pluginName.featureName. For example, - babili index.js --mangle.keepClassName --deadcode.keepFnArgs --outFile index.min.js + minify index.js --mangle.keepClassName --deadcode.keepFnArgs --outFile index.min.js `; log(msg, exitCode); } @@ -164,7 +164,7 @@ function getArgv(args) { }); } -function getBabiliOpts(argv) { +function getMinifyOpts(argv) { const inputOpts = Object.keys(argv) .filter(key => { if (Array.isArray(argv[key])) return argv[key].length > 0; @@ -180,7 +180,7 @@ function getBabiliOpts(argv) { const options = optionsParser(inputOpts); - // delete unncessary options to babili preset + // delete unncessary options to minify preset delete options["_"]; delete options.d; delete options["out-dir"]; @@ -243,7 +243,7 @@ async function run(args) { if (argv.help) printHelpInfo(); if (argv.V) log(version); - const options = getBabiliOpts(argv); + const options = getMinifyOpts(argv); if (!process.stdin.isTTY) { return runStdin(argv, options); diff --git a/packages/babili/src/fs.js b/packages/babel-minify/src/fs.js similarity index 95% rename from packages/babili/src/fs.js rename to packages/babel-minify/src/fs.js index b6c9a5593..7fc4e0c99 100644 --- a/packages/babili/src/fs.js +++ b/packages/babel-minify/src/fs.js @@ -4,7 +4,7 @@ const readdir = require("fs-readdir-recursive"); const promisify = require("util.promisify"); const mkdirp = promisify(require("mkdirp")); -const babili = require("./"); +const minify = require("./"); const EXTENSIONS = [".js", ".mjs"]; const readFileAsync = promisify(fs.readFile); @@ -54,7 +54,7 @@ async function readStdin() { } async function handleStdin(outputFilename, options) { - const { code } = babili(await readStdin(), options); + const { code } = minify(await readStdin(), options); if (outputFilename) { await writeFile(outputFilename, code); } else { @@ -63,7 +63,7 @@ async function handleStdin(outputFilename, options) { } async function handleFile(filename, outputFilename, options) { - const { code } = babili(await readFile(filename), options); + const { code } = minify(await readFile(filename), options); if (outputFilename) { await writeFile(outputFilename, code); } else { diff --git a/packages/babili/src/index.js b/packages/babel-minify/src/index.js similarity index 61% rename from packages/babili/src/index.js rename to packages/babel-minify/src/index.js index d72f11226..fee17028d 100644 --- a/packages/babili/src/index.js +++ b/packages/babel-minify/src/index.js @@ -1,9 +1,9 @@ const babelCore = require("babel-core"); -const babelPresetBabili = require("babel-preset-babili"); +const babelPresetMinify = require("babel-preset-minify"); -module.exports = function babili( +module.exports = function babelMinify( input, - // Minify options passed to babiliPreset + // Minify options passed to minifyPreset // defaults are handled in preset options = {}, // overrides and other options @@ -15,13 +15,13 @@ module.exports = function babili( // to override the default babelCore used babel = babelCore, - // to override the default babiliPreset used - babiliPreset = babelPresetBabili + // to override the default minify preset used + minifyPreset = babelPresetMinify } = {} ) { return babel.transform(input, { babelrc: false, - presets: [[babiliPreset, options]], + presets: [[minifyPreset, options]], comments: false, inputSourceMap, sourceMaps, diff --git a/packages/babili/src/options-parser.js b/packages/babel-minify/src/options-parser.js similarity index 97% rename from packages/babili/src/options-parser.js rename to packages/babel-minify/src/options-parser.js index df86c9d23..8e57923cb 100644 --- a/packages/babili/src/options-parser.js +++ b/packages/babel-minify/src/options-parser.js @@ -8,7 +8,7 @@ module.exports = function parseOpts(argv) { /** * Converts and Object of the form - {key: value} to deep object - * following rules of babili preset options + * following rules of minify preset options * * A preset option can be `true` | `object` which enables the particular plugin * `false` disables the plugin diff --git a/packages/babel-plugin-minify-builtins/package.json b/packages/babel-plugin-minify-builtins/package.json index 82aec0e55..9cf99baa8 100644 --- a/packages/babel-plugin-minify-builtins/package.json +++ b/packages/babel-plugin-minify-builtins/package.json @@ -2,16 +2,16 @@ "name": "babel-plugin-minify-builtins", "version": "0.1.3", "description": "Minify Standard built-in Objects", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-builtins", - "main": "lib/index.js", - "bugs": "https://github.com/babel/babili/issues", "keywords": [ "babel-plugin", "transform-built-ins" ], - "author": "Vignesh Shanmugam (https://vigneshh.in)", + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", "license": "MIT", + "author": "Vignesh Shanmugam (https://vigneshh.in)", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-builtins", "dependencies": { "babel-helper-evaluate-path": "^0.1.0" } diff --git a/packages/babel-plugin-minify-constant-folding/package.json b/packages/babel-plugin-minify-constant-folding/package.json index 67c929de5..0fcbf0b06 100644 --- a/packages/babel-plugin-minify-constant-folding/package.json +++ b/packages/babel-plugin-minify-constant-folding/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-constant-folding", "version": "0.1.3", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-constant-folding", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-constant-folding", "dependencies": { "babel-helper-evaluate-path": "^0.1.0" } diff --git a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js index 26d0ef427..aed518ebc 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js +++ b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js @@ -1852,8 +1852,8 @@ describe("dce-plugin", () => { ` ); - // https://github.com/babel/babili/issues/130 - // https://github.com/babel/babili/pull/132 + // https://github.com/babel/minify/issues/130 + // https://github.com/babel/minify/pull/132 thePlugin( "should not regress on #130", ` @@ -1869,7 +1869,7 @@ describe("dce-plugin", () => { ` ); - // https://github.com/babel/babili/issues/151 + // https://github.com/babel/minify/issues/151 thePlugin( "should not regress on issue #151 - array patterns and object patterns", ` @@ -1885,7 +1885,7 @@ describe("dce-plugin", () => { ` ); - // https://github.com/babel/babili/issues/232 + // https://github.com/babel/minify/issues/232 thePlugin( "should not regress on issue #232 - array patterns and object patterns with non constant init", ` @@ -1994,7 +1994,7 @@ describe("dce-plugin", () => { ` ); - // https://github.com/babel/babili/issues/265 + // https://github.com/babel/minify/issues/265 thePlugin( "should not remove return void 0; statement if inside a loop", ` @@ -2015,7 +2015,7 @@ describe("dce-plugin", () => { ` ); - // https://github.com/babel/babili/issues/265 + // https://github.com/babel/minify/issues/265 it("should integrate with simplify plugin changing scopes", () => { const source = unpad(` function getParentConditionalPath(path) { diff --git a/packages/babel-plugin-minify-dead-code-elimination/package.json b/packages/babel-plugin-minify-dead-code-elimination/package.json index 8b97fd4d3..b423c33d8 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/package.json +++ b/packages/babel-plugin-minify-dead-code-elimination/package.json @@ -2,13 +2,15 @@ "name": "babel-plugin-minify-dead-code-elimination", "version": "0.1.7", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-dead-code-elimination", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", + "keywords": [ + "babel-plugin" + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", "license": "MIT", + "author": "amasad", "main": "lib/index.js", - "keywords": ["babel-plugin"], + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-dead-code-elimination", "dependencies": { "babel-helper-evaluate-path": "^0.1.0", "babel-helper-mark-eval-scopes": "^0.1.1", diff --git a/packages/babel-plugin-minify-dead-code-elimination/src/index.js b/packages/babel-plugin-minify-dead-code-elimination/src/index.js index e882b7b94..2557e61f2 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/src/index.js +++ b/packages/babel-plugin-minify-dead-code-elimination/src/index.js @@ -467,7 +467,7 @@ module.exports = ({ types: t, traverse }) => { let noNext = true; let parentPath = path.parentPath; while (parentPath && !parentPath.isFunction() && noNext) { - // https://github.com/babel/babili/issues/265 + // https://github.com/babel/minify/issues/265 if (hasLoopParent(parentPath)) { noNext = false; break; @@ -977,7 +977,7 @@ module.exports = ({ types: t, traverse }) => { return; } - // https://github.com/babel/babili/issues/611 + // https://github.com/babel/minify/issues/611 // this is valid only for FunctionDeclaration where we convert // function declaration to expression in the next step if (replacementPath.isFunctionDeclaration()) { @@ -989,7 +989,7 @@ module.exports = ({ types: t, traverse }) => { } } - // https://github.com/babel/babili/issues/130 + // https://github.com/babel/minify/issues/130 if (!t.isExpression(replacement)) { t.toExpression(replacement); } diff --git a/packages/babel-plugin-minify-dead-code-elimination/src/remove-use-strict.js b/packages/babel-plugin-minify-dead-code-elimination/src/remove-use-strict.js index 81e4b6033..949cce209 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/src/remove-use-strict.js +++ b/packages/babel-plugin-minify-dead-code-elimination/src/remove-use-strict.js @@ -2,7 +2,7 @@ module.exports = removeUseStrict; -const newIssueUrl = "https://github.com/babel/babili/issues/new"; +const newIssueUrl = "https://github.com/babel/minify/issues/new"; const useStrict = "use strict"; diff --git a/packages/babel-plugin-minify-flip-comparisons/package.json b/packages/babel-plugin-minify-flip-comparisons/package.json index cfc496210..e85d10216 100644 --- a/packages/babel-plugin-minify-flip-comparisons/package.json +++ b/packages/babel-plugin-minify-flip-comparisons/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-flip-comparisons", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-flip-comparisons", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-flip-comparisons", "dependencies": { "babel-helper-is-void-0": "^0.1.1" } diff --git a/packages/babel-plugin-minify-guarded-expressions/package.json b/packages/babel-plugin-minify-guarded-expressions/package.json index 2eb39b193..93e748608 100644 --- a/packages/babel-plugin-minify-guarded-expressions/package.json +++ b/packages/babel-plugin-minify-guarded-expressions/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-guarded-expressions", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-guarded-expressions", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-guarded-expressions", "dependencies": { "babel-helper-flip-expressions": "^0.1.2" } diff --git a/packages/babel-plugin-minify-infinity/package.json b/packages/babel-plugin-minify-infinity/package.json index f26294b92..9a13a0f02 100644 --- a/packages/babel-plugin-minify-infinity/package.json +++ b/packages/babel-plugin-minify-infinity/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-minify-infinity", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-infinity", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-infinity" } diff --git a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js index 789640e04..733b224cf 100644 --- a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js +++ b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js @@ -1020,7 +1020,7 @@ describe("mangle-names", () => { ` ); - // https://github.com/babel/babili/issues/138 + // https://github.com/babel/minify/issues/138 thePlugin( "should handle class exports in modules - issue#138", ` @@ -1268,7 +1268,7 @@ describe("mangle-names", () => { // Safari raises a syntax error for a `let` or `const` declaration in a `for` // loop initialization that shadows a parent function's parameter. - // https://github.com/babel/babili/issues/559 + // https://github.com/babel/minify/issues/559 // https://bugs.webkit.org/show_bug.cgi?id=171041 // https://trac.webkit.org/changeset/217200/webkit/trunk/Source describe("Safari for loop lexical scope workaround", () => { diff --git a/packages/babel-plugin-minify-mangle-names/package.json b/packages/babel-plugin-minify-mangle-names/package.json index 83eb94b06..2df14c8bd 100644 --- a/packages/babel-plugin-minify-mangle-names/package.json +++ b/packages/babel-plugin-minify-mangle-names/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-mangle-names", "version": "0.1.3", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-mangle-names", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-mangle-names", "dependencies": { "babel-helper-mark-eval-scopes": "^0.1.1" } diff --git a/packages/babel-plugin-minify-mangle-names/src/index.js b/packages/babel-plugin-minify-mangle-names/src/index.js index 59c1971a4..59d0a6dc8 100644 --- a/packages/babel-plugin-minify-mangle-names/src/index.js +++ b/packages/babel-plugin-minify-mangle-names/src/index.js @@ -12,7 +12,7 @@ const { hasEval } = require("babel-helper-mark-eval-scopes"); -const newIssueUrl = "https://github.com/babel/babili/issues/new"; +const newIssueUrl = "https://github.com/babel/minify/issues/new"; module.exports = babel => { const { types: t, traverse } = babel; @@ -183,7 +183,7 @@ module.exports = babel => { * We have already captured the bindings when traversing through * Scopables, if a binding identifier doesn't have a binding, it * probably means that another transformation created a new binding, - * refer https://github.com/babel/babili/issues/549 for example - + * refer https://github.com/babel/minify/issues/549 for example - * binding created by plugin transform-es2015-function-name * * So we just don't care about bindings that do not exist @@ -444,7 +444,7 @@ module.exports = babel => { // This is a bug in babel // https://github.com/babel/babel/pull/3629 // case 2: Replacements in other plugins - // eg: https://github.com/babel/babili/issues/122 + // eg: https://github.com/babel/minify/issues/122 // replacement in dce from `x` to `!x` gives referencePath as `!x` path.traverse({ ReferencedIdentifier(refPath) { diff --git a/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js b/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js index e661bf930..6655cac46 100644 --- a/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js +++ b/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js @@ -3,7 +3,7 @@ const CountedSet = require("./counted-set"); const isLabelIdentifier = require("./is-label-identifier"); -const newIssueUrl = "https://github.com/babel/babili/issues/new"; +const newIssueUrl = "https://github.com/babel/minify/issues/new"; /** * ScopeTracker @@ -123,7 +123,7 @@ module.exports = class ScopeTracker { // Safari raises a syntax error for a `let` or `const` declaration in a // `for` loop initialization that shadows a parent function's parameter. - // https://github.com/babel/babili/issues/559 + // https://github.com/babel/minify/issues/559 // https://bugs.webkit.org/show_bug.cgi?id=171041 // https://trac.webkit.org/changeset/217200/webkit/trunk/Source const maybeDecl = binding.path.parentPath; diff --git a/packages/babel-plugin-minify-numeric-literals/package.json b/packages/babel-plugin-minify-numeric-literals/package.json index 329ab718d..1f1305232 100644 --- a/packages/babel-plugin-minify-numeric-literals/package.json +++ b/packages/babel-plugin-minify-numeric-literals/package.json @@ -2,16 +2,16 @@ "name": "babel-plugin-minify-numeric-literals", "version": "0.1.1", "description": "Shortens numeric literals using scientific notation", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-numeric-literals", - "bugs": "https://github.com/babel/babili/issues", - "author": "kangax", - "license": "MIT", - "main": "lib/index.js", "keywords": [ - "babel-plugin", - "babili" + "babel-minify", + "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "kangax", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-numeric-literals", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-plugin-minify-replace/package.json b/packages/babel-plugin-minify-replace/package.json index f8cc669dd..5fd65656b 100644 --- a/packages/babel-plugin-minify-replace/package.json +++ b/packages/babel-plugin-minify-replace/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-minify-replace", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-replace", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-replace" } diff --git a/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js b/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js index 9f15e450c..ef29adfa4 100644 --- a/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js +++ b/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js @@ -239,7 +239,7 @@ describe("simplify-plugin", () => { ` ); - // https://github.com/babel/babili/issues/208 + // https://github.com/babel/minify/issues/208 thePlugin( "should not regresson #208 by handling empty blocks when merging lines into sequences", ` @@ -421,7 +421,7 @@ describe("simplify-plugin", () => { ` ); - // https://github.com/babel/babili/issues/198 + // https://github.com/babel/minify/issues/198 thePlugin( "should convert while->for and NOT merge let/const if any is refereced outside the loop", ` @@ -2116,7 +2116,7 @@ describe("simplify-plugin", () => { ` ); - // https://github.com/babel/babili/issues/115 + // https://github.com/babel/minify/issues/115 thePlugin( "should transform impure conditional statements correctly - issue#115", ` diff --git a/packages/babel-plugin-minify-simplify/package.json b/packages/babel-plugin-minify-simplify/package.json index 524947264..039d44edd 100644 --- a/packages/babel-plugin-minify-simplify/package.json +++ b/packages/babel-plugin-minify-simplify/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-simplify", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-simplify", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-simplify", "dependencies": { "babel-helper-flip-expressions": "^0.1.2", "babel-helper-is-nodes-equiv": "^0.0.1", diff --git a/packages/babel-plugin-minify-simplify/src/index.js b/packages/babel-plugin-minify-simplify/src/index.js index 9e281cff7..50e2afaab 100644 --- a/packages/babel-plugin-minify-simplify/src/index.js +++ b/packages/babel-plugin-minify-simplify/src/index.js @@ -492,7 +492,7 @@ module.exports = ({ types: t }) => { node.body = statements; // this additional traversal is horrible but it's done to fix - // https://github.com/babel/babili/issues/323 + // https://github.com/babel/minify/issues/323 // in which type annotation somehow gets messed up // during sequence expression transformation path.traverse({ diff --git a/packages/babel-plugin-minify-type-constructors/README.md b/packages/babel-plugin-minify-type-constructors/README.md index efd6fce04..9bb9789d5 100644 --- a/packages/babel-plugin-minify-type-constructors/README.md +++ b/packages/babel-plugin-minify-type-constructors/README.md @@ -1,6 +1,6 @@ # babel-plugin-minify-type-constructors -**Note:** Not recommended if full support for IE8 and lower is required. [Details](https://github.com/babel/babili/pull/45#discussion_r70181249) +**Note:** Not recommended if full support for IE8 and lower is required. [Details](https://github.com/babel/minify/pull/45#discussion_r70181249) ## Example diff --git a/packages/babel-plugin-minify-type-constructors/__tests__/type-constructors-test.js b/packages/babel-plugin-minify-type-constructors/__tests__/type-constructors-test.js index 40c15afad..be00d7f4f 100644 --- a/packages/babel-plugin-minify-type-constructors/__tests__/type-constructors-test.js +++ b/packages/babel-plugin-minify-type-constructors/__tests__/type-constructors-test.js @@ -293,7 +293,7 @@ describe("type-constructors-plugin", () => { } }); - // https://github.com/babel/babili/issues/206 + // https://github.com/babel/minify/issues/206 thePlugin( "should handle floating point numbers in `Array()`", ` diff --git a/packages/babel-plugin-minify-type-constructors/package.json b/packages/babel-plugin-minify-type-constructors/package.json index 18e123d4b..5be1b84d4 100644 --- a/packages/babel-plugin-minify-type-constructors/package.json +++ b/packages/babel-plugin-minify-type-constructors/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-minify-type-constructors", "version": "0.1.2", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-type-constructors", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-type-constructors", "dependencies": { "babel-helper-is-void-0": "^0.1.1" } diff --git a/packages/babel-plugin-transform-inline-consecutive-adds/package.json b/packages/babel-plugin-transform-inline-consecutive-adds/package.json index 11dfaa633..7b6819b1b 100644 --- a/packages/babel-plugin-transform-inline-consecutive-adds/package.json +++ b/packages/babel-plugin-transform-inline-consecutive-adds/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-inline-consecutive-adds", "version": "0.1.2", "description": "This plugin inlines consecutive property assignments, array pushes, etc.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-inline-consecutive-adds", - "bugs": "https://github.com/babel/babili/issues", - "author": "shinew", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "shinew", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-inline-consecutive-adds" } diff --git a/packages/babel-plugin-transform-inline-environment-variables/package.json b/packages/babel-plugin-transform-inline-environment-variables/package.json index 0cd3efd82..55531c93a 100644 --- a/packages/babel-plugin-transform-inline-environment-variables/package.json +++ b/packages/babel-plugin-transform-inline-environment-variables/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-inline-environment-variables", "version": "0.1.1", "description": "Inline environment variables.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-inline-environment-variables", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-inline-environment-variables", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-plugin-transform-member-expression-literals/package.json b/packages/babel-plugin-transform-member-expression-literals/package.json index b4d5daec7..c64511116 100644 --- a/packages/babel-plugin-transform-member-expression-literals/package.json +++ b/packages/babel-plugin-transform-member-expression-literals/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-member-expression-literals", "version": "6.8.4", "description": "Turn valid member expression property literals into plain identifiers", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-member-expression-literals", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-member-expression-literals" } diff --git a/packages/babel-plugin-transform-merge-sibling-variables/package.json b/packages/babel-plugin-transform-merge-sibling-variables/package.json index bd3756c68..df64a0fc8 100644 --- a/packages/babel-plugin-transform-merge-sibling-variables/package.json +++ b/packages/babel-plugin-transform-merge-sibling-variables/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-merge-sibling-variables", "version": "6.8.5", "description": "Merge sibling variables into one.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-merge-sibling-variables", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-merge-sibling-variables" } diff --git a/packages/babel-plugin-transform-minify-booleans/package.json b/packages/babel-plugin-transform-minify-booleans/package.json index ff8b696df..72f1d72a0 100644 --- a/packages/babel-plugin-transform-minify-booleans/package.json +++ b/packages/babel-plugin-transform-minify-booleans/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-minify-booleans", "version": "6.8.2", "description": "Turn boolean literals into !0 for true and !1 for false.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-minify-booleans", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-minify-booleans", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-plugin-transform-node-env-inline/package.json b/packages/babel-plugin-transform-node-env-inline/package.json index 26bb2c3ff..1e5bbba8a 100644 --- a/packages/babel-plugin-transform-node-env-inline/package.json +++ b/packages/babel-plugin-transform-node-env-inline/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-node-env-inline", "version": "0.1.1", "description": "Inline the `NODE_ENV` environment variable and evaluate it if possible", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-node-env-inline", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-node-env-inline", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-plugin-transform-property-literals/package.json b/packages/babel-plugin-transform-property-literals/package.json index c2def0288..b87c615f8 100644 --- a/packages/babel-plugin-transform-property-literals/package.json +++ b/packages/babel-plugin-transform-property-literals/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-property-literals", "version": "6.8.4", "description": "Turn valid property key literals to plain identifiers", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-property-literals", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-property-literals", "dependencies": { "esutils": "^2.0.2" } diff --git a/packages/babel-plugin-transform-regexp-constructors/package.json b/packages/babel-plugin-transform-regexp-constructors/package.json index 153359f9a..6468eb87a 100644 --- a/packages/babel-plugin-transform-regexp-constructors/package.json +++ b/packages/babel-plugin-transform-regexp-constructors/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-regexp-constructors", "version": "0.1.1", "description": "This changes RegExp constructors into literals if the RegExp arguments are strings.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-regexp-constructors", - "bugs": "https://github.com/babel/babili/issues", - "author": "shinew", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "shinew", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-regexp-constructors", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-plugin-transform-remove-console/package.json b/packages/babel-plugin-transform-remove-console/package.json index 93fbea040..2548d48be 100644 --- a/packages/babel-plugin-transform-remove-console/package.json +++ b/packages/babel-plugin-transform-remove-console/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-remove-console", "version": "6.8.4", "description": "Remove all console.* calls.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-remove-console", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-console" } diff --git a/packages/babel-plugin-transform-remove-debugger/package.json b/packages/babel-plugin-transform-remove-debugger/package.json index 559c83b8c..28990ae7f 100644 --- a/packages/babel-plugin-transform-remove-debugger/package.json +++ b/packages/babel-plugin-transform-remove-debugger/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-remove-debugger", "version": "6.8.4", "description": "Remove debugger statements", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-remove-debugger", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-debugger" } diff --git a/packages/babel-plugin-transform-remove-undefined/package.json b/packages/babel-plugin-transform-remove-undefined/package.json index c3bfe00cb..cd720c436 100644 --- a/packages/babel-plugin-transform-remove-undefined/package.json +++ b/packages/babel-plugin-transform-remove-undefined/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-remove-undefined", "version": "0.1.2", "description": "This removes rvals that are equivalent to undefined wherever possible", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-remove-undefined", - "bugs": "https://github.com/babel/babili/issues", - "author": "shinew", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "shinew", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-undefined" } diff --git a/packages/babel-plugin-transform-remove-undefined/src/index.js b/packages/babel-plugin-transform-remove-undefined/src/index.js index c1dd6083e..5cfccd11b 100644 --- a/packages/babel-plugin-transform-remove-undefined/src/index.js +++ b/packages/babel-plugin-transform-remove-undefined/src/index.js @@ -60,7 +60,7 @@ function hasViolation(declarator, scope, start) { const scopeParent = declarator.getFunctionParent(); const violation = binding.constantViolations.some(v => { - // https://github.com/babel/babili/issues/630 + // https://github.com/babel/minify/issues/630 if (!v.node) { return false; } diff --git a/packages/babel-plugin-transform-simplify-comparison-operators/package.json b/packages/babel-plugin-transform-simplify-comparison-operators/package.json index a8a3f7e10..77de33731 100644 --- a/packages/babel-plugin-transform-simplify-comparison-operators/package.json +++ b/packages/babel-plugin-transform-simplify-comparison-operators/package.json @@ -2,13 +2,13 @@ "name": "babel-plugin-transform-simplify-comparison-operators", "version": "6.8.4", "description": "Convert === and !== to == and != if their types are inferred to be the same.", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-simplify-comparison-operators", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" - ] + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-simplify-comparison-operators" } diff --git a/packages/babel-plugin-transform-undefined-to-void/package.json b/packages/babel-plugin-transform-undefined-to-void/package.json index ad92f3b86..9b05c7f9d 100644 --- a/packages/babel-plugin-transform-undefined-to-void/package.json +++ b/packages/babel-plugin-transform-undefined-to-void/package.json @@ -2,15 +2,15 @@ "name": "babel-plugin-transform-undefined-to-void", "version": "6.8.2", "description": "Replace references to `undefined` with `void 0`", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-undefined-to-void", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", "keywords": [ "babel-plugin" ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "amasad", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-undefined-to-void", "dependencies": {}, "devDependencies": {} } diff --git a/packages/babel-preset-babili/.npmignore b/packages/babel-preset-minify/.npmignore similarity index 100% rename from packages/babel-preset-babili/.npmignore rename to packages/babel-preset-minify/.npmignore diff --git a/packages/babel-preset-babili/README.md b/packages/babel-preset-minify/README.md similarity index 94% rename from packages/babel-preset-babili/README.md rename to packages/babel-preset-minify/README.md index 76d0c7228..c5cd9a616 100644 --- a/packages/babel-preset-babili/README.md +++ b/packages/babel-preset-minify/README.md @@ -1,4 +1,4 @@ -# babel-preset-babili +# babel-preset-minify Babel preset for all minify plugins. @@ -9,7 +9,7 @@ Babel preset for all minify plugins. ## Install ```sh -npm install --save-dev babel-preset-babili +npm install --save-dev babel-preset-minify ``` ## Usage @@ -20,7 +20,7 @@ npm install --save-dev babel-preset-babili ```json { - "presets": ["babili"] + "presets": ["minify"] } ``` @@ -28,7 +28,7 @@ or pass in options - ```json { - "presets": [["babili", { + "presets": [["minify", { "mangle": { "blacklist": ["MyCustomError"] }, @@ -43,14 +43,14 @@ or pass in options - ### Via CLI ```sh -babel script.js --presets babili +babel script.js --presets minify ``` ### Via Node API ```javascript require("babel-core").transform("code", { - presets: ["babili"] + presets: ["minify"] }); ``` @@ -105,7 +105,7 @@ keepClassName | Passed to [mangle][mangle] & [deadcode][deadcode] ```json { - "presets": [["babili", { + "presets": [["minify", { "evaluate": false, "mangle": true }]] @@ -114,7 +114,7 @@ keepClassName | Passed to [mangle][mangle] & [deadcode][deadcode] ```json { - "presets": [["babili", { + "presets": [["minify", { "mangle": { "blacklist": ["ParserError", "NetworkError"] } @@ -124,13 +124,13 @@ keepClassName | Passed to [mangle][mangle] & [deadcode][deadcode] ```json { - "presets": [["babili", { + "presets": [["minify", { "keepFnName": true }]] } // is the same as { - "presets": [["babili", { + "presets": [["minify", { "mangle": { "keepFnName": true }, diff --git a/packages/babel-preset-babili/__tests__/__snapshots__/options-tests.js.snap b/packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap similarity index 100% rename from packages/babel-preset-babili/__tests__/__snapshots__/options-tests.js.snap rename to packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap diff --git a/packages/babel-preset-babili/__tests__/babili-es2015-tests.js b/packages/babel-preset-minify/__tests__/babili-es2015-tests.js similarity index 85% rename from packages/babel-preset-babili/__tests__/babili-es2015-tests.js rename to packages/babel-preset-minify/__tests__/babili-es2015-tests.js index 47c516511..876aff558 100644 --- a/packages/babel-preset-babili/__tests__/babili-es2015-tests.js +++ b/packages/babel-preset-minify/__tests__/babili-es2015-tests.js @@ -1,12 +1,12 @@ jest.autoMockOff(); const es2015 = require("babel-preset-es2015"); -const babili = require("../src/index"); +const minifyPreset = require("../src/index"); const thePlugin = require("../../../utils/test-transform")(null, { plugins: [], minified: false, - presets: [babili, es2015] + presets: [minifyPreset, es2015] }); describe("preset along with es2015", () => { diff --git a/packages/babel-preset-babili/__tests__/options-tests.js b/packages/babel-preset-minify/__tests__/options-tests.js similarity index 100% rename from packages/babel-preset-babili/__tests__/options-tests.js rename to packages/babel-preset-minify/__tests__/options-tests.js diff --git a/packages/babel-preset-babili/__tests__/preset-tests.js b/packages/babel-preset-minify/__tests__/preset-tests.js similarity index 97% rename from packages/babel-preset-babili/__tests__/preset-tests.js rename to packages/babel-preset-minify/__tests__/preset-tests.js index e4226bb38..e704e8049 100644 --- a/packages/babel-preset-babili/__tests__/preset-tests.js +++ b/packages/babel-preset-minify/__tests__/preset-tests.js @@ -7,7 +7,7 @@ const thePlugin = require("../../../utils/test-transform")(null, { }); describe("preset", () => { - // https://github.com/babel/babili/issues/122 + // https://github.com/babel/minify/issues/122 thePlugin( "should fix issue#122", ` diff --git a/packages/babel-preset-babili/package.json b/packages/babel-preset-minify/package.json similarity index 82% rename from packages/babel-preset-babili/package.json rename to packages/babel-preset-minify/package.json index 222c07e37..cb767f4f9 100644 --- a/packages/babel-preset-babili/package.json +++ b/packages/babel-preset-minify/package.json @@ -1,14 +1,18 @@ { - "name": "babel-preset-babili", + "name": "babel-preset-minify", "version": "0.1.4", "description": "", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babel-preset-babili", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", + "keywords": [ + "babel-minify", + "babel-preset", + "minify" + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", "license": "MIT", + "author": "amasad", "main": "lib/index.js", - "keywords": ["babel-preset"], + "repository": "https://github.com/babel/minify/tree/master/packages/babel-preset-minify", "dependencies": { "babel-plugin-minify-builtins": "^0.1.3", "babel-plugin-minify-constant-folding": "^0.1.3", diff --git a/packages/babel-preset-babili/src/index.js b/packages/babel-preset-minify/src/index.js similarity index 100% rename from packages/babel-preset-babili/src/index.js rename to packages/babel-preset-minify/src/index.js diff --git a/packages/babili/README.md b/packages/babili/README.md deleted file mode 100644 index 42120e829..000000000 --- a/packages/babili/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# babili - -Node API and CLI - -[`babili`](/packages/babili) [![npm](https://img.shields.io/npm/v/babili.svg?maxAge=2592000)](https://www.npmjs.com/package/babili) - -Use `babili` if you don't already use babel (as a preset) or want to run it standalone. - -## Installation - -```sh -npm install babili --save-dev -``` - -## Usage - -### Node API - -```js -const babili = require("babili"); - -const {code, map} = babili("input code", { - mangle: { - keepClassName: true - } -}); -``` - -### CLI - -```sh -babili input.js --out-file input.min.js --mangle.keepClassName -``` - -## Node API - -```js -const babili = require("babili"); - -babili(input, babiliOptions, overrides) -``` - -### babiliOptions - -Refer [babel-preset-babili options](../babel-preset-babili#options) - -### overrides - -+ `babel`: Custom babel -+ `babiliPreset`: Custom babili preset -+ `inputSourceMap`: Input Sourcemap -+ `sourceMaps`: [Boolean] - -## CLI Options - -``` -babili input.js [options] -``` - -### Simple preset options - -For simple options, use `--optionName` in CLI - -Refer [preset's 1-1 options](../babel-preset-babili#1-1-mapping-with-plugin) for the list of options - -Example: - -``` -babili input.js --mangle false -``` - -### Nested preset options - -Usage: `--optionName.featureName` - -Example: - -```sh -babili input.js --mangle.keepClassName --deadcode.keepFnArgs --outFile input.min.js -``` - -Refer the corresponding plugins to know the list of options it takes - -### IO options - -+ `--out-file path/to/file.min.js`: Output filename. Used only when reading from STDIN / a single input file -+ `--out-dir path/to/dir`: Output Directory. diff --git a/packages/babili/__tests__/__snapshots__/cli-tests.js.snap b/packages/babili/__tests__/__snapshots__/cli-tests.js.snap deleted file mode 100644 index 075c88c8c..000000000 --- a/packages/babili/__tests__/__snapshots__/cli-tests.js.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Babili CLI input dir + outdir 1`] = `"let foo=10;"`; - -exports[`Babili CLI input file + outDir 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; - -exports[`Babili CLI input file + outFile 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; - -exports[`Babili CLI input file + stdout 1`] = ` -Object { - "stderr": "", - "stdout": "function foo(){const a=x(1),b=y(2);return z(a,b)}", -} -`; - -exports[`Babili CLI should throw on all invalid options 1`] = ` -Object { - "code": 1, - "stderr": "Error: Invalid Options passed: foo,bar -", -} -`; - -exports[`Babili CLI stdin + outFile 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; - -exports[`Babili CLI stdin + stdout 1`] = ` -Object { - "stderr": "", - "stdout": "function a(){const a=x(1),b=y(2);return z(a,b)}", -} -`; diff --git a/packages/babili/__tests__/__snapshots__/node-api-tests.js.snap b/packages/babili/__tests__/__snapshots__/node-api-tests.js.snap deleted file mode 100644 index 2f652c7ba..000000000 --- a/packages/babili/__tests__/__snapshots__/node-api-tests.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Babili Node API override default babili options 1`] = `"function foo(){const bar=x(1),baz=y(2);return z(bar,baz)}"`; - -exports[`Babili Node API override nested babili options 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; - -exports[`Babili Node API simple usage 1`] = `"function foo(){const a=x(1),b=y(2);return z(a,b)}"`; diff --git a/packages/babili/__tests__/node-api-tests.js b/packages/babili/__tests__/node-api-tests.js deleted file mode 100644 index 9575e7963..000000000 --- a/packages/babili/__tests__/node-api-tests.js +++ /dev/null @@ -1,31 +0,0 @@ -jest.autoMockOff(); - -const babili = require("../src/index"); - -const sampleInput = ` -function foo() { - const bar = x(1); - const baz = y(2); - return z(bar, baz); -} -`; - -describe("Babili Node API", () => { - it("simple usage", () => { - expect(babili(sampleInput).code).toMatchSnapshot(); - }); - - it("throw on invalid options", () => { - expect(() => babili(sampleInput, { foo: false, bar: true }).code).toThrow(); - }); - - it("override default babili options", () => { - const babiliOpts = { mangle: false }; - expect(babili(sampleInput, babiliOpts).code).toMatchSnapshot(); - }); - - it("override nested babili options", () => { - const babiliOpts = { mangle: { keepFnName: false } }; - expect(babili(sampleInput, babiliOpts).code).toMatchSnapshot(); - }); -}); diff --git a/packages/babili/package.json b/packages/babili/package.json deleted file mode 100644 index f35e1bdd8..000000000 --- a/packages/babili/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "babili", - "version": "0.1.4", - "description": "✂️ An ES6+ aware minifier based on the Babel toolchain (beta)", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/babili", - "bugs": "https://github.com/babel/babili/issues", - "author": "amasad", - "license": "MIT", - "main": "lib/index.js", - "bin": { - "babili": "./bin/babili.js" - }, - "keywords": ["babel-preset"], - "dependencies": { - "babel-core": "^6.24.1", - "babel-preset-babili": "^0.1.4", - "fs-readdir-recursive": "^1.0.0", - "mkdirp": "^0.5.1", - "util.promisify": "^1.0.0", - "yargs-parser": "^5.0.0" - } -} diff --git a/packages/gulp-babili/.npmignore b/packages/gulp-babel-minify/.npmignore similarity index 100% rename from packages/gulp-babili/.npmignore rename to packages/gulp-babel-minify/.npmignore diff --git a/packages/gulp-babel-minify/README.md b/packages/gulp-babel-minify/README.md new file mode 100644 index 000000000..1dd3b6c07 --- /dev/null +++ b/packages/gulp-babel-minify/README.md @@ -0,0 +1,41 @@ +# gulp-babel-minify + +## Installation + +```sh +npm install gulp-babel-minify --save-dev +``` + +## Usage + +```js +const gulp = require("gulp"); +const minify = require("gulp-babel-minify"); + +gulp.task("minify", () => + gulp.src("./build/app.js") + .pipe(minify({ + mangle: { + keepClassName: true + } + })) + .pipe(gulp.dest("./dist")); +); +``` + +## API + +```js +gulpBabelMinify(minifyOptions, overrides); +``` + +### minifyOptions + +These are passed on to the minify preset. Refer https://github.com/babel/minify/tree/master/packages/babel-preset-minify#options. Default `{}` + +### Overrides + +Default: `{}` + ++ `babel`: Use a custom `babel-core` ++ `minifyPreset`: Use a custom `babel-preset-minify` diff --git a/packages/gulp-babel-minify/__tests__/__snapshots__/gulp-babili-test.js.snap b/packages/gulp-babel-minify/__tests__/__snapshots__/gulp-babili-test.js.snap new file mode 100644 index 000000000..c15682ab8 --- /dev/null +++ b/packages/gulp-babel-minify/__tests__/__snapshots__/gulp-babili-test.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`gulp-babel-minify comments should remove all comments when false 1`] = `"function foo(){}bar();var a=baz();"`; + +exports[`gulp-babel-minify comments should remove comments by default except license and preserve 1`] = ` +"/** + * @license + * This is a test + */function foo(){}bar();var a=baz();" +`; + +exports[`gulp-babel-minify comments should take a custom function 1`] = `"function foo(){}bar();/* YAC - yet another comment */var a=baz();"`; + +exports[`gulp-babel-minify should remove comments while doing DCE and simplify 1`] = ` +"var a=function(){(function(){foo(),bar(),baz();// comments should be optimized away +})()};" +`; diff --git a/packages/gulp-babili/__tests__/gulp-babili-test.js b/packages/gulp-babel-minify/__tests__/gulp-babili-test.js similarity index 88% rename from packages/gulp-babili/__tests__/gulp-babili-test.js rename to packages/gulp-babel-minify/__tests__/gulp-babili-test.js index 88a6d36ef..f3a38d3ce 100644 --- a/packages/gulp-babili/__tests__/gulp-babili-test.js +++ b/packages/gulp-babel-minify/__tests__/gulp-babili-test.js @@ -2,15 +2,15 @@ jest.autoMockOff(); const gutil = require("gulp-util"); const babelCore = require("babel-core"); -const babiliPreset = require("babel-preset-babili"); +const minifyPreset = require("babel-preset-minify"); const unpad = require("../../../utils/unpad"); -const gulpBabili = require("../src/index"); +const gulpBabelMinify = require("../src/index"); -describe("gulp-babili", () => { +describe("gulp-babel-minify", () => { it("should work with a good default", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili(); + const stream = gulpBabelMinify(); const source = unpad(` function foo() { @@ -35,9 +35,9 @@ describe("gulp-babili", () => { }); }); - it("should take options and pass them to babili", () => { + it("should take options and pass them to babel-minify", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili({ + const stream = gulpBabelMinify({ mangle: { blacklist: { bar: true @@ -67,7 +67,7 @@ describe("gulp-babili", () => { }); }); - it("should take custom babel and babili", () => { + it("should take custom babel and babel-minify", () => { return new Promise((resolve, reject) => { const babel = Object.assign({}, babelCore); @@ -80,16 +80,16 @@ describe("gulp-babili", () => { }); let usedPreset = false; - const babili = function(...args) { + const minify = function(...args) { usedPreset = true; - return babiliPreset(...args); + return minifyPreset(...args); }; - const stream = gulpBabili( + const stream = gulpBabelMinify( {}, { babel, - babili + minifyPreset: minify } ); @@ -135,7 +135,7 @@ describe("gulp-babili", () => { it("should remove comments by default except license and preserve", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili(); + const stream = gulpBabelMinify(); stream.on("data", function(file) { expect(file.contents.toString()).toMatchSnapshot(); resolve(); @@ -147,7 +147,7 @@ describe("gulp-babili", () => { it("should remove all comments when false", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili( + const stream = gulpBabelMinify( {}, { comments: false @@ -164,7 +164,7 @@ describe("gulp-babili", () => { it("should take a custom function", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili( + const stream = gulpBabelMinify( {}, { comments(contents) { @@ -184,7 +184,7 @@ describe("gulp-babili", () => { it("should remove comments while doing DCE and simplify", () => { return new Promise((resolve, reject) => { - const stream = gulpBabili( + const stream = gulpBabelMinify( {}, { comments(contents) { diff --git a/packages/gulp-babel-minify/package.json b/packages/gulp-babel-minify/package.json new file mode 100644 index 000000000..43a2eed61 --- /dev/null +++ b/packages/gulp-babel-minify/package.json @@ -0,0 +1,22 @@ +{ + "name": "gulp-babel-minify", + "version": "0.1.4", + "description": "Babel Minify plugin for Gulp", + "keywords": [ + "babel-minify", + "babel-preset" + ], + "homepage": "https://github.com/babel/minify#readme", + "bugs": "https://github.com/babel/minify/issues", + "license": "MIT", + "author": "boopathi", + "main": "lib/index.js", + "repository": "https://github.com/babel/minify/tree/master/packages/gulp-babel-minify", + "dependencies": { + "babel-core": "^6.25.0", + "babel-preset-minify": "^0.1.4", + "gulp-util": "^3.0.8", + "through2": "^2.0.3", + "vinyl-sourcemaps-apply": "^0.2.1" + } +} diff --git a/packages/gulp-babili/src/index.js b/packages/gulp-babel-minify/src/index.js similarity index 87% rename from packages/gulp-babili/src/index.js rename to packages/gulp-babel-minify/src/index.js index 58cef62ca..a6d6961d5 100644 --- a/packages/gulp-babili/src/index.js +++ b/packages/gulp-babel-minify/src/index.js @@ -2,19 +2,19 @@ const babelCore = require("babel-core"); const through2 = require("through2"); const gutil = require("gulp-util"); const applySourceMap = require("vinyl-sourcemaps-apply"); -const babiliPreset = require("babel-preset-babili"); +const babelPresetMinify = require("babel-preset-minify"); const { PluginError } = gutil; -const NAME = "gulp-babili"; +const NAME = "gulp-babel-minify"; -module.exports = gulpBabili; +module.exports = gulpBabelMinify; -function gulpBabili( - babiliOpts = {}, +function gulpBabelMinify( + minifyOpts = {}, { babel = babelCore, - babili = babiliPreset, + minifyPreset = babelPresetMinify, comments = /preserve|licen(s|c)e/ } = {} ) { @@ -38,7 +38,7 @@ function gulpBabili( ast: false, /* preset */ - presets: [[babili, babiliOpts]], + presets: [[minifyPreset, minifyOpts]], /* sourcemaps */ sourceMaps: !!file.sourceMap, diff --git a/packages/gulp-babili/README.md b/packages/gulp-babili/README.md deleted file mode 100644 index d484edfcb..000000000 --- a/packages/gulp-babili/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# gulp-babili - -## Installation - -```sh -npm install gulp-babili --save-dev -``` - -## Usage - -```js -const gulp = require("gulp"); -const babili = require("gulp-babili"); - -gulp.task("minify", () => - gulp.src("./build/app.js") - .pipe(babili({ - mangle: { - keepClassName: true - } - })) - .pipe(gulp.dest("./dist")); -); -``` - -## API - -```js -gulpBabili(babiliOptions, overrides); -``` - -### babiliOptions - -These are passed on to the babili preset. Refer https://github.com/babel/babili/tree/master/packages/babel-preset-babili#options. Default `{}` - -### Overrides - -Default: `{}` - -+ `babel`: Use a custom `babel-core` -+ `babili`: Use a custom `babel-preset-babili` diff --git a/packages/gulp-babili/__tests__/__snapshots__/gulp-babili-test.js.snap b/packages/gulp-babili/__tests__/__snapshots__/gulp-babili-test.js.snap deleted file mode 100644 index 4f574e8fc..000000000 --- a/packages/gulp-babili/__tests__/__snapshots__/gulp-babili-test.js.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`gulp-babili comments should remove all comments when false 1`] = `"function foo(){}bar();var a=baz();"`; - -exports[`gulp-babili comments should remove comments by default except license and preserve 1`] = ` -"/** - * @license - * This is a test - */function foo(){}bar();var a=baz();" -`; - -exports[`gulp-babili comments should take a custom function 1`] = `"function foo(){}bar();/* YAC - yet another comment */var a=baz();"`; - -exports[`gulp-babili should remove comments while doing DCE and simplify 1`] = ` -"var a=function(){(function(){foo(),bar(),baz();// comments should be optimized away -})()};" -`; diff --git a/packages/gulp-babili/package.json b/packages/gulp-babili/package.json deleted file mode 100644 index f0de022a8..000000000 --- a/packages/gulp-babili/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "gulp-babili", - "version": "0.1.4", - "description": "Gulp Babili", - "homepage": "https://github.com/babel/babili#readme", - "repository": "https://github.com/babel/babili/tree/master/packages/gulp-babili", - "bugs": "https://github.com/babel/babili/issues", - "author": "boopathi", - "license": "MIT", - "main": "lib/index.js", - "keywords": [ - "babel-preset", - "babili" - ], - "dependencies": { - "babel-core": "^6.25.0", - "babel-preset-babili": "^0.1.4", - "gulp-util": "^3.0.8", - "through2": "^2.0.3", - "vinyl-sourcemaps-apply": "^0.2.1" - } -} diff --git a/scripts/benchmark.js b/scripts/benchmark.js index b83922f75..110dcded2 100755 --- a/scripts/benchmark.js +++ b/scripts/benchmark.js @@ -55,7 +55,7 @@ class Benchmark { gzipped, filename, items: [ - this.test(this.babili, code), + this.test(this.babelMinify, code), this.test(this.uglify, code), this.test(this.closureCompiler, filename, false), this.test(this.closureCompilerJs, code), @@ -100,10 +100,10 @@ class Benchmark { time: delta[0] * 1e3 + delta[1] / 1e6 }; } - babili(code) { + babelMinify(code) { return babel.transform(code, { sourceType: "script", - presets: [require("../packages/babel-preset-babili")], + presets: [require("../packages/babel-preset-minify")], comments: false }).code; } diff --git a/scripts/plugin-timing.js b/scripts/plugin-timing.js index 79cdade84..62a5aa176 100755 --- a/scripts/plugin-timing.js +++ b/scripts/plugin-timing.js @@ -1,6 +1,6 @@ #!/usr/bin/env node const babel = require("babel-core"); -const preset = require("../packages/babel-preset-babili"); +const preset = require("../packages/babel-preset-minify"); const fs = require("fs"); const Table = require("cli-table"); diff --git a/smoke/run.js b/smoke/run.js index 45e020169..69115c3b4 100644 --- a/smoke/run.js +++ b/smoke/run.js @@ -18,7 +18,7 @@ const TESTS = [ dir: "lodash", files: "lodash.js", test: "npm run test:main", - babiliOptions: { + minifyOptions: { keepFnName: true } } @@ -112,7 +112,7 @@ run(); // files: "dist/immutable.js", // build: "npm run build:dist", // test: "npm run testonly", -// babiliOptions: { +// minifyOptions: { // keepFnName: true, // unsafe: { // typeConstructors: false diff --git a/smoke/smoke-test.js b/smoke/smoke-test.js index 6ec052850..33c352a44 100644 --- a/smoke/smoke-test.js +++ b/smoke/smoke-test.js @@ -4,7 +4,7 @@ const path = require("path"); const babel = require("babel-core"); const chalk = require("chalk"); const glob = require("glob"); -const babiliPreset = require("../packages/babel-preset-babili"); +const minifyPreset = require("../packages/babel-preset-minify"); const breakMeTransform = require("./break"); const SMOKE_ASSETS_DIR = path.join(__dirname, "../smoke/assets"); @@ -121,7 +121,7 @@ class SmokeTest { minify(contents) { return babel.transform(contents, { minified: true, - presets: [[babiliPreset, this.options.babiliOptions]] + presets: [[minifyPreset, this.options.minifyOptions]] }); }