This is a toy example demonstrating how to start prototyping with Svelte in anywidget.
Since Svelte requires a compiler, we need to configure a bundler
to prototype our widget. This example extends from the Vite recipe
in the documentation, and importantly adds the svelte compiler in the vite.config.js
.
Make sure you have a Python environment with anywidget installed and the Node.js dependencies:
pip install jupyterlab anywidget
pnpm install
To get started you will need to run both a notebook server:
jupyterlab SvelteDemo.ipynb # open notebook
and run the vite dev server:
pnpm vite # run vite development server
You can now start developing the widget. Any changes to the JavaScript/Svelte source are automatically reflected in the notebook frontend.
Note: this example is incomplete and only demonstrates live prototyping with the development server. Follow the rest of the Vite recipe to learn the recommended bundling strategy for production.