thlorenz/es6ify

For of not working.

Closed this issue · 6 comments

Compiling the following

for (let v of [1, 2, 3]) {
    console.log(v);
}

results in the following, compiled.

for (var $__2 = [1, 2, 3][$__iterator](),
    $__3; !($__3 = $__2.next()).done;) {
  try {
    throw undefined;
  } catch (v) {
    v = $__3.value;
    {
      console.log(v);
    }
  }
}

which results in the following error

TypeError: Property '#<error>' of object [object Array] is not a function

Any idea why?

I think it's something to do with native features in Chrome getting in the way. I disabled the flags in Chrome and things are working again. I'll keep the issue open though because it should gracefully use the native features if they're available.

Seems it's because I haven't added the runtime. Trying to work out how to do that from grunt-browserify though.

Turns out there's no easy way to get it to work from grunt-browserify's config.

Adding this at the start of your entry file works though.

require('es6ify/node_modules/traceur/src/runtime/runtime');

Thanks for reporting this problem and the solution.

I'll probably add this to the readme.

For the record this had nothing to do with Chrome's native features, that was just breaking Traceur in general.

Sent from my iPhone

On 19 Jan 2014, at 01:59, Thorsten Lorenz notifications@github.com wrote:

Thanks for reporting this problem and the solution.

I'll probably add this to the readme.


Reply to this email directly or view it on GitHub.

Yes, I understand.
The es6 language runtime is pretty big and not needed for all es6 features.
That's the reason I made it an option to pull in.