Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including better-babel-cli with all npm packages installed. Try it out:

better-babel-cli lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("better-babel-cli/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

better-babel-cli v1.2.3

A better babel command-line utility

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

[sudo] npm uninstall -g babel-cli
[sudo] npm install -g better-babel-cli

Example

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

Makefile:

out/%.js : src/%.jsx
    babel --react --es2015 --object-rest-spread -o $@ -- lt; 

out/%.js : src/%.js
    babel --es2015 -o $@ -- lt; 

Commandline:

babel --verbose --es2015 --stage-0
(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:

babel --transform-es2015-template-literals loose=true,spec=false
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

{
  "plugins": [
    ["transform-es2015-modules-umd", {
      "globals": {
        "es6-promise": "Promise"
      }
    }]
  ]
}

is handled as:

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

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free