Skip to content
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

react native dependencies broken my dependency tree #68469

Open
moonrailgun opened this issue Feb 4, 2024 · 10 comments
Open

react native dependencies broken my dependency tree #68469

moonrailgun opened this issue Feb 4, 2024 · 10 comments

Comments

@moonrailgun
Copy link
Contributor

moonrailgun commented Feb 4, 2024

I found this commit 8e8a4b6 change all @types/react-native to react-native but some library declare this in dependencies fields

so when i try to install those type library in pnpm, its will broken my dependencies tree and throw those error

img_v3_027o_7ddda1fe-b05a-4534-aedb-58c671e2e41g

I dont know why, but if i change library's dependencies and remove it , every thing is ok.

I thinks its a mistake for those library which make react-native in dependencies field and you know its will be install rather than devDependencies which will be ignore.

image

@jakebailey
Copy link
Member

@lunaleaps

But you should be using discussions for these kinds of questions.

@moonrailgun
Copy link
Contributor Author

But you should be using discussions for these kinds of questions.

well, but i think its not a question but a issue, common issue.

It's just that in other package management software it will be obscured because they are not so precise

@jakebailey
Copy link
Member

jakebailey commented Feb 7, 2024

well, but i think its not a question but a issue, common issue.

Our discussion boards ping package owners; the issue tracker is supposed to be for infrastructure issues only (hence why the only valid form is for infra issues, which everyone is ignoring).

@lunaleaps
Copy link
Contributor

lunaleaps commented Feb 8, 2024

@moonrailgun I'm not sure I understand how that error is related to the type change. Can you clarify that connection?

Happy to continue discussion in a discussion board or a react-native issue

@moonrailgun
Copy link
Contributor Author

@moonrailgun I'm not sure I understand how that error is related to the type change. Can you clarify that connection?

Happy to continue discussion in a discussion board or a react-native issue

the major problem is as a type dependency try to install a real dependency, and react native has a lot of implicit dependencies.

I am using pnpm and its will broken topology of react native dependency. i think its not true so i remove it and everything is work.

I don’t know why this problem occurs under the hood. I only know that types should not actually install an library. It should be used as devDependency or peerdependency.

@lunaleaps
Copy link
Contributor

I'm wondering if its also because react-native doesn't support pnpm from my understanding and DefinitelyTyped doesn't support peer dependencies as mentioned here: #67459 (comment)

@jakebailey
Copy link
Member

I only know that types should not actually install an library. It should be used as devDependency or peerdependency.

This is generally not true; types dependencies are real dependencies, and are needed if you ever want to use a library that uses another library's types. Peer dependencies are certainly possible and I have half proposed switching DT to them, but not all package managers auto-install peers (notably, no version of yarn does!)

@moonrailgun
Copy link
Contributor Author

react-native doesn't support pnpm from my understanding

In fact, our team is using pnpm workspace to manage react native projects (excluding expo)

types dependencies are real dependencies, and are needed if you ever want to use a library that uses another library's types

I mean a type library should not help people install other library. because its not real run in runtime.

For example, user install package A@^1.0.0, and create lock file, everything is good.

Then, user install a type library which include A@1.1.0 in dependencies list, and everything maybe broke.


After all, i just report a problem as user. although I solved this problem myself, I thought someone might have the same problem as me in the future. so i report it let you know.

Because this is the source of my problem and I think this design is unreasonable. It violates the node package management design philosophy. They should be a peerdependency rather than dependencies.

There is no problem if a type library depends on a type library, but if it is changed to a complete library, we must pay attention to its impact.

If I install a type library that depends on react native, I will definitely not expect this type library to install react native for me.

@jakebailey
Copy link
Member

There is no problem if a type library depends on a type library, but if it is changed to a complete library, we must pay attention to its impact.

This is generally inevitable as DT becomes less relevant and more packages include their own types (which has strong benefits).

That being said, for packages where it's clear that you're going to have to install a sibling package (like react, express, etc), I think that it's possible for DT to do peer dependencies safely, even with yarn not behaving like other package managers on that front.

@lunaleaps
Copy link
Contributor

I think at this stage, this is a limitation from DT.

From discussion on the change, we can consider releasing a types-only react-native package if it becomes a larger issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants