jupyterlab / extension-cookiecutter-ts

A cookiecutter recipe for JupyterLab extensions in Typescript
BSD 3-Clause "New" or "Revised" License
181 stars 88 forks source link

3.0 branch: jlpm install includes two incompatible versions of @lumino/widgets, breaks build #312

Closed tomjakubowski closed 1 year ago

tomjakubowski commented 1 year ago

Description

When creating an extension from the 3.0 branch, two versions of @lumino/widgets are included which causes the Typescript bulid to fail.

Reproduce

  1. conda create -n fext --override-channels --strict-channel-priority -c conda-forge -c nodefaults jupyterlab=3 cookiecutter nodejs
  2. conda activate fext
  3. cookiecutter https://github.com/jupyterlab/extension-cookiecutter-ts --checkout 3.0 (defaults for all prompts)
  4. cd myextension
  5. pip install -ve .

This produces an error about mismatched interfaces in @lumino/widgets.

  $ tsc --sourceMap
  node_modules/@jupyterlab/rendermime/lib/widgets.d.ts(8,31): error TS2420: Class 'RenderedCommon' incorrectly implements interface 'IRenderer'.
    The types of 'title.owner.layout' are incompatible between these types.
      Type 'import("/Users/tom/tmp/myextension/node_modules/@lumino/widgets/types/layout").Layout | null' is not assignable to type 'import("/Users/tom/tmp/myextension/node_modules/@jupyterlab/rendermime-interfaces/node_modules/@lumino/widgets/types/layout").Layout | null'.
        Type 'import("/Users/tom/tmp/myextension/node_modules/@lumino/widgets/types/layout").Layout' is not assignable to type 'import("/Users/tom/tmp/myextension/node_modules/@jupyterlab/rendermime-interfaces/node_modules/@lumino/widgets/types/layout").Layout'.
          Property '[Symbol.iterator]' is missing in type 'import("/Users/tom/tmp/myextension/node_modules/@lumino/widgets/types/layout").Layout' but required in type 'import("/Users/tom/tmp/myextension/node_modules/@jupyterlab/rendermime-interfaces/node_modules/@lumino/widgets/types/layout").Layout'.

The culprit is that @jupyterlab/rendermime-interfaces version 3.8.2 is bringing in an extra version of @lumino/widgets which is incompatible. I diagnosed this using jlpm list.

% jlpm list --pattern '@lumino/widgets'
yarn list v1.21.1
├─ @jupyterlab/rendermime-interfaces@3.8.2
│  └─ @lumino/widgets@2.2.0
└─ @lumino/widgets@1.37.2

I am able to work around the issue by instructing yarn to use rendermime-interfaces 3.6.5:

  "resolutions": {
    "@jupyterlab/rendermime-interfaces": "3.6.5"
  },

Expected behavior

A working build w/ only one resolved version of @lumino/widgets

Context

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
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! :wave:
Welcome to the Jupyter community! :tada:

fcollonval commented 1 year ago

Hey @tomjakubowski thanks for reporting. I would recommend you to use the following resolution instead of the one you mentionned:

"resolutions": {
  "@lumino/widgets": "^1.0.0"
}

This will make your set up more robust.

fcollonval commented 1 year ago

@tomjakubowski I updated the 3.0 branch for this.