Making JupyterLab Extensions work with versions 2 and 3

Hi folks,

I’m the maintainer of Plotly.py and hence of the main Plotly extensions: jupyterlab-plotly and plotlywidget. I’m looking for some advice about how to go about supporting JupyterLab 3 now that it’s out. The Extension Migration Guide seems to suggest a way to make the next version of our extensions work with JupyterLab 3, but this will break compatibility with JupyterLab 2, am I reading it right?

Is there an example somewhere of the changes I would need to make to be able to provide a single source extension that is compatible with JupyterLab 2 and JupyterLab 3, so as to keep our installation docs as simple as possible? I want to avoid having to say “if you’re using JupyterLab 2, install this, but if you’re using JupyterLab 3, install that” if at all possible :slight_smile:

Thanks!
Nicolas

For source extensions, if the APIs you depend on did not change, you may be able to just introduce a new || dependency version for the jlab 3 dependencies. If APIs you depend on changed, of course it will be more difficult to support both versions.

In other words, if the APIs you used did not change, you might be able to just do something like changing:

"@jupyterlab/rendermime-interfaces": "^1.3.0 || ^2.0.0",

to

 "@jupyterlab/rendermime-interfaces": "^1.3.0 || ^2.0.0 || ^3",
2 Likes

The above seems to work for our extension! :slight_smile:

2 Likes

@jasongrout if I can impose on your time just a little bit more… We have another extension that needs upgrading and I’m unsure what the most backwards-compatible fix is :slight_smile:

Here’s the PR where I’ve tried to do this, which lists the error I see: trying to make extension work with jlab3 by nicolaskruchten · Pull Request #53 · plotly/jupyterlab-chart-editor · GitHub

Is there a version of @lumino/widgets I can depend on in package.json which makes this error go away and lets me publish a single extension that works with JLab 2 and 3?

I replied on the issue.

1 Like