BearToCode / carta

A lightweight, fast and extensible Svelte Markdown editor and viewer.
https://beartocode.github.io/carta/
MIT License
252 stars 8 forks source link

Build fails for SvelteKit vercel adapter #54

Open dit7ya opened 3 weeks ago

dit7ya commented 3 weeks ago

I am just trying out the v4 of this library in a SvelteKit project, but the build fails, probably due to this issue of shiki trying to load files using fs - https://github.com/vercel/vercel/discussions/8726.

BearToCode commented 3 weeks ago

Hello, can you provide some more details? Also, a simple example would be great. I'm also using the latest version inside of a Vercel project, and it's working fine.

dit7ya commented 3 weeks ago

Thanks for the prompt response. I dug a little deeper, and found out that it only breaks for the edge runtime of vercel.

import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

const config = {

    preprocess: vitePreprocess(),

    kit: {
        adapter: adapter({runtime: 'edge'})
    }
};

export default config;
BearToCode commented 3 weeks ago

It looks like the edge runtime only supports web APIs. From my little experience with it, you should use the edge runtime to handle requests that require fast responses near users, so probably you are accidentaly importing the component/Carta class in your +server.ts endpoint configured to use the edge runtime, as I don't see a reason you would import it there.

If, for some reason, you need to actually use it there, I honestly don't think there is a way for me to help you out, as the issue seems to be with Shiki. You might have better chances to have it fixed asking there.