Skip to content
This repository was archived by the owner on May 11, 2018. It is now read-only.
/ babel-preset-env Public archive

v1.0.0

Compare
Choose a tag to compare
@hzoo hzoo released this 09 Dec 20:52
· 230 commits to 1.x since this release

v1.0.0 (2016-12-09)

🚀 New Feature

A way to apply babel-preset-env for polyfills (via `"babel-polyfill"``).

This option will apply a new Babel plugin that replaces require("babel-polyfill") with the individual requires for babel-polyfill based on the target environments.

Install

npm install babel-polyfill --save

In

import "babel-polyfill"; // create an entry js file that contains this
// or 
import "core-js";

Out (different based on environment)

// chrome 55
import "core-js/modules/es7.string.pad-start"; // haha left_pad
import "core-js/modules/es7.string.pad-end";
import "core-js/modules/web.timers";
import "core-js/modules/web.immediate";
import "core-js/modules/web.dom.iterable";

.babelrc Usage

{
  "presets": [
    ["env", {
      "targets": {
        "electron": 1.4
      },
      "modules": false, // webpack 2
      "useBuiltIns": true // new option
    }]
  ]
}

Also looking to make an easier integration point via Webpack with this method. Please reach out if you have ideas!


Electron is also an environment, so Paul went ahead and added support for this!

.babelrc Usage

{
  "presets": [ ["env", {"targets": { "electron": 1.4 }}]]
}

Currently we are manually updating the data in /data/electronToChromium.js, but @kevinsawicki says we could generate the data from atom-shell/dist/index.json as well! (Someone should make a PR 😄)