Skip to content

fix: order "types" first in package.json exports - #330

Open
oliverlaz wants to merge 1 commit into
mainfrom
fix/exports-types-condition-order
Open

fix: order "types" first in package.json exports#330
oliverlaz wants to merge 1 commit into
mainfrom
fix/exports-types-condition-order

Conversation

@oliverlaz

Copy link
Copy Markdown
Member

Export conditions are matched top-to-bottom, first match wins. With "import" and "require" listed before "types", the types condition was unreachable — consumers resolving through "exports" (moduleResolution: node16 / bundler) never picked up the declarations, and esbuild warned on every vitest run:

▲ [WARNING] The condition "types" here will never be used as it comes after both "import" and "require" [package.json]

Reordering "types" to the top fixes it. The top-level "types" field is kept as the fallback for legacy moduleResolution: node.

Verification

  • yarn vitest run no longer emits the warning (0 occurrences).
  • No behavior change to the emitted bundles — this only affects resolution order.

Export conditions are matched top-to-bottom, first match wins. With
"import" and "require" listed before "types", the types condition was
unreachable, so consumers resolving through "exports" (moduleResolution
node16/bundler) never picked up the declarations and esbuild warned about
it. The top-level "types" field is kept as the legacy fallback.
@oliverlaz
oliverlaz requested a review from szuperaz as a code owner August 17, 2026 08:12
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.

2 participants