

With the plan, import() is proposed to work in both modules and scripts, giving script code an easy asynchronous entry point into the module world and allowing it to start running module code.

This was not possible with the usual import declarations. While specifier is a string, it is not necessarily a string literal thus, code like import(`./language-packs/$.js`) will work. The specifier will be interpreted the same way as in an import declaration. It returns a promise for the module namespace object of the requested module, created after fetching, instantiating, and evaluating a module’s dependencies, along with the module itself. The proposal adds an import(specifier) syntactic form, acting in many ways like a function.

A “function-like” import() module loading syntax to asynchronously import modules with a dynamic specifier.
