✍️ Tracking the status of Babel's implementation of TC39 proposals
Switch branches/tags
Nothing to show
Clone or download
Sven SAULEAU
Sven SAULEAU Merge pull request #36 from rajzshkr/preset-link-fix
preset-env link updated
Latest commit 3fc8ec1 Jan 13, 2018
Permalink
Failed to load latest commit information.
README.md preset-env link updated Jan 13, 2018

README.md

Babel progress on ECMAScript proposals

Official TC39 Proposals Repo

Proposals

For the official list, check the TC39 repo. This list only contains all proposals higher than Stage 0 that are compilable by Babel. (If Stage 4, it will be in preset-env)

Proposal Link Current Stage Status
Rest/Spread Properties 3 3
Asynchronous Iteration 3 3
Dynamic Import 3 3
RegExp Unicode Property Escapes 3 3
RegExp Named Capture Groups 3 3
RegExp DotAll Flag 3 3
Class Fields 3 2
function.sent 2 2
Class and Property Decorators 2 1
BigInt 2 Parsable
import.meta 2 Parsable
export * as ns from "mod"; 1 1
export v from "mod"; 1 1
Generator Arrow Functions 1 N/A
Optional Chaining 1 1
do Expressions 1 1
Numeric Separator 1 1
Function Bind 0 0
Pattern matching 0 0

Implemented

Rest/Spread Properties

TC39 Champion: Sebastian Markbage
Preset: babel-preset-stage-3
Plugin: babel-plugin-transform-object-rest-spread
Babylon Label: Spec: Object Rest/Spread

Code Example
// Rest properties
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
console.log(x); // 1
console.log(y); // 2
console.log(z); // { a: 3, b: 4 }

// Spread properties
let n = { x, y, ...z };
console.log(n); // { x: 1, y: 2, a: 3, b: 4 }

Asynchronous Iteration

TC39 Champion: Domenic Denicola
Preset: babel-preset-stage-3
Plugin: babel-plugin-transform-async-generator-functions

Code Example
async function* agf() {
  await 1;
  yield 2;
}

async function f() {
  for await (let x of y) {
    g(x);
  }
}

Dynamic Import

TC39 Champion: Domenic Denicola
Preset: babel-preset-stage-3
Plugins: babel-plugin-syntax-dynamic-import

Webpack 1: https://github.com/airbnb/babel-plugin-dynamic-import-webpack
Webpack 2: supports this by default (just needs Babel to parse)
Node: https://www.npmjs.com/package/babel-plugin-dynamic-import-node

Code Example
import('test-module').then(() => (
  import('test-module-2');
));

RegExp Unicode Property Escapes

TC39 Champion: Brian Terlson, Daniel Ehrenberg, Mathias Bynens
Preset: babel-preset-stage-3
Plugins: babel-plugin-transform-unicode-property-regex

Code Example
const a = /^\p{Decimal_Number}+$/u;
const b = /\p{Script_Extensions=Greek}/u;

RegExp Named Capture Groups

TC39 Champion: Daniel Ehrenberg, Brian Terlson
Preset: N/A
Plugins: babel-plugin-transform-modern-regexp (with namedCapturingGroups flag)

Code Example
let re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u;

let result = re.exec('2015-01-02');
// result.groups.year === '2015';
// result.groups.month === '01';
// result.groups.day === '02';

// result[0] === '2015-01-02';
// result[1] === '2015';
// result[2] === '01';
// result[3] === '02';

Regexp DotAll Flag

TC39 Champion: Daniel Ehrenberg, Jeff Morrison Preset: N/A
Plugins: babel-plugin-transform-dotall-regex, babel-plugin-transform-modern-regexp (with dotAll flag)

Code Example
/./s; // /[\0-\uFFFF]/;

Class Fields

TC39 Champion: Daniel Ehrenberg, Jeff Morrison

Stage 2

Preset: WIP
Plugins: WIP
First Pull Request: babel/babylon#608 by @diervo
Babylon Label: Spec: Class Fields

Stage 1

Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-class-properties

Code Example
class Bork {
  instanceProperty = "bork";
  boundFunction = () => {
    return this.instanceProperty;
  }

  static staticProperty = "babelIsCool";
  static staticFunction = function() {
    return Bork.staticProperty;
  }
}

Class and Property Decorators

TC39 Champion: Yehuda Katz and Brian Terlson

Stage 2

Preset: WIP
Plugins: WIP

Stage 1

Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-decorators, babel-plugin-transform-decorators-legacy
First Pull Request: babel/babylon#587 by @peey
Babylon Label: Spec: Decorators

Code Example
@frozen class Foo {
  @configurable(false) @enumerable(true) method() {}
}
function frozen(constructor, parent, elements) {
  return {
    constructor,
    elements,
    finisher(constructor) {
      Object.freeze(constructor.prototype)
      Object.freeze(constructor)
    }
  }
}
function configurable(configurable) {
  return decorator;
  function decorator(previousDescriptor) {
    return {
      ...previousDescriptor,
      descriptor: {
        ...previousDescriptor.descriptor,
        configurable
      }
    }
  }
}
function enumerable(enumerable) {
  return decorator;
  function decorator(previousDescriptor) {
    return {
      ...previousDescriptor,
      descriptor: {
        ...previousDescriptor.descriptor,
        enumerable
      }
    }
  }
}

Export Extensions

This proposal was split into 2:
https://github.com/tc39/proposal-export-ns-from
https://github.com/tc39/ecmascript-export-default-from

TC39 Champion: Lee Byron
Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-export-extensions

Code Example
export * as ns from 'mod'; // export-ns-from
export v from 'mod'; // export default from

Optional Chaining

TC39 Champion: Gabriel Isenberg
Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-optional-chaining

Code Example
obj?.prop       // optional property access
obj?.[expr]     // optional property access
func?.(...args) // optional function or method call

a?.b = 42; // a == null ? undefined : a.b = 42;

do Expressions

TC39 Champion: Dave Herman
Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-do-expressions

Code Example
let a = do {
  if (x > 10) {
    'big';
  } else {
    'small';
  }
};

// let a = x > 10 ? 'big' : 'small';

Numeric Separator

TC39 Champion: Sam Goto
Preset: babel-preset-stage-1
Plugins: babel-plugin-transform-numeric-separator
First Pull Request: babel/babylon#541 by @rwaldron
Babylon Label: Spec: Numeric Separator

Code Example
// Decimal Literals
let budget = 1_000_000_000_000;
// Binary Literals
let nibbles = 0b1010_0001_1000_0101;
// Hex Literal
let message = 0xA0_B0_C0;

Function Bind

TC39 Champion: Brian Terlson & Matthew Podwysocki
Preset: babel-preset-stage-0
Plugins: babel-plugin-transform-function-bind

Code Example
obj::func
// is equivalent to:
func.bind(obj)

obj::func(val)
// is equivalent to:
func.call(obj, val)

::obj.func(val)
// is equivalent to:
func.call(obj, val)

function.sent

TC39 Champion: Allen Wirfs-Brock
Preset: babel-preset-stage-2
Plugins: babel-plugin-transform-function-sent

Code Example
function* generator() {
  console.log("Sent", function.sent);
  console.log("Yield", yield);
}

const iterator = generator();
iterator.next(1); // Logs "Sent 1"
iterator.next(2); // Logs "Yield 2"

Parser Only

BigInt

TC39 Champion: Daniel Ehrenberg
Preset: WIP
Plugins: WIP
First Pull Request: babel/babylon#588 by @wdhorton
Babylon Label: Spec: BigInt

Code Example
1n // integer
0b101n // binary
0xFF123n // hex
0o16432n // octal
9223372036854775807n // larger than floating
Invalid Example
// Invalid
1.0n // no decimals
2e9n // no exponential notation
016n // no old octal

import.meta

TC39 Champion: Domenic Denicola
Preset: babel-preset-stage-2
Plugins: babel-plugin-syntax-import-meta
First Pull Request: babel/babylon#544 by @jkrems
Babylon Label: Spec: import.meta

Code Example
import.meta.url;
import.meta.scriptElement.dataset.size;

Not Implemented

Pattern Matching

TC39 Champion: Brian Terlson (Microsoft, @bterlson), Sebastian Markbåge (Facebook, @sebmarkbage)
Preset: WIP
Plugins: WIP
Babylon Label: Spec: pattern matching
First Pull Request: babel/babylon#635 by @krzkaczor

Code Example
let length = vector => match (vector) {
    { x, y, z }: Math.sqrt(x ** 2 + y ** 2 + z ** 2),
    { x, y }:   Math.sqrt(x ** 2 + y ** 2),
    [...]:      vector.length,
    else: {
        throw new Error("Unknown vector type");
    }
}
let isVerbose = config => match (config) {
    { output: { verbose: true } }: true,
    else: false
}

let outOfBoundsPoint = p => match (p) {
    { x > 100, y }: true,
    { x, y > 100 }: true,
    else: false
}

Generator Arrow Functions

TC39 Champion: Brendan Eich, Domenic Denicola
Preset: N/A
Plugins: N/A

Code Example
()=>*{}

FAQ

When does Babel implement new features?

Babel will accept any PR for a proposal that is intended to go through the TC39 Proposal Process. This just means that we could implement and release a proposal starting at Stage 0. However this doesn't mean that we will implement it ourselves, but that we will work with both TC39 Champions and the community to get an implementation in. (And sometimes we have to wait for Summer of Code for that to happen).

It's our intention (and one of our main goals) as a project to help TC39 get feedback from the community through using the new syntax in their codebases. There is however a balance between supporting new proposals and informing users that any proposal is still just a proposal and subject to change. In order to move the community forward, we will continously make changes to adhere to the spec as patches. If bigger changes require a major version, we will deprecate older versions of plugins, document those changes, and see if we can automate the upgrade via a codemod. This way everyone is moving towards Stage 4 and closer to what will be in the spec if the proposal makes it to the end.

This means we will also include proposals in this repo that haven't been presented to the committee yet if they are concrete enough and someone on TC39 is planning on presenting it (and marked appropriately).