Code Monkey home page Code Monkey logo

babel-preset-modern-browsers's Introduction

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

babel-preset-modern-browsers's People

Contributors

announcement avatar christophehurpeau avatar dependabot[bot] avatar graingert avatar greenkeeperio-bot avatar plotnikovn avatar renovate[bot] 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

babel-preset-modern-browsers's Issues

object-rest import failing in webpack

object-rest appears to be failing the import for my webpack build. I had a look at the codebase here and couldn't see any issues. So not sure what is going on.

Example of failing code

    loaders: [
      {
        test: /\.js$/,
        include: PATHS.src,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          cacheDirectory: true,
          presets: ['modern-browsers', 'modern-browsers/object-rest', 'react'],
          plugins: [
            'react-hot-loader/babel',
          ],
        },
      },

gives the error

ERROR in ./src/views/collectionItems/collectionItems/CollectionItemsReducer.js
Module build failed: SyntaxError: Unexpected token (61:10)

  59 |       return {
  60 |         collectionItems: {
> 61 |           ...state.collectionItems,
     |           ^
  62 |           [action.payload.id]: action.payload,
  63 |         },
  64 |         defaultOrder: [...state.defaultOrder, action.payload.id],

 @ ./src/views/rootReducer.js 11:30-97

if I update the presets to presets: ['modern-browsers', 'stage-2', 'react'], it works fine.

Any thoughts?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

How to use async functions with this preset?

Previously, I had es2015 and stage-0 presets, which allowed me to use async functions.

But now I'm trying modern-browsers and modern-browsers/safari9 and that results in "unexpected token" errors about the async keyword.

I tried adding the stage-0 preset alongside the modern presets, and that works, but it seems to compile everything the same as with es2015. For example, it compiles class {} syntax down to ES5 classes, but I was thinking that modern-browsers would leave class syntax alone.

Similar to https://github.com/askmatey/babel-preset-modern

This repo seems very similar to @askmatey's https://github.com/askmatey/babel-preset-modern

Eg It looks like the readme was copied and altered.

If so, you need to include this license in this work somewhere:

Copyright (c) 2016 Matej Kieres <[email protected]>

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency eslint-plugin-unicorn to v46
  • chore(deps): lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/push.yml
  • actions/checkout v3
  • actions/setup-node v2
  • actions/cache v3
npm
.yarn/sdks/eslint/package.json
.yarn/sdks/prettier/package.json
package.json
  • @babel/plugin-syntax-numeric-separator ^7.10.4
  • @babel/plugin-transform-modules-commonjs ^7.10.4
  • @babel/core 7.21.3
  • @pob/commitlint-config 5.1.1
  • @pob/eslint-config 40.0.0
  • @pob/eslint-config-node 41.1.2
  • @pob/root 3.3.0
  • @types/jest 26.0.24
  • eslint 7.32.0
  • eslint-import-resolver-node 0.3.7
  • eslint-plugin-import 2.27.5
  • eslint-plugin-node 11.1.0
  • eslint-plugin-prettier 3.4.1
  • eslint-plugin-unicorn 22.0.0
  • husky 4.3.8
  • jest 26.6.3
  • pob-lcov-reporter 4.0.1
  • prettier 2.8.4
  • standard-version 9.5.0
  • @babel/core ^7.10.5
  • node >=10.13.0

  • Check this box to trigger a request for Renovate to run again on this repository

Missing dependencies

In ade31a8 new dependencies were added:

  • babel-plugin-syntax-trailing-function-commas
  • babel-plugin-transform-async-to-generator

However, they are not mentioned in package.json or yarn.lock, causing the 8.1.0 release to fail for users.

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.