A project I'm working on has IE8 as a hard requirement. We would like to potentially use Traceur to start working with some of ES6's improved syntax, but I'm aware that it produces ES5, which is not supported by IE8. Given that I can patch up IE8 with es5shim, which Traceur-supported ES6 features are safe to use?
More specifically, I'm wondering which features map always map directly to fully compatible code (much of the sugar, presumably), which features suffer from mismatch in behavior, due to limitations of the shim, and which are unavailable altogether
Summary: do not use Traceur if you need IE8 support
It is not possible to get full support for Traceur-compiled code in IE8 as it has very poor ES5 compatibility, which cannot be patched completely even with known polyfills like es5shim.
You may get some of your Traceur-compiled code to work in IE 8 though, but as far as I know this is pretty unexplored space. One of the only references to such attempts I know is an open issue in traceur's github repo regarding "old IE support".
From engineering point of view, I think using Traceur+ES5 shim combination in production is a really bad idea. You will not only have to deal with the potential problems raising from ES6->ES5, but also have to work around bugs due to buggy ES5 polyfills, both of which are very likely problems to occur.
Using Traceur in combination with various polyfills and patches will also result in hugely bloated JavaScript code. Just to give you an example, let us consider simple ES6 generator usage along with ES5 Array.prototype.each
:
function* items() {yield new Array(1, 2, 3);}
for (item of items()) {
item.every(function(elem, index, arr) {
console.log(item);
});
}
If we want to run this in IE8, we first need to compile it to ES5 with Traceur and then apply a polyfill for Array.prototype.each. The resulting IE8-compliant code in this case is roughly around 50 lines of code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With