I REALLY hate to be that guy - but I've got to say, as a Rails dev trying to get a working ES6 environment that will compile stuff to work in IE11, the documentation to do so could not be more confusing in my wildest of dreams.
Does anyone have a working config example repo out there of a fresh rails app that will transpile arrow functions and other ES6 features to work in IE11?
Feel free to delete this. I think I just didn't understand that webpacker will not magically allow the asset pipeline to transpile ES6. It has to be in javascripts/packs, etc.
@gregblass Webpacker4 comes packaged with Babel7, that actually honors the .browserslistrc correctly.
For my project we used stock Webpacker4 and Babel7 configs since they now come with preset-env, and modified the .browserslistrc to include:
> 1%
last 3 versions
ie 11
safari 9
And added the following polyfills to our JS pack:
import "core-js/stable";
import "regenerator-runtime/runtime";
import "whatwg-fetch";
import "dom4";
There are still some things you can't do such as special fetch features, some bits of promises, and some bits of shadowdom but 90% of modern JS works in IE11 and Safari with that config.
Hope it helps!
Hey there again! Thanks for the reply man.
This is super helpful. I鈥檓 and idiot and was expecting to be able to use ES6 features in the asset pipeline.
Took me a really embarrassing amount of time to realize that isn鈥檛 possible.
Ok the bright side, this example config information should be useful to people.
Cheers!
@gregblass You should be able to use ES6 features. In order to help debug, could you please post as much as you can of:
environment.jspackage.jsonbabel.config.js application.js 鈥攖o a https://gist.github.com. Please tag me via @jakeNiemiec in a comment and I鈥檒l be able to point out any problems directly in the gist.
Most helpful comment
@gregblass Webpacker4 comes packaged with Babel7, that actually honors the
.browserslistrccorrectly.For my project we used stock Webpacker4 and Babel7 configs since they now come with preset-env, and modified the .browserslistrc to include:
And added the following polyfills to our JS pack:
There are still some things you can't do such as special fetch features, some bits of promises, and some bits of shadowdom but 90% of modern JS works in IE11 and Safari with that config.
Hope it helps!