Using libraries from JSR in SvelteKit
Hi! I'm playing around with using SvelteKit with Deno 2, and tried to import a library from Deno's standard library to use that with SvelteKit. This, however, adds it into deno.json instead of package.json and I'm not able to import it in Svelte code. What would be needed to be able to import modules from JSR and make them work in SvelteKit?
5 Replies
Try using the
jsr
binary, eg. npx jsr add @std/fmt
so,
deno run -A npm:jsr add @std/fmt
?
feels a bit convoluted, but alright 😅Yeah, it is convoluted
We are aware of this problem - it's because SvelteKit uses a bundler that currently doesn't understand
jsr:
imports in deno.json
We're trying to fix the situation to make it more approachableAh okay, yeah that makes sense. Thank you for the response! :)
sveltekit uses vite for bundling, you should be able to use the deno vite plugin https://github.com/denoland/deno-vite-plugin (instructions in readme) to support deno-specific features
GitHub
GitHub - denoland/deno-vite-plugin: Vite plugin to enable Deno reso...
Vite plugin to enable Deno resolution inside vite. - denoland/deno-vite-plugin