-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Please note the explicit guidance on Custom conditions for monorepos at from the author of zod who I consider an authority on typescript practices...
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").
https://colinhacks.com/essays/live-types-typescript-monorepo
The change to force this order breaks systems in a major way.
Within the "exports" object, key order is significant. During condition matching, earlier entries have higher priority and take precedence over later entries. The general rule is that conditions should be from most specific to least specific in object order.
https://nodejs.org/api/packages.html#conditional-exports
it's nice to have the keys of a package.json in a well sorted order.
Object order in package.json is part of the node resolution API, it's not a nice formatting aspect to help with diffs or styling.
The result of this particular opinionated ordering was to break every module and server in our monorepo meaning we will have to remove tooling for package ordering via https://github.com/matzkoh/prettier-plugin-packagejson which brought through the change.
I'm guessing #294 (comment) is a comment on a feature discussion and therefore won't be considered a live issue. So I'm raising this here as an issue so that it can at least be considered
In the circumstances I imagine we just have to stop formatting package.json. I suspect from reading discussion that this upstream will stay this way, which is of course your right, but please consider how being opinionated in this way may end up actually breaking things very badly in ways that are nearly impossible to trace, and that people will struggle with the consequences.
Working in an ecosystem where navigating a functioning intersection between all the opinionated tools, the cost of these arbitrary decisions compounds. For every opinionated tool fighting it out with all the others, the last move in the venn diagram can end up excluding systems from even functioning.
It's a particular shame because monorepos is exactly where this kind of tooling and consistency matters and I am sad to abandon it.