-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Documentation Link
https://github.com/manzt/anywidget/tree/main/packages/svelte
Issue
thanks so much for #869! 🙏
i took a close look at https://github.com/manzt/ipyfoo-svelte which is very helpful. there are a few things i'm still struggling with though. Structure.svelte
component imports some file loading/reading utilities
import {
decompress_file,
handle_url_drop,
load_from_url,
parse_any_structure,
} from '$lib/io'
which results in a dynamic import in the rolldown-compiled JS file that fails to resolve
const { decompress_data } = await import("./decompress-BatFPLgB.js");
>>> TypeError: Failed to resolve module specifier "./decompress-BatFPLgB.js". Invalid relative url or base scheme isn't hierarchical.
directory structure:
pymatviz/widgets/static
├── composition.css
├── composition.js
├── decompress-_eNwcOzc.js
├── decompress-BatFPLgB.js
├── structure.css
└── structure.js
not sure if rolldown
should have compiled this to use import.meta.url
const { decompress_data } = await import(new URL('./decompress-BatFPLgB.js', import.meta.url));
or how to achieve that.
Recommended improvement
maybe the docs could cover how to handle 3 cases:
-
Svelte files importing from JS/TS files, especially ones that contain
$state
runes for shared component state which rolldown doesn't pass torollup-plugin-svelte
and so the runes don't get compiled to vanilla JS. could be documented by extracting the count state in https://github.com/manzt/ipyfoo-svelte/blob/main/web/Widget.svelte into a state.svelts.js file. -
how to compile multiple widgets with one rolldown config. seems to be as simple as exporting as array of configs (but would have saved me some trial and error if it was documented)
import { defineConfig } from 'rolldown' import svelte from 'rollup-plugin-svelte' export default defineConfig([{ input: './structure.ts', output: { dir: './static/', format: 'es', }, plugins: [ svelte({ compilerOptions: { runes: true } }), ], }, { input: './composition.ts', output: { dir: './static/', format: 'es', }, plugins: [ svelte({ compilerOptions: { runes: true } }), ], }])
-
what's the best way to include data files (JSON/YAML/...) needed by a component (use some rollup plugin to ESM-import or configure rolldown to copy it over or something else)?
sorry for the slightly messy issue. will spend some more time tomorrow figuring things out and maybe come up with more actionable suggestions