I want to transform let to var, but leave const alone
const
is well-supported (choosing one key browser, it works back to Safari 5.1). It gives certain concrete benefits over var
, such as UglifyJS being able to inline primitives (const X = 42; …; x = X
→ …; x = 42
).
let
support is much more recent; Safari didn’t implement it until 10.0, for example. And let
doesn’t really get you much over var
.
I’d like to be able to configure Bublé to leave const
alone, and only transpile let
to var
: all the browsers I care about support const
, but not all of them support let
.
I imagine this would entail still processing const
declarations in order to make identifiers appropriately unique, but then emitting const
instead of var
. Because of this and the interaction between let
and const
, I’m expecting it would be done as an option on the letConst
transformation rather than just splitting it into two transformations, let
and const
.