Skip to content

Instantly share code, notes, and snippets.

@kukiron
Forked from xtuc/UPGRADE-7.0.md
Created January 13, 2018 20:51
Show Gist options
  • Save kukiron/7b9344dc60796d68d5941ca300bdb317 to your computer and use it in GitHub Desktop.
Save kukiron/7b9344dc60796d68d5941ca300bdb317 to your computer and use it in GitHub Desktop.
Upgrade guide for Babel 7

UPGRADE FROM 6.x to 7.0

Table of Contents

TODO

babel

Support for Node.js 0.10 and 0.12 has been dropped

We highly encourage you to use a newer version of Node.js since these versions are in end of maintenance.

Yarn

Along npm Babel supports Yarn. See Yarn's documentation on how to use it.

babylon

Trailing comma after rest parameter in objects is not allowed anymore

Before:

var { ...y, } = { a: 1};

This will now throw a SyntaxError.

After:

var { ...y } = { a: 1};

or:

var { ...y, b } = { a: 1};

babel-core

babel-core/register.js has been removed

Relying on babel-core/register is deprecated and will be removed in Babel 7.

Upgrade with Mocha:

mocha --compilers js:babel-core/register

to:

mocha --compilers js:babel-register

We need to add babel-register as a new dependecy:

npm install --save-dev babel-register

See babel-register documentation for more informations.

babel-preset-stage-3

babel-plugin-syntax-trailing-function-commas, babel-plugin-transform-async-to-generator and babel-plugin-transform-exponentiation-operator are moved into babel-preset-stage-4.

Babel recently created babel-preset-env which based on your environment use the right presets. If you have issue with this changes we suggest you using the env preset.

babel-plugin-transform-exponentiation-operator has been removed from this preset

Example:

let cubed = 2 ** 3;

If you rely on this syntax, we suggest you using rather the env preset.

babel-plugin-syntax-class-constructor-call

babel-plugin-syntax-class-constructor-call has been removed

TC39 decided to drop this proposal.

Before:

class Point {

  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  call constructor(x, y) {
    return new Point(x, y);
  }

}

let p1 = new Point(1, 2);
let p2 = Point(3, 4);

You can move your logic into the constructor or into a static method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment