Are ES6 module imports hoisted?

After doing some more research, I’ve found:

  • Imports ARE hoisted! according to the spec of ModuleDeclarationInstantiation
  • ALL the dependent Modules will be loaded before running any code.

This code will have no errors, and will work:

localFunc();

import {myFunc1} from 'mymodule';

function localFunc() { // localFunc is hoisted
    myFunc1();
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)