You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came up in discussion in #5215. It's a strange bug which can go unnoticed during development.
Basically, jupyter labextension install will fail on at least some packages using typescript and react because it always uses yarn. Yarn has a known issue with resolving types for react and react-dom.
This bug means that a straight attempt to install a package with a naive approach to setting up typescript and React (and by naive, I mean expecting things to work across npm and yarn). See example below.
To Reproduce
I'm simply pointing you to a simple version of the gigantum extension, as I think it's quite clear to see what's going on. If an even simpler demo project is desired, please ask!
Assuming a throw-away python env with jupyterlab installed, set up for extension development:
It builds with npm (which is the recommended development command in the docs), so it should install without error. Incompatibilities between yarn and npm will likely continue to perpetuate this problem.
Knowing that I need to accomodate yarn, I can follow the instructions provided on the DefinitelyTyped issue and include the following in my package.json (at least for @types/react-dom 16.0.11):
"resolutions": {
"@types/react": "16.4.13"
},
This is how the jupyterlab-gigantum-extension package is now configured, so that it builds.
Potential fixes include switching to npm, or at least suggesting developers use yarn so that they hit the same issues that users will hit. I assume that yarn devs proximity to the flow devs may cause continued lag in typescript support - so I'd LIKE to be able to just use npm. (I'm unaware of any remaining categorical benefits of npm at this point - I'm interested to hear if there are principled reasons to use it.)
Desktop (please complete the following information):
OS / Browser not relevant, but running in npm 8 or 10 works (tested on Ubuntu 18.04 and macOS), while yarn fails (testing only on Ubuntu).
which -a jupyter:
/home/dav/Projects/tmp/jupyterlab-gigantum-extension/env/bin/jupyter
/home/dav/Projects/tmp/jupyterlab-gigantum-extension/env/bin/jupyter
/home/dav/.local/bin/jupyter
One last thing - to make it explicit, I'm happy to help with a PR for a doc change on this. I'm also happy to TRY to help if you want to change to npm from yarn, but I suspect I may not be the most effective / efficient person at doing that!
Is there any particular reason why you have @types packages in your dependencies? They’re helpers for TS only, so they should normally be devDependencies (meaning they won’t get installed by end users installing your extension)
Thanks @quigleyj97 - this was simply outside the scope of what I was focused on. I've moved @types to devDependencies now.
UPDATE: ...and this means I don't need the resolutions clause anymore. I'm a bit mystified as to how this fixes the issue, but I'm willing to let it go for now.
lockbot
added
the
status:resolved-locked
Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
label
Aug 8, 2019
lockbot
locked as resolved and limited conversation to collaborators
Aug 8, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
status:resolved-lockedClosed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Describe the bug
This came up in discussion in #5215. It's a strange bug which can go unnoticed during development.
Basically,
jupyter labextension install
will fail on at least some packages using typescript and react because it always uses yarn. Yarn has a known issue with resolving types for react and react-dom.This bug means that a straight attempt to install a package with a naive approach to setting up typescript and React (and by naive, I mean expecting things to work across npm and yarn). See example below.
To Reproduce
I'm simply pointing you to a simple version of the gigantum extension, as I think it's quite clear to see what's going on. If an even simpler demo project is desired, please ask!
Assuming a throw-away python env with jupyterlab installed, set up for extension development:
You will see scads of (redundant) type errors.
Expected behavior
It builds with npm (which is the recommended development command in the docs), so it should install without error. Incompatibilities between yarn and npm will likely continue to perpetuate this problem.
Knowing that I need to accomodate yarn, I can follow the instructions provided on the DefinitelyTyped issue and include the following in my package.json (at least for @types/react-dom 16.0.11):
This is how the jupyterlab-gigantum-extension package is now configured, so that it builds.
Potential fixes include switching to npm, or at least suggesting developers use yarn so that they hit the same issues that users will hit. I assume that yarn devs proximity to the flow devs may cause continued lag in typescript support - so I'd LIKE to be able to just use npm. (I'm unaware of any remaining categorical benefits of npm at this point - I'm interested to hear if there are principled reasons to use it.)
Desktop (please complete the following information):
OS / Browser not relevant, but running in npm 8 or 10 works (tested on Ubuntu 18.04 and macOS), while yarn fails (testing only on Ubuntu).
Troubleshoot Output
I believe other outputs are irrelevant, but will provide if asked!
The text was updated successfully, but these errors were encountered: