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.

In more detail

Anything not listed cannot be imported, which keeps internal files private. Each path can map conditions such as types, import and require to different files. It replaces the older main and module fields for modern tools.

Example

"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.mjs", "require": "./dist/index.cjs" } }

Related terms

Taught in

References