-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Error occur when build with next-mdx-remote and next.js standalone option #283
Comments
same with MDX-Bundler.
|
Both are using pnpm? I'll try to test it tomorrow |
Ok, that's a problem with shiki and next.js. Shiki import languages and themes by fs, when run You can check out by build next.js with standalone, then go to const nextConfig = {
output: 'standalone'
} The solution is // in your next.js page
export const config = {
// pnpm in my case, maybe 'node_modules/**/shiki/**/*.json' for npm or yarn.
unstable_includeFiles: ['node_modules/.pnpm/**/shiki/**/*.json'],
}; After add above lines, CodeHike with next-remote-mdx works fine for me . |
reference: https://stackoverflow.com/questions/71422446/nextjs-force-dependency-with-outputstandalone-option |
Above solution not works for mdx-bundler. Basically same error with kentcdodds/mdx-bundler#158 |
Yes i am using pnpm! |
This is very interesting, thanks for your help! Let me test it further |
Due to #290 and code-hike/codehike#283, In order to use code-hike in Next.js standalone server, we need to provide additional information for Next.js to not tree-shake shiki languages and themes files. This commit solves this problem by using "unstable_includeFiles" config
@xWil what's the error with mdx-bundler? it may be a different issue |
Local-dev works great, the error above was came from next.js server rendering. |
you are using mdx-bundler inside |
Yeah, all pages are rendered inside https://nextjs.org/docs/api-reference/data-fetching/get-static-paths |
this fixed the issue for me on getServerSideProps
|
Also just hit this problem. // bottom of /pages/references/javascript/[...slug].tsx
// yes.. tried them all
export const config = {
unstable_includeFiles: [
'node_modules/.pnpm/**/shiki/**/*.json',
'node_modules/**/shiki/**/*.json',
'node_modules/.npm/shiki/**/*.json',
'/var/task/node_modules/shiki/languages/abap.tmLanguage.json',
'node_modules/shiki/languages/abap.tmLanguage.json',
'node_modules/shiki/**/*.json',
],
} |
Ideally the syntax highlighting should be done at build time, but I'm going to replace shiki with something custom soon and these problems should disappear. |
I'm working on PR #308. There's a canary version there if anyone wants to try it and see if it fixes the problem. |
should be fixed with |
Running v0.8.0, still running into this issue, Ill figure it out and report back though. |
What's the error? |
|
That shouldn't happen, can you open a new issue with the steps to reproduce it? |
I can do that, but I will need to find out how to reproduce it first, im trying to debug it on my end, then I'll open the issue. EDIT: It's late so I will have to look into creating reproducible steps and issue tomorrow, in the meantime if you are using NextJs, add this to your
|
Context
Hi!! Thank you for building and maintaining such a great package. I am encountering some issues when using
codehike
+next-mdx-remote
+ Nextjs with the standalone option.During development, the code goes smoothly. But after building it with the Next.js standalone option, the app can't find some file that codehike relied on and throw Internal Error.
The way to reproduce
npm run build
node ./.next/standalone/server.js
I have set up a docker image if this could help.
npm run docker:app:develop
The text was updated successfully, but these errors were encountered: