ESMs (ECMAScript modules) are the official standard format to package JavaScript code for reuse. Modules are defined using import and export statements. 1
The way we export "things" from our libraries impacts the way they can get imported by clients of our libraries.
For example, if we define a module and export cheese from it as the default export:
export default cheese;
// same as `export { cheese as default };`Then clients of our library should import it like this:
import cheese from 'my-library';But had we defined cheese as a non-default export:
export cheese;Then we should have used a different syntax to import it:
import { cheese } from 'my-library';- #javascript
- #typescript