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
Typings should not be in dependencies. #4367
Conversation
Just checking - we're not exporting anything from |
No, nor should we, I think. All evidence of TS should be gone from the built JS, I believe. I ran into this conflict when updating some extensions that depend on apputils |
Ooh, maybe you are right, @jasongrout. What do you think about VDomRenderer.render()? |
It's still a dev dependency. Anyone that wants to consume our typings during build needs to install the react typings too (IMO). |
I thought the purpose of having the types packages was so that you didn't need to install the typings outside of your dependencies. What exactly is the problem with including the typing package as a dependency? |
Conflicting versions of the types? |
In theory, the types should be scoped to our current package, but I think typescript has a problem with multiple global definitions of different versions. Although IIRC the newer releases of TS are better at this. |
Ian, is that what happened to you? |
Yes, there was one set of React typings from the extension, and one from apputils. They conflicted (regardless of the versions), and deleting the ones distributed by apputils fixed the issue. Happy to consider other options, but as it stands, extension developers can't rely on both apputils and React. |
More discussion of this question: |
Would it be enough to change the dependency to |
For me personally, apputils is too big and pulls in too many unrelated things. For example, the widgets jlab manager depends on it transitively, so now we are depending on all sorts of stuff we don't need or want. So for that reason I'm fine with removing the typing package. Also, this particular typing package declares a global, right? If so, that's another reason to not include it as the possibility of conflicts/problems is much greater. On the other hand, I see the argument for including it. So I'm probably +0 on merging this PR. |
I was unable to get it to build when more than one |
(I also generally agree that apputils is getting pretty large) |
Consider the case of someone writing a lab extension in JS. They should not need to have a dependency for typings. |
@ian-r-rose which extension was this? I would like to investigate. From my experience with yarn versioning, it will only install multiple instances of the same library if there are conflicting dependencies. I assume we want to avoid this with React, that there should only be on version of it, since it has global state.
|
I would be grateful for a second set of eyes on it @saulshanabrook. I have seen it in multiple extensions, but the simplest one is https://github.com/ian-r-rose/jupyterlab-toc, which has an open PR bumping it to the 0.32 packages. |
Note, we're only talking about the typings package here, not the react package itself. |
Another data point: the extension build works fine using |
|
I meant changing the apputils react typing to |
No, I did not change the apputils react (note that it is very tricky to try to experiment with these, since extensions only target published packages). Why do you think that changing the react version would make a difference? |
Apputils is pinned to patch updates. If it is instead pinned to minor updates, it's possible that the dedup will work. |
But again, this is just for the Edit: misunderstood what you said. I am pretty baffled here, but this appears to be a case where yarn is getting it wrong, and npm is getting it right. |
Another update: adding a "resolutions": {
"**/types/react": "16.3.9"
} This is not a fully satisfying solution, but seems to work. I think @jasongrout may be right that using |
@ian-r-rose No magic with lockfiles interfering? |
@vidartf Not as far as I could tell. I don't think that the |
It's even worse than that. Type definitions can be compatible with only certain versions of typescript as well (so we have a 2d compatibility matrix here...). Looking at https://www.npmjs.com/package/@types/react, and the tags, we see that for ts v2.5, you should probably use 16.0.36. I think in general it's a nice idea to include typings in dependencies. In this case, where apparently this particular typings package may be brittle and apputils itself brings in "too many" dependencies anyway from being a smorgasbord of a package, I'm okay with removing these typings. But I would also like to see if bumping the apputils typings to |
I still get errors using |
Okay, +1 on moving the dependency to a dev dependency in this case, then. |
Thanks for publishing @jasongrout. Unfortunately, this PR seems to have broken the build for extensions that don't include This is a frustrating situation. Extensions with |
This will need to be in 0.32. I think this can cause problems when dependencies that rely on
@jupyterlab/apputils
also depend on@types/react
.