项目作者: ksherlock

项目描述 :
a better babel command-line utility
高级语言: JavaScript
项目地址: git://github.com/ksherlock/better-babel-cli.git
创建时间: 2016-03-04T20:09:19Z
项目社区:https://github.com/ksherlock/better-babel-cli

开源协议:

下载


Better Babel CLI

The babel 6 cli is actively user hostile. They “encourage” you to install it
locally for every project. Installing it globally is a waste of time.

Did I mention a local install of babel-cli and nothing else takes up
39 Megabytes? And that doesn’t even include any of the plugins that
actually make babel useful. Why is that acceptable to anyone?

This is a replacement which includes all the plugins, is global happy,
works great on the command-line and in makefiles, doesn’t require .babelrc
files to configure, and somehow only takes up 20 Megabytes (which is still
excessive but that’s node for you.)

Install

  1. [sudo] npm uninstall -g babel-cli
  2. [sudo] npm install -g better-babel-cli

Example

You can either run it on the command line or put it in your makefile.

Makefile:

  1. out/%.js : src/%.jsx
  2. babel --react --es2015 --object-rest-spread -o $@ -- $<
  3. out/%.js : src/%.js
  4. babel --es2015 -o $@ -- $<

Commandline:

  1. babel --verbose --es2015 --stage-0
  2. (reads stdin, writes to stdout)

Use --preset or --plugin to enable transformations. You can also
use --no-plugin to disable a plugin (if it was part of a preset, for
example.). --foo and --transform-foo are equivalent to
require(babel-plugin-transform-foo).

run babel --help, babel --help-presets, or babel --help-plugins to see
a list of presets and plugins.

Configuration

Some plugins allow configuration options. Run babel --help-config for
details. These may be specified as optional sub-arguments on the command-line.

For example:

  1. babel --transform-es2015-template-literals loose=true,spec=false
  2. babel --transform-es2015-template-literals loose,spec=false

loose is equivalent to loose=true. --loose and --spec set the loose
and spec properties, respectively, for all plugins.

--transform-es2015-modules-umd is a special case. This .babelrc

  1. {
  2. "plugins": [
  3. ["transform-es2015-modules-umd", {
  4. "globals": {
  5. "es6-promise": "Promise"
  6. }
  7. }]
  8. ]
  9. }

is handled as:

  1. babel --transform-es2015-modules-umd es6-promise=Promise,...