This adds support for namespace imports, i.e. import * as foo from 'foo'. The initial work was done by @caridy and I followed up to make it work with both the commonjs and bundle formatters. I am not yet satisfied with this branch. The biggest code smell is that I am having to cache the specifier names by forcing them to be computed before they are re-written. Other than that, here's some things I think we may need before we can merge:
[x] Make the tests added in 56aa11e pass.
[ ] Potentially optimize import * as foo from 'foo' with foo.a to become a direct reference to the a export (i.e. foo$$a) rather than foo$$.a, which may keep us from needing the foo$$ object at all (bundle formatter only).
[ ] Figure out a better way to preserve the original specifier names.
[x] Ensure ES5 output is acceptable for the bundle formatter (i.e. get properties vs. Object.defineProperty).
Any other optimizations or static errors you all can think of?
cc @caridy @ericf @wycats @dherman
This adds support for namespace imports, i.e.
import * as foo from 'foo'
. The initial work was done by @caridy and I followed up to make it work with both the commonjs and bundle formatters. I am not yet satisfied with this branch. The biggest code smell is that I am having to cache the specifier names by forcing them to be computed before they are re-written. Other than that, here's some things I think we may need before we can merge:Potentially optimizeimport * as foo from 'foo'
withfoo.a
to become a direct reference to thea
export (i.e.foo$$a
) rather thanfoo$$.a
, which may keep us from needing thefoo$$
object at all (bundle formatter only).Figure out a better way to preserve the original specifier names.get
properties vs.Object.defineProperty
).Any other optimizations or static errors you all can think of?