Giter Club home page Giter Club logo

ember-cli-babel-polyfills's Introduction

ember-cli-babel-polyfills

This addon automatically includes a split build of the Babel polyfills in your Ember application! This includes three files that are added programmatically to your index.html:

  1. polyfill-shared.js
  2. polyfill-evergreen.js
  3. polyfill-legacy.js

The shared file contains the common code between both polyfills, while the others contain whatever is unique to them. Importantly, the polyfill-legacy file (which is usually the largest!) is marked with the nomodule attribute. This attribute prevents the file from loading in all modern browsers, so it only impacts your legacy users. For more details, see the MDN documentation.

Why would I want an evergreen polyfill?

It turns out that browsers almost always have inconsistencies, even when they aren't updating only once-per-Windows-release! For instance, Microsoft Edge does not yet implement the DOM iterable API as of 01/24/19 (try checking for document.forms[Symbol.iterator] in the developer console).

These polyfills are built dynamically using Babel's presetEnv, so they'll stay up to date even as the browsers themselves are changing. Best of all, you only ship the things you care about to modern browsers!

Installation

ember install ember-cli-babel-polyfills

Usage

Installing the addon will automatically include the polyfills without any additional configuration. You can opt to configure the addon with the following options:

interface EmberCliBabelPolyfillsConfig {
  legacyTargets?: string[];
  evergreenTargets?: string[];
  includeScriptTags?: boolean;
}

evergreenTargets

The evergreen browsers you want to support, provided in browserslist format. Defaults to the following:

const evergreenTargets = [
  'last 2 Chrome versions',
  'last 2 Firefox versions',
  'last 2 Safari versions',
  'last 2 Edge versions',
  'last 2 ChromeAndroid versions',
  'last 2 iOS versions',
]

Example Usage:

// ember-cli-build.js

let app = new EmberApp(defaults, {
  'ember-cli-babel-polyfills': {
    evergreenTargets: [
      'last 1 Chrome versions',
      'last 1 Firefox versions',
      'last 1 Safari versions',
    ],
  },
});

legacyTargets

The legacy browsers you want to support, provided in browserslist format. Defaults to your app's targets.

Example Usage:

// ember-cli-build.js

let app = new EmberApp(defaults, {
  'ember-cli-babel-polyfills': {
    legacyTargets: [
      "last 1 version",
      "> 1%",
      "maintained node versions",
      "not dead",
    ],
  },
});

includeScriptTags

Whether or not the addon should inject script tags into your content for body. Defaults to true.

Example Usage:

// ember-cli-build.js

let app = new EmberApp(defaults, {
  'ember-cli-babel-polyfills': {
    includeScriptTags: false,
  },
});

License

This project is licensed under the MIT License.

ember-cli-babel-polyfills's People

Contributors

ember-tomster avatar exelord avatar pzuraq avatar stefanpenner avatar

Watchers

 avatar

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.