Babel presets for modern browsers
JavaScript
Latest commit b609566 Nov 17, 2016 @christophehurpeau 7.0.0

README.md

babel-preset-modern-browsers

NPM Version Edge 14 Firefox 47 Chrome 51 Opera 38 Safari 10

Transpile with babel only for modern browsers.

Installation

npm install --save-dev babel-preset-modern-browsers

Usage

Add the following line to your .babelrc file:

{
  "presets": ["modern-browsers"]
}

Options

  • loose: Enable “loose” transformations for any plugins in this preset that allow them (Disabled by default).
  • modules - Enable transformation of ES6 module syntax to another module type (Enabled by default to "commonjs"). Can be false to not transform modules, or "commonjs"
  • fullSupport - Add support for features below
  • objectRest - Add this if you need object-rest
{
  presets: [
    ["modern-browsers", { "loose": true }]
  ]
}
{
  presets: [
    [require("babel-preset-modern-browsers").buildPreset, { "loose": true }]
  ]
}

Note: to support async functions and other proposals, you can add babel preset stage-X or the stage you want:

{
  "presets": [
    ["modern-browsers", { objectRest: true }], 
    "stage-1"
  ]
}

This preset only covers es2015 and es2016.

Features supported only with full-support

  • default parameters: temporal dead zone, separate scope and new Function() support
  • for...of: iterator closing
  • destructuring: iterator closing, separate scope and new Function() support

More info in the compatibility table below

Features not supported

  • generators: iterator closing on firefox

Compatibility Table

Feature Edge Firefox Chrome Opera Safari

ES2015

Syntax

default parameters, without temporal dead zone, separate scope and new Function() support Edge 14 Firefox 43 Chrome 49 Opera 36 Safari 10
default parameters, with temporal dead zone and separate scope Edge 14 Firefox 51 Chrome 49 Opera 36 Safari 10
default parameters, with new Function() support Edge 14 Firefox None Chrome 49 Opera 36 Safari 10
↳ (objectRest and fullSupport) transform-es2015-parameters
rest parameters Edge 12 Firefox 43 Chrome 47 Opera 34 Safari 10
↳ (objectRest and fullSupport) transform-es2015-parameters
spread Edge 13 Firefox 36 Chrome 46 Opera 33 Safari 10
↳ (unused) transform-es2015-spread
computed properties Edge 12 Firefox 34 Chrome 44 Opera 31 Safari 7.1
↳ (unused) transform-es2015-computed-properties
shorthand properties Edge 12 Firefox 33 Chrome 43 Opera 30 Safari 9
↳ (unused) transform-es2015-shorthand-properties
for...of, without iterator closing Edge 13 Firefox 36 Chrome 39 Opera 26 Safari 10
for...of, with iterator closing Edge 14 Firefox None Chrome 51 Opera 38 Safari 10
↳ (fullSupport) transform-es2015-for-of
template string Edge 13 Firefox 34 Chrome 41 Opera 28 Safari 9
↳ (unused) transform-es2015-template-literals
Regexp sticky Edge 13 Firefox 31 Chrome 49 Opera 36 Safari 10
↳ (unused) transform-es2015-sticky-regex
Regexp unicode Edge 12 Firefox 46 Chrome 51 Opera 38 Safari 10
↳ (unused) transform-es2015-unicode-regex
destructuring, without iterator closing, separate scope, new Function() support Edge 14 Firefox 47 Chrome 49 Opera 36 Safari 10
destructuring, with iterator closing, separate scope, new Function() support Edge None Firefox None Chrome 52 Opera 39 Safari 10
↳ (objectRest and fullSupport) transform-es2015-destructuring
Unicode Strings Edge 12 Firefox 45 Chrome 44 Opera 31 Safari 9
Octal/Binary Numbers Edge 12 Firefox 36 Chrome 41 Opera 28 Safari 9
↳ (unused) transform-es2015-literals

Bindings

const Edge 14 Firefox 51 Chrome 49 Opera 36 Safari 10
let Edge 14 Firefox 51 Chrome 49 Opera 36 Safari 10
↳ (used) transform-es2015-block-scoping
block-level function declaration Edge 11 Firefox 46 Chrome 41 Opera 28 Safari 10
↳ (unused) transform-es2015-block-scoped-functions

Functions

arrow functions Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
↳ (used, needed with function-name) transform-es2015-arrow-functions
classes Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
↳ (unused) transform-es2015-classes
super Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
↳ (unused) transform-es2015-object-super
generators without yield *, iterator closing Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
generators, yield *, iterator closing Edge 13 Firefox None Chrome 51 Opera 38 Safari 10
↳ (unused) transform-regenerator

Built-ins

typeof Symbol Edge 12 Firefox 36 Chrome 38 Opera 25 Safari 9
↳ (unused) transform-es2015-typeof-symbol

Built-in extensions

function name Edge Partial Firefox Partial Chrome 52 Opera 39 Safari 10
↳ (used) transform-es2015-function-name

ES2016

exponentiation operator Edge 14 Firefox 52 Chrome 52 Opera 39 Safari 10
↳ (used) transform-exponentiation-operator

Release Dates

Firefox

Date Version
2016-12-13 50.0.1
2016-11-08 50
2016-09-20 49
2016-08-02 48
2016-06-07 47
2016-04-26 46
2016-03-08 45
2016-01-26 44

Chrome (Desktop release date)

Date Version
2016-12-06? 55
2016-10-12 54
2016-08-31 53
2016-07-20 52
2016-05-25 51
2016-04-13 50
2016-03-02 49

Thanks

Alternatives