Giter Club home page Giter Club logo

proposals's Introduction

Babel progress on ECMAScript proposals

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
Dynamic Import 4 3
RegExp Unicode Property Escapes 4 3
RegExp Named Capture Groups 4 3
RegExp DotAll Flag 4 3
Class Fields 3 2
function.sent 2 2
Class and Property Decorators 2 1
BigInt 4 Parsable
import.meta 3 Parsable
export * as ns from "mod"; 4 1
export v from "mod"; 1 1
Generator Arrow Functions 1 N/A
Optional Chaining 4 1
do Expressions 1 1
Numeric Separator 3 1
Function Bind 0 0
Pattern matching 1 0

Implemented

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');
));

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;

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';

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]/;

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;
  }
}

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

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;

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';

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;

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)

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

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

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

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
const length = vector => {
  case (vector) {
    when { x, y, z } -> return Math.sqrt(x ** 2 + y ** 2 + z ** 2)
    when { x, y } ->   return Math.sqrt(x ** 2 + y ** 2)
    when [...etc] ->     return vector.length
  }
}
const isVerbose = config => {
   case (config) {
    when {output: { verbose: true }} -> return true
    when config -> return false
    }
}
const res = await fetch(jsonService)
case (res) {
  when {status: 200, headers: {'Content-Length': s}} ->
    console.log(`size is ${s}`)
  when {status: 404} ->
    console.log('JSON not found')
  when {status} if (status >= 400) -> {
    throw new RequestError(res)
  }
}

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 continuously 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).

proposals's People

Contributors

chicoxyzzy avatar dnalborczyk avatar existentialism avatar hzoo avatar kielan avatar n1ru4l avatar otomakan avatar rajasekarm avatar sarupbanskota avatar sidntrivedi012 avatar xtuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

proposals's Issues

Nov 2017

Airbnb: San Francisco, CA (Nov 28-30)
https://github.com/tc39/agendas/blob/master/2017/11.md

Checkbox means we completed it (some Stage 1 we may want to wait to start, given instability of the proposal)
https://tc39.github.io/process-document/ for a primer what each Stage means

Meeting notes: https://github.com/rwaldron/tc39-notes/tree/master/es8/2017-11

New Proposals

  • HashBang Directive (#! node foo) to Stage 1
  • Object.freeze + Object.seal syntax to Stage 1
  • Block Params to Stage 1

Moving Forward

  • Numeric Separators (1_000) from Stage 2 to Stage 3
  • RegExp dotAll to Stage 4
  • RegExp named captures to Stage 4
  • Class Fields split into class instance fields and private instance methods to Stage 3
    • so class A { a = 1; #b = c; #a() {} }

Needs Consensus (Stage 4)

Needs Spec Work

  • Class Fields split public + private static fields and private static methods to Stage 2
    • so class A { static a = 1; static #b = c; static #a() {} }

Other (Builtins, etc)

  • Array.prototype.flatten to Stage 3
  • Array.prototype.flatMap to Stage 3
  • String.prototype.replaceAll to Stage 1
  • Subsume JSON to Stage 2
  • String.prototype.codePoints to Stage 1
  • Distinguishing literal strings to Stage 1

Sept 2017

Bocoup, Boston, MA (Sept 26-28)
https://github.com/tc39/agendas/blob/master/2017/09.md

Checkbox means we completed it (some Stage 1 we may want to wait to start given instability of the proposal)
https://tc39.github.io/process-document/ for a primer what each Stage means

New Proposals

Moving Foward

Needs Consensus (Stage 4)

Needs Spec Work

Other (Builtins, etc)

July 2017

Just summarizing the updates from: https://github.com/tc39/agendas/blob/master/2017/07.md

Can discuss changes as they pertain to Babel implementation (syntax).
babel-polyfill implementation is https://github.com/zloirock/core-js

EDIT: made some issues for Babel updates

New Proposals

Moving Forward

Needs work

Partial Application: Stage 1

Champion: @rbuckton
Repo: https://github.com/rbuckton/proposal-partial-application
Slides: https://docs.google.com/presentation/d/1GSnqtT1jHbilIAwCuaK2yjKNj0y6cLfJNisZDig3Nm8/edit?usp=sharing
First presented at the Sept 2017 meeting

Example

const addOne = add(1, ?); // apply from the left
addOne(2); // 3

const addTen = add(?, 10); // apply from the right
addTen(2); // 12

// with pipeline
let newScore = player.score
  |> add(7, ?)
  |> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.

const maxGreaterThanZero = Math.max(0, ...);
maxGreaterThanZero(1, 2); // 2
maxGreaterThanZero(-1, -2); // 0

Syntax

f(x, ?)           // partial application from left
f(x, ...)         // partial application from left with rest
f(?, x)           // partial application from right
f(..., x)         // partial application from right with rest
f(?, x, ?)        // partial application for any arg
f(..., x, ...)    // partial application for any arg with rest

Optional Chaining Operator (Stage 1)

Pipeline Operator (Stage 1)

Champion: @littledan
Spec Repo: https://github.com/tc39/proposal-pipeline-operator
First presented at Sept 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/09.md
Slides: https://docs.google.com/presentation/d/1qiWFzi5dkjuUVGcFXwypuQbEbZk-BV7unX0bYurcQsA/edit#slide=id.p
Related proposal: Partial Application https://github.com/rbuckton/proposal-partial-application by @rbuckton
Related proposal: Function Bind Operator https://github.com/tc39/proposal-bind-operator

Basic Example

Input

let result = "hello"
  |> doubleSay
  |> capitalize
  |> exclaim;
result //=> "Hello, hello!"

Output

let result = exclaim(capitalize(doubleSay("hello")));
result //=> "Hello, hello!"

Initial Implementation (would need updating to v7)

Old/Alternative Implementations

cc @gilbert, @SuperPaintman

Implementation

Private Methods (and accessors) (Stage 3)

Champions: Daniel Ehrenberg @littledan
Spec Repo: https://github.com/littledan/proposal-private-methods
First presented at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md
Moved to Stage 3 at the Sept 2017 meeting: https://docs.google.com/presentation/d/1aI89Jgl7CdtKV6D5-ydieUn_-kgRqAD2X8gGzh62xzc/edit#slide=id.p

Example:

class Counter extends HTMLElement {
  #xValue = 0;

  get #x() { return this.#xValue; }
  set #x(value) {
    this.#xValue = value; 
    window.requestAnimationFrame(
      this.#render.bind(this));
  }

  #clicked() {
    this.#x++;
  }
}

Implementation

Private Static Methods (Stage 3)

Info

Proposal Status: Stage 3 @ May 2018 TC39 meeting
Meeting Slides: Status Class Features
Proposal Repo: tc39/proposal-static-class-features

Article on class features subject by @syg: "The Semantics of All JS Class Elements"

Prior Work:

Example

class Account {
   // ...
  static #makeTransaction(dollars, from, to) {
    Account.#transactions = this.#transactions.concat(/* ... */);
  }
  
  transfer(dollars, targetAccount) {
    return Account.#makeTransaction(dollars, this, targetAccount);
  }
}

cc @robpalme @littledan @nicolo-ribaudo

Numeric Separator (Stage 3)

Champions: Sam Goto (@samuelgoto), Rick Waldron (@rwaldron)
Spec Repo: https://github.com/tc39/proposal-numeric-separator
Moved to Stage 1 at the May 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/05.md
Moved from Stage 1 to Stage 2 at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md
Moved to Stage 3 at the Nov 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/11.md
Update at May 2018 meeting: https://github.com/tc39/agendas/blob/master/2018/05.md

Syntax

let budget = 1_000_000_000_000;
let nibbles = 0b1010_0001_1000_0101;
let message = 0xA0_B0_C0;

Implementation

[Meta] Should ECMA262 pull requests be listed here or just as issues on the main repository?

Because not everything put through TC39 goes through the proposal process there should probably be some tracking of the so called "Needs consensus PRs". It's probably not worth tracking the many ones that are pending or didn't achieve consensus in Babel but any that have achieved consensus should almost certainly be tracked in Babel.

Here's a short list of some of the recent consensus-achieved PRs and their status in Babel:

PR Babel Status Notes
#785 Fixed (in polyfill)
#833 Not fixed Fixable if Proxy itself is already available
#984 Not fixed Still a runtime early but should be early error in Babylon
#988 / #1021 Not fixed
#890 Not fixed
#1005 Fixed Already a babel transform

Throw Expressions (Stage 2)

Champions: Ron Buckton (@rbuckton)
Spec Repo: https://github.com/rbuckton/proposal-throw-expressions
First presented at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md
Stage 1 to Stage 2 at Sept 2017 meeting

Examples:

function save(filename = throw new TypeError("Argument required")) {}
lint(ast, { 
  with: () => throw new Error("avoid using 'with' statements.")
});
function getEncoder(encoding) {
  const encoder = encoding === "utf8" ? new UTF8Encoder() 
                : encoding === "utf16le" ? new UTF16Encoder(false) 
                : encoding === "utf16be" ? new UTF16Encoder(true) 
                : throw new Error("Unsupported encoding");
}
class Product {
  get id() { return this._id; }
  set id(value) { this._id = value || throw new Error("Invalid value"); }
}

Implementation

Pattern Matching (Stage 0)

Original issue submitted by @xtuc in babel/babylon#610

This issue is to keep track of the implementation in the parser of this proposal.

Champions: Brian Terlson (Microsoft, @bterlson), Sebastian Markbåge (Facebook, @sebmarkbage)
Spec Repo: https://github.com/tc39/proposal-pattern-matching

tc39/proposals#56

Remember that proposals are just that; subject to change until Stage 4!

Examples

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
}

You can find more example in the spec repo.

Parsing

https://github.com/babel/babylon/blob/master/CONTRIBUTING.md#creating-a-new-plugin-spec-new

  • Babylon plugin: patternMatching

Transform

  • Babel plugin

Class Fields (Stage 3)

Original issue submitted by @babel-bot in babel/babel#4408

Champions: @jeffmo (public class fields) @littledan (private + combined)
Spec Repo: https://github.com/tc39/proposal-class-fields
Spec Text: https://tc39.github.io/proposal-class-fields/
Slides: https://drive.google.com/file/d/0B-TAClBGyqSxWHpyYmg2UnRHc28/view

Moved to Stage 3 at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md (https://twitter.com/lbljeffmo/status/890679542007738368)

Examples

class C {
  static x = 1, #y, [a];
  z, #w = 2, [b];
  
  a() {
    this.z;
    this.#w++;
    #w; // #w is this.#w
  }
}

Parsing/ESTree

  • AST handled already in current classProperties and classPrivateProperties.
  • May need to rename though (new plugin name).
  • make sure no "private computed" parse
  • need to support comma separated properties.

Transform

  • combine the class-properties plugin + tbd private properties one

Contacts

BigInt (Stage 3)

Champion: @littledan
Spec Repo: https://github.com/tc39/proposal-bigint
Spec Text: https://tc39.github.io/proposal-bigint
Slides (to Stage 3 at May TC39 Meeting): https://docs.google.com/presentation/d/1lrcjQzIFgdUXczeeAzs4GkTXJsRQU21UhtmXef70Qic/edit#slide=id.p

moved to Stage 3 at July TC39 Meeting https://github.com/tc39/agendas/blob/master/2017/07.md

The syntax has been implemented in Babylon, see babel/babylon#569 (comment) . What remains is a plugin to implement the transform.

  • All arithmetic operations and comparisons should be replaced by calls to functions which provide the appropriate behavior depending whether arguments are BigInts or Numbers.
    • The transform is slow, so it will really be more of a toy rather than something that should be used in production. For this reason, I'd argue it should be left out of Babel presets.
  • Polyfill needed--ideally, this would be a thin wrapper around another BigNum library from npm. There are just a few methods to support. Some functions will have to be a bit different to get close to the right behavior, for example, valueOf() should throw a TypeError, so that implicitly casting to Number throws a TypeError, even if it would really return the BigInt. Additionally, the polyfill needs BigInt64Array and DataView operations.
  • A good starting point from @amilajack:

I've done some work on this in a babel plugin that prevents coercion in JS. Here's the related code for that

How to represent things which have not yet been presented to the committee?

There are a number of spec proposals which are pretty well written out, and eagerly awaited, which have not yet been presented to TC39. Pattern matching is one of them, and it's included here. I'm working on a private methods proposal which is in a similar state, but it's not represented.

I see a few possible policies here:

  • Don't include proposals here until they're presented at TC39 (I thought this was Babel policy)
  • Add unpresented proposals when they seem significant enough/have strong user demand (what this page seems to be following)
    • Here, it might be nice to mark the stage distinctly, such as "unpresented" rather than 0.
  • Permit any concrete-enough proposal, also marked as unpresented.
    • This could/should also include proposals which are not by TC39 members, for example pipeline
    • These are "pre-stage-0"--not even presented to the committee for basic feedback, I'd suggest leaving them out of the stage 0 preset.

Nullish Coalescing (Stage 3)

Champions: @gisenberg
Spec Repo: https://github.com/gisenberg/proposal-nullary-coalescing
First presented at the July 2017 meeting: slides
Moved to Stage 1 at the Sept 2017 meeting: slides

Syntax

a ?? b

When performing optional property access in a nested structure in conjunction with the optional chaining operator, it is often desired to provide a default value if the result of that property access is null or undefined. At present, a typical way to express this intent in JavaScript is by using the || operator.

so most use const variable = a || b but a falsy value like 0 or '' or false will unintentionally return b as the value.

Notes:

While this proposal specifically calls out null and undefined values, the intent is to provide a complementary operator to the optional chaining operator. This proposal will update to match the semantics of that operator.

Parsing

  • a new node type name (operator)?
  • pluginName?

https://twitter.com/littledan/status/908032146484469761
https://github.com/babel/babylon/pull/742/files#r142008197

import.meta: (Stage 3)

Original issue submitted by @hzoo in babel/babel#5832

Original issue submitted by @hzoo in babel/babylon#539

import.meta for stage 2 (Domenic Denicola) (@domenic)

Info

Proposed at TC39 Meeting: May 2017
Spec Repo: https://github.com/tc39/proposal-import-meta
Spec Text: https://tc39.github.io/proposal-import-meta/
Moved to Stage 3 at the Sept 2017 meeting

Example

(async () => {
  const response = await fetch(new URL("../hamsters.jpg", import.meta.url));
  const blob = await response.blob();

  const size = import.meta.scriptElement.dataset.size || 300;

  const image = new Image();
  image.src = URL.createObjectURL(blob);
  image.width = image.height = size;

  document.body.appendChild(image);
})();

Parsing

Transform

  • Not sure, maybe webpack should handle? Or in node?

First Class Protocols: Stage 1

Champion: @michaelficarra
Repo: https://github.com/michaelficarra/proposal-first-class-protocols
Slides: https://docs.google.com/presentation/d/1WrvSyslnF-5VnPj3k3HRq8MRzuiSN1kQ6ENE1iUSmDU/edit?usp=sharing
First presented at the Sept 2017 meeting

Example

protocol ProtocolName {
  // declare a symbol which must be implemented
  thisMustBeImplemented;

  // and some methods that you get for free by implementing this protocol
  youGetThisMethodForFree(...parameters) {
      methodBody;
  }
}

class ClassName implements ProtocolName {
  [ProtocolName.thisMustBeImplemented]() {
    // this is the implementation for this class
  }
}

let instance = new ClassName;
instance[ProtocolName.youGetThisMethodForFree]();

Implementation

Binary AST (Stage 1)

Champions: @syg, @vdjeric, @Yoric, @kannan-vijayan
Spec Repo: https://github.com/syg/ecmascript-binary-ast/
First presented at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md

Why is this relevant

Babel operates on an AST, and would be part of the toolchain that should be able to take advantage of this format. This would help consolidate tooling to use the same AST. Would be a breaking change, unless our AST is adopted (unlikely, and probably not desired).

Status Fields

Status: Not started, In development, Completed
Owner/Champion (for Babel implementation)

  • link to the tracking issue, initial PR, create a github label for the spec to track issues/prs for interested parties, add TC39 champion to TC39 team in the Babel Org

  • link to transform/parser plugin name, preset, first release, etc

Subsume JSON strings (Stage 4)

By @gibson042, champion: @mathiasbynens

Presented as Stage 1 at Sept 2017
Moved to Stage 2 at Nov 2017
Moved to Stage 3 at Jan 2018
Moved to Stage 4 at May 2018

Spec repo: https://github.com/tc39/proposal-json-superset

ECMAScript claims JSON as a subset in JSON.parse, but (as has been well-documented) that is not true because JSON strings can contain unescaped U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR characters while ECMAScript strings cannot.

-[x] Babel PR by @jridgewell: babel/babel#7985

Optional Catch Binding (Stage 4)

Champion: @michaelficarra
Spec repo: https://github.com/michaelficarra/optional-catch-binding-proposal/
Spec text: https://michaelficarra.github.io/optional-catch-binding-proposal/
Stage: -1 :)

Moved to Stage 3 at the July meeting https://github.com/tc39/agendas/blob/master/2017/07.md

Stage 4 at May 2018 meeting

This hasn't been presented to the committee as of this writing, but will be at the July meeting. If it receives broad support it is likely to advance quickly, in my personal estimation.

It allows the binding to be omitted from a catch clause:

try {
  throw 0;
} catch {
  doSomethingWhichDoesntCareAboutTheValueThrown();
}

or

try {
  throw 0;
} catch {
  doSomethingWhichDoesntCareAboutTheValueThrown();
} finally {
  doSomeCleanup();
}

This will need a (very small) change in Babylon, including a change to the AST (marking the catch binding as optional), and then a very small change to Babel.

This would make a great first contribution, I think!

UPDATE:

Regex named capture groups

Named capture groups are being merged in the main spec (tc39/ecma262#1027).
We need a plugin for that 🙂

There is already https://www.npmjs.com/package/babel-plugin-transform-modern-regexp, but it does a lot of things. I think we should have a plugin which only transforms named groups (like we have for every other regexp feature).

It would consist in two parts:

  1. The pattern transpiler
    e.g. (?<name>.)\k<name> -> (.)\1
    We have two options for this: regexp-tree and regexpu-core.
    I would prefer using regexpu-core, because:

    • we already use it, so it wouldn't add a new dependency to babel
    • regexp-tree parses by default some non standard featues (like comments in patterns)

    On the other hand, it would require some more time because first I need to implement named groups in regexpu-core. The plugin might not be ready before the proposal is merged into the spec.

  2. The runtime wrapper
    This is needed to add the groups property to the result of .match/.exec/.replace.
    I think the implementation which gives best browser support requires overwriting RegExp#exec and String#replace.
    Another option which doesn't requires modifying builtins is to use a class like this:

    class BabelRegExp extends RegExp {
      exec() { /* overwrite */ }
      [Symbol.replace]() { /* overwrite */ }
    }

    This would be self-contained, but it wouldn't work in IE <= 10 or other browsers without __proto__.

@babel/babel Thoughts? (especially about regexp-tree vs regexpu-core)

cc @mathiasbynens

July 2018

Microsoft: Redmond, WA (July 24-26)
https://github.com/tc39/agendas/blob/master/2018/07.md

Checkbox means we completed it (some Stage 1 we may want to wait to start given instability of the proposal)
https://tc39.github.io/process-document/ for a primer what each Stage means

New Syntax Proposals

Existing Syntax Proposals

Other (Builtins, etc)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.