Automating Svelte tooling with Quarto #2494
Replies: 6 comments 5 replies
-
I'd initially ruled a Quarto extension out, since I'd been thinking about it in terms of run-time dependencies. But I suppose you could write one that includes stuff like a |
Beta Was this translation helpful? Give feedback.
-
Oh! I'll have to read through this Svelte + Deno article, and its prequel, a bit more. It looks promising! |
Beta Was this translation helpful? Give feedback.
-
(There's a feature in quarto which we don't advertise because we haven't had the chance to make sure it's solid, so keep that caveat in mind) If you import a javascript module from your OJS tags and render with wrt Svelte: I would rather not involve the Svelte compiler, since it's my understanding that their process is a lot more involved. |
Beta Was this translation helpful? Give feedback.
-
@cscheid Hoping I can pick your brain a little bit more on this! I'm powering on with trying to automate Svelte compilation using an external Svelte compiler (not trying to mess with Quarto's Deno!). My current assumption is that I would have a pre-render script and a post-render script:
Regarding that last step: by the time the rendered HTML is opened, I generally need to end up with a statement like: Circles = import("/Circles.js"); So it could start (in the Quarto doc) with something as simple as: Circles = import("/Circles.svelte"); So I need to turn the latter (or some other statement that identified the Svelte component) into the former post-render. Would a statement like the latter cause a problem with Quarto's build process (in between my two scripts)? I'm thinking particularly of it getting sucked into (I can also have my post-render script identify some other magic syntax or a commented statement that would get ignored by Quarto's render, so it's not a showstopper for me!) |
Beta Was this translation helpful? Give feedback.
-
We have a first working version of this up at https://github.com/360-info/sverto! Here's a barchart you can control in OJS, for example. I think it's about ready for some feedback from external users. Thanks very much for the guidance, @cscheid! |
Beta Was this translation helpful? Give feedback.
-
This is very cool! Has anyone on the thread tried the reverse: Embedding a rendered quarto block into a SvelteKit page? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been getting into Svelte lately, and I've had some nice early success compiling Svelte components as ES bundles and embedding them in Quarto documents:
svelte-quarto.mov
I'd really like to expand on this and use Svelte more often for charts that animate or transition in response to OJS reactivity. There are two approaches I could take (or, more likely, a combination of them):
.svelte
file (perhaps one that uses sub-components imported as above) that sits alongside my Quarto doc and is compiled and bundled on render.The way forward for the first option is pretty clear to me. The second is what I've done in the example above, but I've essentially included an entire Svelte project bootstrap as a sub-directory (configured to produce one JS bundle for each
.svelte
file in a/charts
directory), compiled it separately and then rendered with the bundled JS included. That's not terrible, but one of the things I love about Quarto is how much of the JS tooling it abstracts away.I'd love to get to a place where I can set up a Quarto doc with
myChart.svelte
sitting alongsidedocument.qmd
. I'm still a novice when it coms to bundle tooling, but I'm imagining there're a few tasks involved:require
statements with.svelte
extensions and swapping them for the equivalent expected.js
bundle output;.svelte
files and placing the.js
bundle in either the document_files
folder or the websitesite_libs
(contrast my approach above, where I listed the.js
bundle in the project YAML underresources
)npm install
Basically, I'm just trying to work out how to keep my project spaces fairly clean and avoid them spiralling into full-blown web dev projects! Just thinking out loud here, but any guidance from pros would be welcome!
Beta Was this translation helpful? Give feedback.
All reactions