BearToCode / carta

A lightweight, fast and extensible Svelte Markdown editor and viewer.

Home Page:https://beartocode.github.io/carta/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails for SvelteKit vercel adapter

dit7ya opened this issue · comments

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 - vercel/vercel#8726.

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.

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;

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.

Closing due to inactivity. Also, this issue can probably be fixed by using the new __ENABLE_CARTA_SSR_HIGHLIGHTER__ flag.