> module name from './path'
> ...
> name.method();
>
Right - that would work for objects-as-modules, but this wouldn't:
import { something } from "./path";
Unless you somehow emitted getters for all references to "something".
Without consulting documentation, I would expect that these two things:
module x from "./path";
// From within some function or other
x.foo();
import { foo } from "./path";
// From within some function or other
foo();
would be equivalent. I think a beginner would find a difference there
surprising.
Also, consider hoisting.
// Call an imported function directly
import { foo } from "./path";
foo(123);
module m from "./path";
m.foo();
With "object-as-module", neither one is going to work if you have a
circular dependency at play.
Of course, these gains aren't giant - they support edge cases. But they
are real.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss