-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: move types
condition to the front in all package.json.exports
maps
#22321
Conversation
I'm not 100% sure if this should be labelled Should we patch this back to 7.0? |
This is awesome @Andarist, question: does this remove the need for code like this: storybook/code/addons/backgrounds/package.json Lines 55 to 66 in b891cd4
|
@ndelangen This probably makes sense to patch back. I occasionally patch maintenance PRs back if they don't add new features, so I don't mind whether it's labeled bug or maintenance |
I tried it real quick, and turns out it is in fact, NOT possible to remove:
|
It would be possible if you'd switch to An alternative to this // code/addons/backgrounds/preview.d.ts
export * from './dist/preview'; This is basically the type-level equivalent of what you are already doing for runtime resolution since you have |
Fix: move `types` condition to the front in all `package.json.exports` maps
What I did
I moved
types
condition to the front.package.json#exports
are order-sensitive - they are always matched from the top to the bottom. When a match is found then it should be used and no further matching should occur.Right now, the current setup works in TypeScript but it's considered a bug and it should not be relied upon, see the thread and the comment here. For that reason, I would like to fix all popular packages that misconfigured their
exports
this way so the bug can be fixed in TypeScript.How to test
Try to use built package with different
tsconfig.json
settings related to module resolution.Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]