Override an extension

Hello, what I want to do is to override an extension. For example, I want to change how launcher-extension works. I got a fork and changed what I want, but how can I replace it with the current one?

Certainly have a solid read-through of the docs.

You’ll likely want to start a new project with the cookiecutter linked from that page, and then move your patched upstream package into the src folder, but keep the package.json.

In said package.json#/jupyterlab you need:

"jupyterlab": {
  # ... the other stuff like outputDir
  "disabledExtensions": ["@jupyterlab/launcher-extension:plugin"]
}

In your src/index.ts you then need to ensure you grab the upstream ILauncher token, and repeat much of what’s in the upstream index.ts.

import {ILauncher} from `@jupyterlab/launcher`
// ...
/**
 * A service providing an interface to the the launcher.
 */
const plugin: JupyterFrontEndPlugin<ILauncher> = {
  activate,
  id: '@your-namespace/your-launcher:plugin',
  requires: [ITranslator],
  optional: [ILabShell, ICommandPalette, IFileBrowserFactory],
  provides: ILauncher,
  autoStart: true
};

Then you should be able to:

python -m pip install -e .
jupyter labextension develop . --overwrite
jlpm watch

And in a separate terminal:

jupyter lab

And be able to do the change-hardreload-test workflow.

2 Likes

Hello, I was also thinking about doing that but I just wanted to ask if there is any recommended solution, thank you.