create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Object.assign et al are not polyfilled

Open conatus opened this issue 10 years ago • 7 comments

Hi all,

Thanks for your wonderful work on this.

When testing a React app using create-react-app on a old version of mobile Safari I noticed that Object.assign was failing.

I looked and saw that polyfill support is turned off on the configuration of babel-plugin-transform-runtime https://github.com/facebookincubator/create-react-app/blob/master/config/babel.prod.js#L33-L37

I worked around this by, for the moment, slightly inefficiently manually adding babel-polyfill and using the more "traditional" import 'babel-polyfill'; at the root of the application to include core-js polyfills.

Seems that if the goal is zero configuration setup this is going to be a gotcha for more than a few folks. Unsure if the best approach is to simply turn on the polyfill in babel-plugin-transform-runtime as the documentation seems to suggest this is not the intent of this transformation to supplement native methods like Object.assign.

conatus avatar Aug 08 '16 10:08 conatus

@gaearon @vjeux further to Twitter convo.

conatus avatar Aug 08 '16 10:08 conatus

I probably wouldn’t turn on the whole runtime (it’s pretty aggressive and brings in half of core-js).

However Object.assign() seems reasonably since we provide spread operator anyway, and we also use object-assign inside of React itself.

So we’ll probably just do that.

gaearon avatar Aug 08 '16 11:08 gaearon

Hi @gaearon, I'm at the script version 1.0.12 and IE11 reports this as a problem. Am I missing some implementation detail? Do I need to import it manually or something like that?

image

Cheers, Nemanja

mnemanja avatar Aug 30 '17 13:08 mnemanja

I get exactly the same problem as mnemanja.

Version Info: C:\src\sandbox\react\my-app>create-react-app --version 1.4.0

dcp12345678 avatar Aug 30 '17 18:08 dcp12345678

Note: adding this to index.html seems to resolve the create-react-app bug with ie11, but this doesn't feel like a good solution: <script src="//cdn.polyfill.io/v2/polyfill.min.js"></script>

dcp12345678 avatar Aug 30 '17 19:08 dcp12345678

Can you please open a new issue? It's hard to track in old, closed issues.

Timer avatar Aug 30 '17 19:08 Timer

Timer, here you go: https://github.com/facebookincubator/create-react-app/issues/3034

dcp12345678 avatar Aug 30 '17 20:08 dcp12345678