Coder Social home page Coder Social logo

babili's Introduction

babili (babel-minify)

An ES6+ aware minifier based on the Babel toolchain.

Travis Status Slack Status

  • NOTE: We are in a feature freeze as we're trying to hammer out all the bugs to get to beta release. The best way to contribute is to test, report bugs, and add test cases.

  • Checkout our CONTRIBUTING.md if you want to help out!

  • babili is consumable via API, CLI, or babel preset.

Package Version Dependencies
babili npm Dependency Status

This is simple wrapper around the regular babel-cli and thus takes in the same 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.

Usage

babili src -d lib

Equivalent to: babel src -d lib --presets=babili

Package Version Dependencies
babel-preset-babili npm Dependency Status

It's a babel preset (like babel-preset-es2015).

Usage

You'll most likely want to use it only in the production environment. Check out the env docs for more help.

Options specific to a certain environment are merged into and overwrite non-env specific options.

.babelrc:

{
  "presets": ["es2015"],
  "env": {
    "production": {
      "presets": ["babili"]
    }
  }
}

Then you'll need to set the env variable which could be something like BABEL_ENV=production npm run build

Plugins (in babel-preset-babili)

The babili repo is comprised of many npm packages. It is a lerna monorepo similar to babel itself.

The npm package babel-preset-babili is at the path packages/babel-preset-babili

Package Version Dependencies
babel-plugin-minify-constant-folding npm Dependency Status
babel-plugin-minify-dead-code-elimination npm Dependency Status
babel-plugin-minify-flip-comparisons npm Dependency Status
babel-plugin-minify-guarded-expressions npm Dependency Status
babel-plugin-minify-infinity npm Dependency Status
babel-plugin-minify-mangle-names npm Dependency Status
babel-plugin-minify-replace npm Dependency Status
babel-plugin-minify-simplify npm Dependency Status
babel-plugin-minify-type-constructors npm Dependency Status
babel-plugin-transform-member-expression-literals npm Dependency Status
babel-plugin-transform-merge-sibling-variables npm Dependency Status
babel-plugin-transform-minify-booleans npm Dependency Status
babel-plugin-transform-property-literals npm Dependency Status
babel-plugin-transform-simplify-comparison-operators npm Dependency Status
babel-plugin-transform-undefined-to-void npm Dependency Status

Usage

Normally you wouldn't be consuming the plugins directly since the preset is available.

Add to your .babelrc's plugins array.

{
  "plugins": ["babel-plugin-transform-undefined-to-void"]
}

Other

Package Version Dependencies
babel-plugin-minify-empty-function npm Dependency Status
babel-plugin-transform-inline-environment-variables npm Dependency Status
babel-plugin-transform-node-env-inline npm Dependency Status
babel-plugin-transform-remove-console npm Dependency Status
babel-plugin-transform-remove-debugger npm Dependency Status

Benchmarks

Running the benchmarks: ./scripts/benchmark.js file.js

Backbone.js:

           raw     raw win gzip   gzip win parse time run
uglify     21.79kB 221%    7.29kB 169%     2ms        379ms
closure    21.67kB 223%    7.37kB 167%     3ms        4083ms
babili     21.62kB 223%    7.4kB  165%     2ms        1072ms
closure js 29.45kB 137%    8.07kB 144%     1ms        5822ms

Run with: ./scripts/benchmark.js ./scripts/fixtures/backbone.js

React:

          raw      raw win gzip    gzip win parse time run
closure    171.46kB 265%    52.97kB 168%     16ms       9481ms
uglify     176.36kB 255%    53.13kB 167%     13ms       1552ms
babili     177.28kB 253%    55.18kB 157%     14ms       4403ms
closure js 229.62kB 173%    58.57kB 142%     14ms       16834ms

Run with: ./scripts/benchmark.js ./scripts/fixtures/react.js

jQuery:

           raw      raw win gzip    gzip win parse time run
uglify     94.27kB  218%    32.78kB 158%     9ms        1388ms
closure    94.23kB  218%    33.38kB 153%     20ms       10805ms
babili     101.52kB 195%    35kB    141%     10ms       6045ms
closure js 135.64kB 121%    37.91kB 123%     10ms       16360ms

Run with: ./scripts/benchmark.js ./scripts/fixtures/jquery.js

babili's People

Contributors

amasad avatar bfred-it avatar boopathi avatar hzoo avatar jamiebuilds avatar kangax avatar sebmck avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.