keithamus / sort-package-json

Sort an Object or package.json based on the well-known package.json keys
MIT License
806 stars 87 forks source link

Sort conditional exports objects #239

Open jonahsnider opened 2 years ago

jonahsnider commented 2 years ago

The default field should be sorted to appear last in the a conditional exports object. Additionally, the types field should be sorted to appear first when present.

The Node.js documentation has some information on ordering rules:

"default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last. (source)

Nested conditions should also be sorted.

Related to #197

keithamus commented 2 years ago

PRs welcome! I think also getting opinions from folks in #197 (@dandv, @Xunnamius) would be useful.