Skip to content

ES modules from two kernels in one JupyterLab page share one registry #116

Description

@maartenbreddels

ES modules defined with define_module share one registry per browser page, so two kernels in one JupyterLab page can see each other's modules.

Problem

JupyterLab shows notebooks with different kernels in one browser page.
The ES module support in ipyvue (#106, #108) and ipyreact (#83) keeps one module registry and one es-module-shims import map per page, keyed only by the module name.

  • Two kernels that define different module names work.
  • Two kernels that define the same name with different code overwrite each other. The last load wins for both notebooks, and a hot reload in one notebook changes the other.
  • Imports between modules go through the single import map, so they collide in the same way.
  • A Vue plugin module from one kernel is installed on every ipyvue app on the page, so in the other notebooks too (Vue 2 already has one global component registry).
  • Solara is not affected: each browser page has one kernel.

Mario raised this. We do not know the best solution yet, so we merge the ES module PRs with this limit documented and track it here.

Possible directions

  • Key the module registry by widget manager (one per kernel), so a widget only gets modules from its own kernel. This is a moderate change in ipyvue and ipyreact.
  • Imports between modules are the hard part: es-module-shims has one import map per page. One option is a kernel-specific name per module (for example a prefix) that is rewritten when the module is imported.
  • Decide whether plugins should be installed only on the apps of the kernel that defined them.

Related

🤖 Generated with Claude Code

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions