meteor / babel

Babel wrapper package for use with Meteor
Other
46 stars 20 forks source link

Enable es6.constants #1

Closed stubailo closed 9 years ago

stubailo commented 9 years ago

This is pretty crucial to catch errors where you accidentally assign to constants. It also enables the workflow of replacing all vars to constants, and then figuring out what to do about the ones that are actually assigned to.

dgreensp commented 9 years ago

Actually, without this transformer, const is not transpiled into var at all, it just stays const.

dgreensp commented 9 years ago

Interestingly, most browsers have supported const for a while (but not with strict semantics until recently). But we need this transformer for IE10 and below.

stubailo commented 9 years ago

Actually, I think es6.blockscoping transforms const into var?

stubailo commented 9 years ago

I could be totally wrong though, their documentation is terrible on this

dgreensp commented 9 years ago

The headings on that page aren't one-to-one with the transformers, confusingly.

I think most people just run Babel with the default settings so they don't run into this.

I tried transpiling with and without es6.constants.

stubailo commented 9 years ago

Ah, OK then we definitely need to transpile it. Confusingly, my code seemed to run in Node.js without this transform, even though I was using const.

dgreensp commented 9 years ago

Yeah, const works in Node.