Skip to content

Comments

Remove behaviour forcing types to be first in exports#398

Merged
keithamus merged 1 commit intokeithamus:mainfrom
cefn:CEFN-dont-manipulate-types
Jan 25, 2026
Merged

Remove behaviour forcing types to be first in exports#398
keithamus merged 1 commit intokeithamus:mainfrom
cefn:CEFN-dont-manipulate-types

Conversation

@cefn
Copy link
Contributor

@cefn cefn commented Jan 23, 2026

Forcing "types" to be first in every export map breaks the fundamentals of custom conditions, in which package owners determine the priority order of conditions, including their own 'user conditions'.

Forcing "types" to be first in all exports is a regression we experienced breaking all builds in our monorepo via https://github.com/matzkoh/prettier-plugin-packagejson

In that last article (written by the author of zod) is this very specific guidance, which is impossible when formatted by sort-package-json since 3.5.0

You should put your custom condition first. Order matters! It's important that your custom condition is the first one in the list (even before "types")

@keithamus
Copy link
Owner

It would be useful to have a test demonstrating the failure mode here. For example this simply removes the existing tests, but instead altering them to prove that types is not forced to the top will help us avoid future regressions.

@cefn cefn force-pushed the CEFN-dont-manipulate-types branch from a1187a7 to f847947 Compare January 23, 2026 16:34
@cefn
Copy link
Contributor Author

cefn commented Jan 23, 2026

Updated tests to include negative cases.

Fixes #393

Copy link
Owner

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this LGTM.

Let's have @fisker review this too, and merge.

@keithamus keithamus merged commit 15e1140 into keithamus:main Jan 25, 2026
3 checks passed
@github-actions
Copy link

🎉 This PR is included in version 3.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants