Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support browserslist in @babel/preset-env #6608

Merged
merged 7 commits into from
Mar 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support @babel/polyfill in entry point
  • Loading branch information
ianschmitz committed Mar 9, 2019
commit 38abdbc4ba427cf30f7133406086dc71b5a40d65
8 changes: 6 additions & 2 deletions docusaurus/docs/supported-browsers-features.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ sidebar_label: Supported Browsers and Features

## Supported Browsers

By default, the generated project supports all modern browsers. Support for Internet Explorer 9, 10, and 11 requires [polyfills](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md).
By default, the generated project supports all modern browsers. Support for Internet Explorer 9, 10, and 11 requires polyfills. For a minimum set of polyfills to support older browsers, use [react-app-polyfill](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md). To polyfill other language features, see the [Adding Polyfills](#adding-polyfills) section below

## Supported Language Features

@@ -27,7 +27,11 @@ Note that **this project includes no [polyfills](https://github.com/facebook/cre

If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are [including the appropriate polyfills manually](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md), or that the browsers you are targeting already support them.

## Configuring supported browsers
## Adding Polyfills

You can install [`@babel/polyfill`](https://babeljs.io/docs/en/babel-polyfill) as a dependency in your application, and import it at the very top of your app's entry point (`src/index.js` or `src/index.tsx`) to emulate a full ES2015+ environment. Your `browerslist` configuration will be used to only include the polyfills necessary by your target browsers.

## Configuring Supported Browsers

By default, the generated project includes a set of [`browerslist`](https://github.com/browserslist/browserslist) configuration in your `package.json` file to target a broad range of browsers based on global usage (`> 0.2%`) during production builds, and modern browers during development. This gives a good development experience, especially when using langauge features such as async/await, but still provides high compatibility with many browsers in production.

5 changes: 2 additions & 3 deletions packages/babel-preset-react-app/create.js
Original file line number Diff line number Diff line change
@@ -79,9 +79,8 @@ module.exports = function(api, opts, env) {
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
// If users import all core-js they're probably not concerned with
// bundle size. We shouldn't rely on magic to try and shrink it.
useBuiltIns: false,
// Allow importing @babel/polyfill in entrypoint and use browserlist to select polyfills
useBuiltIns: 'entry',
// Do not transform modules to CJS
modules: false,
// Exclude transforms that make all code slower