medikoo / es5-ext

ECMAScript extensions (with respect to upcoming ECMAScript features)
ISC License
174 stars 85 forks source link

Question #68

Closed sm2017 closed 6 years ago

sm2017 commented 6 years ago

I am using react-native , and I want to be sure my code works anywhere

1- How can I be sure that my code is running safe anywhere? Must I add all ES6 shims?? 2- How can I easily add ES6 shims , is there any single line require?

medikoo commented 6 years ago

1- How can I be sure that my code is running safe anywhere? Must I add all ES6 shims?? 2- How can I easily add ES6 shims , is there any single line require?

Firstly you need to determine whether react-native can work in non ES2015 environments. As some of the ES2015 features are not polyfiable. If it relies on those, than you just can't run it in older enviroments.

If it can run, then it'll be good to clarify on which exactly ES2015 features it relies, and then you can load polyfills specifically for those.

While some other projects (as es6-shim) try to polyfill all missings from ES2015, no matter if you use them or not, I didn't take that path in this project, as ES2015 introduced a lot of things, and as in most cases you rely on just fraction of them, loading all of them would be quite inefficient

So answering your question, there's no single require in this project that loads all of them. Also es5-ext provides shims just for built-ins that were defined in the language prior ES2015, the new builtins as Symbol or Set have external polyfills.

Once I tried to group information about all shims here: https://gist.github.com/medikoo/102b7d0e697627133788#list-of-ecmascript-6-shims

See also https://github.com/addyosmani/es6-tools