Found an interesting snippet in the babel transpiled code.
For the below ES6 code snippet:
import { speak } from './mod_test';
speak('world');
Babel will transpile it to ES5 as below:
(0, _mod_test.speak)('world');
It is to convert a method call to a regular function call which is what intented in ES6 syntax. The equivalent code with explicit assignment expression:
var _speak = _mod_test.speak;
_speak('world');
Without the assignment, this
in the call refers to the module instance _mod_test
instead of global (ie. window/global
).