Closed stubailo closed 9 years ago
Actually, without this transformer, const
is not transpiled into var
at all, it just stays const
.
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.
Actually, I think es6.blockscoping transforms const into var?
I could be totally wrong though, their documentation is terrible on this
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
.
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
.
Yeah, const
works in Node.
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.