-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: All packages have a direct dependency on @types/*
regardless of whether TypeScript is used
#32292
Comments
we discussed this today with v-build folks, with following outcome: immediate action (to unblock your use-case): @tido64 follow up action: clean-up dependency definitions in all packages long term action: in future we will be generating package.json contents, including dependencies, dynamically based on source file usage + implicit dependencies = this way this kind of thing should never happen as source of truth is source code shipped to registry. |
@Hotell: Just so I understand you correctly, do you want me to remove
This field was added in npm 7 and seems to be widely adopted. Here's pnpm and Classic Yarn. |
yes but hold on ↓ the rule is/should be: if react types are not exposed as part of public API I don't see a reason why it should be there as peerDependency. how does it look like for utilitities package: I checked public -> so the peerDep should stay as is. If you are aware about other packages that have the issue and dont use those types as part of public API, happy to accept changes for these. thoughts ? ty |
thanks for quick research ! I can confirm it's supported also for yarn v4 |
This is why we should introduce
Why are we re-exporting |
That's fair, on the other hand we approach I also agree that it is not good practice to force download things you don't use. On the other hand the whole auto peer dependency install is not the most explicit approach that was set as default rather opt in ( but we are very small fish to be able to steer the direction within package managers ).
Regarding pros/cons: Pros:
Cons:
Summary:
Happy to hear more thoughts if needed @tido64 🙌
That "works as expected" -> its how utilities package exports as part of its public API React components ( those are annotated via |
Because this issue is marked as by design and has not had activity for over 3 days, we're automatically closing it for house-keeping purposes. |
Because this issue is marked as by design and has not had activity for over 3 days, we're automatically closing it for house-keeping purposes. |
Library
React / v8 (@fluentui/react)
System Info
Are you reporting an Accessibility issue?
None
Reproduction
https://github.com/microsoft/rnx-kit/blob/main/.yarnrc.yml#L21
Bug Description
As an example,
@fluentui/utilities
has a peer dependency on@type/react
. This causes package managers to either warn or even fail (default with latest npm) if the consumer of the package does not also install the@types
packages. However, it is not always the case that TypeScript is being used. Forcing users to install them in this scenario is unnecessary. Instead, we should mark them all as optional (example).Logs
No response
Requested priority
Low
Products/sites affected
Anyone not using TypeScript
Are you willing to submit a PR to fix?
yes
Validations
The text was updated successfully, but these errors were encountered: