Package · PKG0009
Put the default export condition last
Find conditions objects in package.json "exports" where a "default" that always resolves comes before other conditions, so Node, Vite and other resolvers never reach them.
package/no-condition-after-defaultsrc/rule-packs/package/rules/no-condition-after-default.ts Upstream docs Run this rule
pnpm vite-doctor . --extends package/recommended --rules package/no-condition-after-default
Why it matters
Resolvers walk an exports conditions object in key order and take the first key that matches. "default" matches every environment, so once it resolves to a path, an "import", "require", "node" or "browser" key after it is never read. The package then loads the "default" file everywhere, which usually means the CommonJS build for ESM consumers or the Node build in the browser.
Recommended fix
Move "default" to the end of its conditions object, after every condition that should win over it.
Useful links
Example
Let import and require win over default
Before
{ "exports": { ".": { "default": "./dist/index.cjs", "import": "./dist/index.mjs" } } }
After
{ "exports": { ".": { "import": "./dist/index.mjs", "default": "./dist/index.cjs" } } }