export condition
A key inside an exports entry, such as types, import, require or default, that says which environment should get which file.
In more detail
Resolvers take the first condition in the object that matches, so order matters: types must come first so TypeScript finds declarations, and default must come last. import is used by ECMAScript modules and require by CommonJS.
Related terms
- exports field — The package.json field that lists exactly which files a package exposes, by path such as "." or "./button", and which file to use in each situation.
- 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.
- type declaration file — A TypeScript file ending in .d.ts that describes the types of JavaScript code without containing the code itself.
Taught in
- Component Packaging: Dual ESM/CJS Builds & Package Exports — Design Systems & Component Engineering