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

Add optional field to sharedPackages in package.json -> jupyterlab #15151

Open
edublancas opened this issue Sep 22, 2023 · 3 comments
Open

Add optional field to sharedPackages in package.json -> jupyterlab #15151

edublancas opened this issue Sep 22, 2023 · 3 comments

Comments

@edublancas
Copy link

Problem

Currently, there is no way to mark javascript dependencies in package.json -> jupyterlab -> sharedPackages as optional.

Background:

I'm developing an extension that adds new functionality through toolbar buttons and widgets.

In an earlier release, I made ipywidgets a dependency because of the widgets. Now, I want to make ipywidgets an optional dependency, so I removed it from the pyproject.toml.

When testing the package, I realized that removing ipywidgets broke it, and upon debugging, I noticed that the error came because the extension could not find the @jupyter-widgets/base JS package. After some debugging, I noticed that my package.json has a jupyterlab section and a sharedPackages subsection (I created this project from the template).

It seems like since I no longer have ipywidgets as a dependency, @jupyter-widgets/base is never installed and the package breaks, because it's configured to share the @jupyter-widgets/base package (via sharedPackages)

For now, I eliminated ipywidgets from the sharedPackages section. This fixed the problem, but it isn't an ideal solution.

Proposed Solution

Add an optional field to sharedPackages in package.json -> jupyterlab to indicate that some dependency is optional.

Additional context

Jupyter forums question: https://discourse.jupyter.org/t/optional-dependency-for-jupyterlab-extension/21557

@welcome
Copy link

welcome bot commented Sep 22, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Sep 22, 2023
@JasonWeill JasonWeill added tag:Build System and removed status:Needs Triage Applied to new issues that need triage labels Sep 26, 2023
@fcollonval
Copy link
Member

Hey @edublancas

I think in your specific case, the sharedPackage is not the culprit but rather the way you specify the dependency between your widget plugin and the jupyter widget registry.

Specifically, that line:

requires: [IJupyterWidgetRegistry],

at https://github.com/ploomber/jupysql-plugin/blob/567fb10014fb0abbc0f993f1138657b111658774/src/widgets/index.ts#L17

should be

optional: [IJupyterWidgetRegistry],

Note: an optional token will be set to null if not provided. So you should test you got a token before registering your widget.

Then add back the entry in sharedPackages (bundled = false & singleton = true) and I think it will work.

@edublancas
Copy link
Author

hi @fcollonval, thanks for your feedback! I'll try the approach you suggested and see how it goes.

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

No branches or pull requests

3 participants