Create-react-app: ES2016 feature Array.includes is not transpiled

Created on 22 Oct 2016  路  5Comments  路  Source: facebook/create-react-app

Array.prototype.includes is not transpiled not sure if this a problem with a babel setting here or a problem with babel itself. But this break IE.

Most helpful comment

@gaearon said in https://github.com/facebookincubator/create-react-app/issues/170 that more polyfills can be added in the future.

I believe Array.prototype.includes would be a good one to include by default.

All 5 comments

Related to https://github.com/facebookincubator/create-react-app/issues/914, CRA purposely doesn't bring in a lot of polyfills, and Array.prototype.includes has to be polyfilled on IE

@EnoahNetzach I would say that a polyfill is not necessary, you could transpile array.includes(i) to array.indexOf(i) !== -1

Edit: Oops, I see now that this is hard to transpile, because you have to know that array is an Array.

Polyfills are defined in packages/react-scripts/config/polyfills.js. Looks like there's no support for array.includes at this moment.

@gaearon said in https://github.com/facebookincubator/create-react-app/issues/170 that more polyfills can be added in the future.

I believe Array.prototype.includes would be a good one to include by default.

Closing in favor of #969: we need to document available polyfills.
We don't intend to include most of the ES polyfills by default.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

alleroux picture alleroux  路  3Comments

oltsa picture oltsa  路  3Comments

adrice727 picture adrice727  路  3Comments

fson picture fson  路  3Comments