Modern exports field defined
Why it matters
Without a modern exports field, Node.js 16+ consumers get inconsistent resolution across bundlers and runtimes. Tools like webpack 5 and Vite treat the exports map as authoritative — packages that rely on legacy main/module fields alone can fail outright under strict resolution or expose internal files via unguarded deep imports. ISO 25010 modifiability and interoperability both degrade when entry points are implicit rather than declared. The practical result: import errors in production that only surface at the consumer's build step, not yours.
Severity rationale
Critical because misconfigured or absent entry-point declarations cause outright import failures at build time for Node.js 16+ and all strict-resolution bundlers.
Remediation
Add the exports field to package.json mapping the root entry point with import, require, and types conditions. Keep legacy main, module, and types fields as fallbacks for older tooling.
{
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
Use a build tool like tsup (tsup src/index.ts --format esm,cjs --dts) to generate both formats and the exports map automatically. Verify the referenced files exist in dist/ before publishing.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the SDK / Package Quality Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability.modifiability — Modifiability — package entry-point contracts
- iso-25010:2011 · compatibility.interoperability — Interoperability — CJS/ESM consumer compatibility
Taxons
History
- 2026-04-18·v1.0.0·Initial import from sdk-package-quality·automated