# ECMAScript modules

Type: Concept

ECMAScript modules are JavaScript source units with their own scope and explicit imports and exports. The ECMAScript specification defines their syntax and evaluation. The host environment supplies the mechanism for resolving module specifiers.[1][2]

## Exports and imports

A module declares which names it exports. An importing module can bind a named export, a default export or a module namespace. The specification distinguishes import declarations from the dynamic import expression, which loads a module through a promise that resolves to its namespace. [1]

## Loading and adoption

ECMAScript defines module records and how linked code is evaluated. The host interprets the requested module specifier and supplies the module being loaded. In a 2024 survey of JavaScript and TypeScript repositories and packages, Boris Cherny examined the coexistence of this module system with CommonJS. [1][2]

## Related articles

- [Boris Cherny](/wiki/boris-cherny/) (discussed-by)

## References

1. [ECMAScript Language Specification, Scripts and Modules · Ecma International](https://tc39.es/ecma262/2023/#sec-ecmascript-language-scripts-and-modules)
2. [NPM and NodeJS should do more to make ES Modules easy to use | Boris Cherny’s Blog](https://borischerny.com/javascript,/typescript/2024/06/19/ES-Modules-Are-A-Mess.html)
