Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

christophehurpeau/babel-preset-modern-browsers

Repository files navigation

babel-preset-modern-browsers

Babel presets for modern browsers

DEPRECATED

Use @babel/preset-env instead with configured browserslists:

package.json

{
  "browserslist": {
    "modern": [
      "defaults and supports es6-module"
    ]
  },
}

babel.config.json

{
-  "presets": ["modern-browsers"]
+  "presets": [["@babel/preset-env", {
+      "shippedProposals": true,
+      "bugfixes": true,
+      "browserslistEnv": "modern"
+    }]]
}

https://babeljs.io/docs/babel-preset-env

Legacy README

This preset covers syntax of es2015, es2016, es2017, es2018, es2019 and es2020.

More info in the compatibility table below

babel 7

Since v12, this package requires @babel/[email protected]. If you use babel 6, you can still use the version "11.0.1" of this package. If you want to migrate, you can read the announcement and the official migration guide.

Alternatives

If you don't need preset-env, using this package will only install a few dependencies.

Modern browsers

Edge 83 Firefox 78 Chrome 80 Opera 67 Safari 13.1

Installation

npm install --save-dev babel-preset-modern-browsers @babel/core

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"
  • shippedProposals - Enable features in stages but already available in browsers (Enabled by default)
{
  presets: [['modern-browsers', { loose: true }]];
}
{
  presets: [[require('babel-preset-modern-browsers'), { loose: true }]];
}

Browserlist

Edge >= 83, Firefox >= 78, FirefoxAndroid  >= 78, Chrome >= 80, ChromeAndroid >= 80, Opera >= 67, OperaMobile >= 67, Safari >= 13.1, iOS >= 13.4

Compatibility Table

Feature Edge Firefox Chrome Opera Safari

Shipped Proposals

Numeric Separators Edge 79 Firefox 70 Chrome 75 Opera 62 Safari 13
syntax-numeric-separator

ES2020

Optional chaining (?.) Edge 80 Firefox 74 Chrome 80 Opera 67 Safari 13.1
Nullish Coalescing operator (??) Edge 80 Firefox 72 Chrome 80 Opera 67 Safari 13.1

ES2019

Optional catch binding Edge 79 Firefox 58 Chrome 66 Opera 53 Safari 11.1
JSON strings Edge 79 Firefox 62 Chrome 66 Opera 53 Safari 12

ES2018

Object Rest/Spread Properties Edge 79 Firefox 55 Chrome 60 Opera 47 Safari 11.1
RegExp Unicode Property Escapes Edge 79 Firefox 78 Chrome 64 Opera 51 Safari 11.1
Asynchronous Iterators Edge 79 Firefox 57 Chrome 63 Opera 50 Safari 12

ES2017

trailing commas in function Edge 14 Firefox 52 Chrome 58 Opera 45 Safari 10
async function Edge 15 Firefox 52 Chrome 55 Opera 42 Safari 10.1

ES2016

exponentiation operator Edge 14 Firefox 52 Chrome 52 Opera 39 Safari 10

ES2015

Edge 79 Firefox 53 Chrome 52 Opera 39 Safari 10

Syntax

default parameters Edge 14 Firefox 53 Chrome 49 Opera 36 Safari 10
rest parameters Edge 12 Firefox 43 Chrome 47 Opera 34 Safari 10
spread Edge 13 Firefox 36 Chrome 46 Opera 33 Safari 10
computed properties Edge 12 Firefox 34 Chrome 44 Opera 31 Safari 7.1
shorthand properties Edge 12 Firefox 33 Chrome 43 Opera 30 Safari 9
for...of Edge 14 Firefox 53 Chrome 51 Opera 38 Safari 10
template string Edge 13 Firefox 34 Chrome 41 Opera 28 Safari 9
Regexp sticky Edge 13 Firefox 31 Chrome 49 Opera 36 Safari 10
Regexp unicode Edge 12 Firefox 46 Chrome 51 Opera 38 Safari 10
destructuring Edge 15 Firefox 53 Chrome 52 Opera 39 Safari 10
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

Bindings

const Edge 14 Firefox 51 Chrome 49 Opera 36 Safari 10
let Edge 14 Firefox 51 Chrome 49 Opera 36 Safari 10
block-level function declaration Edge 11 Firefox 46 Chrome 41 Opera 28 Safari 10

Functions

arrow functions Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
classes Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
super Edge 13 Firefox 45 Chrome 49 Opera 36 Safari 10
generators Edge 13 Firefox 53 Chrome 51 Opera 38 Safari 10

Built-ins

typeof Symbol Edge 12 Firefox 36 Chrome 38 Opera 25 Safari 9

Built-in extensions

function name Edge 79 Firefox 53 Chrome 52 Opera 39 Safari 10

Partially Shipped Proposals (Not included)

Feature Edge Firefox Chrome Opera Safari
Static & Instance Class Fields Edge 79 Firefox None Chrome 74 Opera 61 Safari None
proposal-class-properties
Private Class Methods Edge 84 Firefox None Chrome 84 Opera 71 Safari None
proposal-private-methods

Release Dates

Thanks

About

Babel presets for modern browsers

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published