-
Trying to make javascript imported code (local or library) available to all notebooks. It seems not possible to import a javascript code (installed as npm package, or local code), that exports and defines web components (extending the
Also tried patching the global namespace with jsDom, as when using this dependency in node, but same error. // observable (try) patch for HTMLElement not defined with different properties
import jsdom from "jsdom";
const { JSDOM } = jsdom;
global.window = new JSDOM().window;
global.document = new JSDOM().window.document;
global.HTMLElement = new JSDOM().window.HTMLElement;
global.customElements = new JSDOM().window.customElements;
global.DOMParser = new JSDOM().window.DOMParser;
// Unexpected error: HTMLElement is not defined Trying with this lib to import on this page (here as local js code in the Importing from a markdown notebook is possible, following the javascript docs, as it seems this code is evaluated in the browser. The issue arises when importing a library or custom code from the framework config, as it seems this code is evaluated in node. AlternativeCurrently, importing the library in each notebook, and it works without error (as npm package or local code). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
If you want to import code on the client (browser), it needs to live in the docs/ directory (you can't call code that lives outside, in |
Beta Was this translation helpful? Give feedback.
-
To migrate a
The issue seems to be that the |
Beta Was this translation helpful? Give feedback.
If you want to import code on the client (browser), it needs to live in the docs/ directory (you can't call code that lives outside, in
../src/
). However when I install your PR locally and try to do this (by just adding a symlink from src to docs/src and fixing a few paths), I quickly hit a wall because one of the dependent libraries does not work in the browser. I probably misunderstand the question.