Insight of the day: import is hoisted (due to ModuleDeclarationInstantiation). That’s why the following code works.
import
ModuleDeclarationInstantiation
bar(); import {foo} from 'mymodule'; function bar() { // hoisted! foo(); // already initialized? }
Did you mean
bar(); function bar() { // hoisted! foo(); // already initialized? } import {foo} from 'mymodule';
?