-
-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: package.json export map proper order #200
Conversation
types should come after require and import to not override the map.
I will hold this on, until TypeScript and publint change their documentation to advocate the right usage. |
Sorry I think I linked the wrong publint issue, this one got fixed already publint/publint#47 👍🏽 |
I still do not understand what's going on with it. TypeScript recommends to put it on the top, but not it's not a good practice? Why wouldn't TypeScript change their docs? |
@antfu I think it needs to be on top, excluding nested conditions good
bad because the require.types and import.types will be overwritten by types
Where are the Typescript docs about this ? |
But I guess the current config does not address the difference between top-level and nested order, right? |
Yes ! For now I'm using an override like this
But this isn't ideal as you can have any string as a named export, not just require/import. Ideally it should understand the nesting level and that types are always at the top, but the nested level are above root exports. |
Personally, |
It looks like they're making progress in this Typescript issue. Slowly but surely we'll be able to fix the ecosystem. This proposed change prevent the linter from re-ordering the key in the wrong order. |
This PR conflicts with the #250 rewrite (sorry!). If you still want to push it, please create a new PR from the main branch. Thanks! |
New refactor looks great ! Happy to open a new PR, but do you want to merge this change? |
Description
types should come after require and import to not override the map.
There's something wrong with https://publint.dev/rules#exports_types_should_be_first, the "correct" way to have an export map that works without errors is to do this :
This gives all green for packages that emits both cjs and esm files => https://arethetypeswrong.github.io/
See example of a working map.
Linked Issues
publint/publint#46
Additional context
This is not very concerning as it's easy to override on my side, but I think it's an improvement. Feel free to close if you don't like it.