ESM: Default, Mixed, and Async

Learn about ESM default exports and imports and how to use mixed and async imports.

Default exports and imports

One widely used feature of CommonJS is the ability to export a single unnamed entity through the assignment of module.exports. We saw that this is very convenient as it encourages module developers to follow the single-responsibility principle and expose only one clear interface. With ESM, we can do something similar through what’s called a default export. A default export makes use of the export default keywords, and it looks like this:

Get hands-on with 1400+ tech skills courses.