babel-preset-node7

Babel preset for Node 7.x

Use https://github.com/babel/babel-preset-env instead.
Last updated 4 years ago by leebenson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-preset-node7 
SYNC missed versions from official npm registry.

Note: DEPRECATED. Please use babel-preset-env instead.

This package is no longer the recommended way to polyfill with Babel. The new best practice is to use babel-preset-env.


Babel 6.x presets for Node 7.x (updated regularly!)

Node 7.x brings ~99% native ES6/ES2015 coverage.

This preset for Babel 6 attempts to bridge the gap for the remaining 1%.

Motivation

Babel 6.x is awesome, but simply including the ES2015 preset means you're transpiling features that your Node 5.x installation can already do faster and natively, replacing them with inferior / old code.

This preset complements existing V8-native functionality - it doesn't work around it.

The end result is nearly always a faster build and script execution time.

Key features:

Usage instructions

Installation

Install via NPM the usual way:

npm i babel-preset-node7

Usage

Via .babelrc (recommended)

Create a .babelrc file in your project root, and include 'node7' in your preset path:

{
  "presets": [
    "node7"
  ]
}

Now whenever you run babel-node, it will polyfill your app with the ES2015 features that Node is missing.

Via CLI

$ babel script.js --presets node7

Via Node API

If you don't want to use a project-wide .babelrc file (as above):

require("babel-core").transform("code", {
  presets: ["node7"]
});

And if you do, and you want to use vanilla node instead of babel-node as your CLI, you can create an entry script that references your pre-transpiled code like so:

require('babel-register');
require('path/to/es6/script');

... which will then run everywhere Node can.

Of course, make sure to npm i -S babel-core or npm i -S babel-register respectively, to grab the NPM packages you'll need to transpile on-the-fly.

Webpack, Gulp, Browserify, etc

Follow vendor instructions and include node7 in your babel "preset" list.

How to add React support

Babel has a ready-made preset for React, and you now need to install it separately.

Just grab it via NPM:

npm i babel-preset-react

And then add it to your "presets" list in .babelrc:

{
  "presets": [
    "node7",
    "react"
  ]
}

How to use async/await

This preset does not ship with async/await transforms, because Node 7.x now supports them natively.

Simply pass the --harmony-async-await flag to Node on start-up.

Current Tags

  • 1.5.0                                ...           latest (4 years ago)

6 Versions

  • 1.5.0 [deprecated]           ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 5
This Month 10
Last Day 1
Last Week 3
Last Month 13
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |