Skip to content

Conversation

@njg7194
Copy link

@njg7194 njg7194 commented Feb 1, 2026

Summary

This PR adds documentation for the exports field in the manifest (package.json) documentation.

Changes

Added comprehensive documentation for the exports field, which is the modern and recommended way for packages to define their public API and entry points.

Documentation includes:

  • Main field description: Explains the purpose of exports and its relationship to legacy fields like main and module
  • Subpath exports: How to map specific subpaths like "./utils" to different files
  • Conditional exports: Using conditions like "import", "require", "node", "default" to provide different implementations
  • Pattern exports: Using * wildcards to match multiple subpaths
  • publishConfig.exports: Added the ability to override exports at publish time

Example

{
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    },
    "./utils": "./dist/utils.js"
  }
}

Closes #6909

Add documentation for the `exports` field in the manifest (package.json)
documentation. The `exports` field is the modern and recommended way for
packages to define their public API and entry points.

Documentation includes:
- Main field description explaining its purpose
- Subpath exports capability
- Conditional exports (import/require/node/default)
- Pattern exports with wildcards
- Added exports to publishConfig as well

Closes yarnpkg#6909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Manifest documentation mentions export without actually documenting it

1 participant