Skip to content

Add startup extensions for JavaScript kernels#29

Open
MUFFANUJ wants to merge 3 commits into
jupyterlite:mainfrom
MUFFANUJ:startupExtensions
Open

Add startup extensions for JavaScript kernels#29
MUFFANUJ wants to merge 3 commits into
jupyterlite:mainfrom
MUFFANUJ:startupExtensions

Conversation

@MUFFANUJ

@MUFFANUJ MUFFANUJ commented Jun 2, 2026

Copy link
Copy Markdown

Closes #28

This PR adds a first-class startup extension path for JavaScript kernels, allowing integrations to preload modules and register comm targets when kernels start. It also exposes a registration service for extensions and applies startup hooks to new and active kernels.

@jtpio jtpio added the enhancement New feature or request label Jun 10, 2026
@MUFFANUJ MUFFANUJ force-pushed the startupExtensions branch from 49923fa to 0f5c610 Compare June 30, 2026 03:46
Comment thread packages/javascript-kernel-extension/src/index.ts Outdated
@krassowski

Copy link
Copy Markdown

@jtpio what do you think?

@jtpio

jtpio commented Jul 7, 2026

Copy link
Copy Markdown
Member

Thanks for working on this!

I haven't looked into the details of the changes yet. But if you both are fine with the current state please feel free to move forward with this. Otherwise I'll take a look soon.

Also we can aim for a 0.4.0 final release of this kernel in the coming days.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a first-class “kernel startup extensions” mechanism for @jupyterlite/javascript-kernel, enabling frontend integrations to preload runtime modules and register/unregister comm targets automatically as kernels start (and for already-running kernels), reducing the need for frontend requestExecute bootstrap payloads.

Changes:

  • Adds a startup-extension registry service (IJavaScriptKernelStartup) and wires it into the JavaScript kernel extension so registrations apply to new and active kernels.
  • Extends the runtime protocol/backend APIs to support module preloads and comm target registration/unregistration via the remote evaluator.
  • Updates kernel initialization to apply startup extensions before user code runs, and updates docs/dependencies accordingly.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Adds lockfile entries for the new @lumino/disposable dependency.
README.md Documents the new kernel startup extension API and usage example.
packages/javascript-kernel/src/startup.ts Introduces the startup extension registry interface and token.
packages/javascript-kernel/src/runtime_remote.ts Exposes preload/comm-target APIs over the Comlink remote runtime API.
packages/javascript-kernel/src/runtime_protocol.ts Extends the remote runtime protocol interface with preload/comm-target methods.
packages/javascript-kernel/src/runtime_evaluator.ts Implements module preload and comm target registration/unregistration in the evaluator.
packages/javascript-kernel/src/runtime_backends.ts Plumbs new remote APIs through iframe/worker backend readiness contexts.
packages/javascript-kernel/src/kernel.ts Applies/removes startup extensions during runtime readiness and kernel lifetime.
packages/javascript-kernel/src/index.ts Exports the new startup API surface.
packages/javascript-kernel/src/executor.ts Adds an executor-level importModule helper for resolved dynamic imports.
packages/javascript-kernel/src/comm/manager.ts Adds comm target presence checks and unregister support.
packages/javascript-kernel/package.json Declares @lumino/disposable dependency for the kernel package.
packages/javascript-kernel-extension/src/index.ts Adds an in-memory startup extension registry and wires it into kernel creation.
packages/javascript-kernel-extension/package.json Adds @lumino/disposable dependency and marks the kernel package as a singleton shared package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +126 to +133
trackKernel(kernel: JavaScriptKernel): void {
this._kernels.add(kernel);
const untrackKernel = (sender: JavaScriptKernel): void => {
this._kernels.delete(sender);
sender.disposed.disconnect(untrackKernel);
};
kernel.disposed.connect(untrackKernel);
}
Comment on lines +534 to +539
} catch (error) {
for (const target of registeredTargets.reverse()) {
await context.unregisterCommTarget(target.targetName);
}
throw error;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add kernel startup extension hooks for preloading modules and registering comm targets

4 participants