ECMAScript modules

Aa Appearance
Text size
Reading width
Contents

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]

Connections

Discussed by

View connections on the graph
Graph neighborhood · Open full Graph Explorer
Boris ChernyECMAScript modules

References

  1. ↑ECMAScript Language Specification, Scripts and Modules · Ecma International tc39.es
  2. ↑NPM and NodeJS should do more to make ES Modules easy to use | Boris Cherny’s Blog borischerny.com
Revision history
Time view Latest revision

Event dates describe the subject. The knowledge cutoff controls which editorial revisions you can see.