dual package
A package that ships both an ECMAScript module build and a CommonJS build, choosing between them through export conditions.
In more detail
It lets one library work in modern bundlers and older Node.js tooling. The risk is loading both copies in one app, which can duplicate state such as React context, so the builds must be kept equivalent.
Related terms
- ECMAScript modules — The standard JavaScript module system, written with import and export statements, used by browsers and modern tools.
- CommonJS — Node.js's original module system, which loads code with require() and exports it with module.exports.
- export condition — A key inside an exports entry, such as types, import, require or default, that says which environment should get which file.
Taught in
- Component Packaging: Dual ESM/CJS Builds & Package Exports — Design Systems & Component Engineering