-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: Code Component breaks on Vercel SSR #5357
Comments
Since we own this dependency internally, what if we took over theme loading as a way to fix this ourselves? If you translate this issue to English, you can see someone providing and hooking up the themes themselves, which works around the broken automatic theme loading inside of Shiki: https://zenn.dev/thiragi/scraps/4150e766090adb We could also track down this issue to the Shiki repo, and see if they are willing to fix internally. I haven't done this yet, but my guess is that if it was fixible in Shiki they would have already... |
Think this is the same underlying cause as #5253. Vercel copies files by examining your built code and doesn't find dynamic stuff. We need some mechanism where an integration can tell Vercel of additional files that should be copied. The user can do this with |
If it helps, this would be (roughly) the snippet to skip the bug:
|
Here's my config with a workaround for anyone who needs:
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import react from "@astrojs/react";
import vercel from "@astrojs/vercel/serverless";
const shikiResourcePaths = Object.keys(
import.meta.glob([
"./node_modules/.pnpm/shiki@*/node_modules/shiki/languages/*.tmLanguage.json",
"./node_modules/.pnpm/shiki@*/node_modules/shiki/themes/*.json",
]),
);
export default defineConfig({
output: "server",
adapter: vercel({
includeFiles: shikiResourcePaths,
}),
}); |
What version of
@astrojs/compiler
are you using?latest
What package manager are you using?
pnpm
What operating system are you using?
mac
Describe the Bug
The
<Code>
component works in dev, and works in all other build output formats that I tried (static, SSR /w@astrojs/node
).However, when I use
@astrojs/vercel
and deploy, the build is successful but then I get the following error when I request a route that uses the<Code>
component:It looks like this is the same issue as this: code-hike/codehike#283 (comment)
The problem is that Astro/Vite does not detect the dependency on these files, since Shiki uses
fs
to load then instead ofrequire/import
. Therefore, they never end up in the final build. Next.js had to solve this problem more globally with a workaround calledunstable_includeFiles
, we may want to do the same.Link to Minimal Reproducible Example
https://gist.github.com/FredKSchott/b875fec67552289e75ebc594499ccc32
The text was updated successfully, but these errors were encountered: