简体   繁体   中英

Polyfilling node_modules

I am successfully using Babel 6 for all my ES2015 needs in my own codebase but I have found instances of Object.assign in fluxible-addons-react and String.prototype.repeat in react-relay . Yahoo dropped internal polyfill support here . And I am not sure whether Facebook ever supported a polyfill internally.

I discovered when booting my relay app in Safari 8 that I had to...

// Polyfill for Fluxible*
Object.assign = require('core-js/library/fn/object/assign');
// Polyfill for Relay
String.prototype.repeat = require('core-js/library/fn/string/repeat');

Does it make more sense to just...

require('babel-polyfill');

In which case we end up with a possibly higher overhead and superfluous polyfilling in the more modern browsers, but...hunting for the needed polyfills in my browser support matrix and supporting them one by on via core-js seeems a bit madness-inducing.

Does anybody else with experience in this area have recommendations for feedback?

Once I realized that babel-polyfill wraps core-js anyway, this became a non-question.

https://github.com/babel/babel/blob/e68754faf246ba2f7624380d24e7ff369e7caf06/packages/babel-polyfill/package.json#L11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM