-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ES6 code in production build breaks IE11 #238
Comments
Would it make sense to have different build targets? cc @mondaychen Does the ES5 output polyfill for |
I don't think that would be needed, we use react-app-polyfill which already includes one for |
@pgrippi IE11 supports Ideally, libraries shouldn't be concerned with the environment. The consumers build process should take care of transpiling and adding any necessary runtime code. That being said, this complicates things for the consumer and would affect build times (e.g. having to transpile node_modules). Multiple outputs is a good solution for this but how would you pick which output you needed? It could be explicit like changing the import/require specifier: I personally would recommend using are-you-es5 to only transpile the packages that need it. As time goes on, you will probably run into more packages that don't output ES5 so this might be the best option for you. |
Closing this for now as hopefully transpiling is a workable solution for those needing ES5 support. |
I think it would be a simple fix of updating the
@drarmstr thoughts? |
cc @mondaychen |
It looks like there are four outputs right now:
ES Modules & CommonJSMost bundlers automatically handle which module format to use. Recoil controls the options through the "main" and "module" fields in package.json. Using the "module" field is not standardized by NPM but it's used by many popular NPM packages and bundlers will likely support this for a while. Recoil's current ES module output will probably fail when using native modules in Node 14 because the "module" file is entirely CommonJS. Not really a problem now but it would be nice to find a solution that is future compatible. Development and ProductionThe Let's say we make all outputs ES5: What if Recoil offered two more outputs, ES5 and ES{current}?: In my opinion, I would just transform the outputs to ES5 and use the "loose" option babel provides. It would be pretty cool if NPM or another package manager handled generating the output the consumer needed but I doubt a feature like that is even on their radar. |
@mondaychen I've checked out on my local and linked to my app. Seems to all work as expected without any random import errors that I had before. But it's still not transpiled down to es5. That would simple just to add |
Let's add ES5 transpiling in a separate PR (after #433 merged) so that we can test the impact on file size there. Some thoughts on the options we have: About loose mode: IMO we should NOT use babel loose mode because this is a library and we should not risk getting problems when switching to non-transpiled version in the future. About providing multiple outputs: if we do see a relatively significant size impact in the output transpiled down to es5, we can consider providing one single ES-current uncompressed output, so that people who care about size a lot have the option to pick target browsers themselves. |
I was hoping to give Recoil a try in one of my projects, but it looks like ES6 code is not being transpiled away in the production build:
We sadly have to support IE11, would it be possible to update the rollup config to output ES5 code instead?
The text was updated successfully, but these errors were encountered: