How to create a VsCode Notebook Renderer that is part of a VsCode extension?

48 Views Asked by At

I am trying to create a VsCode notebook renderer.

I already have a VsCode extension that provides a lot of functionality. I am trying to reuse that functionality in the renderer. I am following the example from https://github.com/microsoft/notebook-extension-samples?tab=readme-ov-file#readme but I am trying to avoid using the webpack to build the renderer which should be part of my VSIX package.

Everything builds fine, but at runtime I am getting this error:

"Typescript ReferenceError: exports is not defined"

Is there any way to have this renderer built without using webpack?

The renderer code is:

import type { ActivationFunction } from 'vscode-notebook-renderer';

export const activate: ActivationFunction = context => ({
  renderOutputItem(data, element) {
    element.innerText = JSON.stringify(data.json());
  }
});

and package.json:

   "notebookRenderer": [
      {
        "id": "My-notebook-renderer",
        "displayName": "My Notebook Renderer",
        "entrypoint": "./out/notebook/index.js",
        "mimeTypes": ["x-application/my-notebook-renderer"],
        "requiresMessaging": "optional"
      }
    ]
0

There are 0 best solutions below