musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Optimization: @const and computed properties #114

Closed iccir closed 8 years ago

iccir commented 8 years ago

In our source base, we do a lot of the following:

@const Foo = "Foo";

doSomething({
    [ Foo ]: "value"
});

Right now this outputs:

doSomething({
    [ "Foo" ]: "value"
});

Which Babel turns into something like this:

doSomething((_$tmp = {}, _defineProperty(_$tmp, "Foo","value"), _$tmp));

oj could instead output:

doSomething({
    "Foo": "value"
});