最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

internet explorer 8 - To what extent does Traceur compile to IE8 compatible Javascript? - Stack Overflow

programmeradmin1浏览0评论

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 patible code (much of the sugar, presumably), which features suffer from mismatch in behavior, due to limitations of the shim, and which are unavailable altogether

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 patible code (much of the sugar, presumably), which features suffer from mismatch in behavior, due to limitations of the shim, and which are unavailable altogether

Share Improve this question edited Jun 5, 2014 at 2:50 acjay asked Jun 4, 2014 at 18:53 acjayacjay 36.8k6 gold badges59 silver badges102 bronze badges 6
  • @jsalonen I feel like a real answer would be objective. But please feel free to edit/make suggestions to make that scenario less likely. – acjay Commented Jun 4, 2014 at 19:27
  • After some consideration and your edit, retracted my close vote. Also: could you be a little more specific on what you mean with "Traceur features"? Do you mean ES6 Language Features? – jsalonen Commented Jun 4, 2014 at 19:58
  • Everything that uses stuff that es5shim can't or doesn't provide. The best way to find out is probably to react when issues arise. – jgillich Commented Jun 4, 2014 at 20:09
  • @jgillich I figured, but I'm trying to figure out whether anyone has solid knowledge on what ES6 features are piled to ES3 or ES3+es5shim patible JS – acjay Commented Jun 4, 2014 at 20:32
  • @jsalonen: Well yes and no. Traceur itself can only support a subset of ES6 features (kangax.github.io/pat-table/es6), so naturally anything in the No column there is an automatic No for the purposes of this question – acjay Commented Jun 4, 2014 at 20:49
 |  Show 1 more ment

1 Answer 1

Reset to default 10

Summary: do not use Traceur if you need IE8 support

It is not possible to get full support for Traceur-piled code in IE8 as it has very poor ES5 patibility, which cannot be patched pletely even with known polyfills like es5shim.

You may get some of your Traceur-piled 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 bination 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 bination 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 pile it to ES5 with Traceur and then apply a polyfill for Array.prototype.each. The resulting IE8-pliant code in this case is roughly around 50 lines of code.

发布评论

评论列表(0)

  1. 暂无评论