codehike icon indicating copy to clipboard operation
codehike copied to clipboard

not work after deployed to vercel

Open lili21 opened this issue 3 years ago • 2 comments

I'm running the mdx compiler on the server side on each page request, it works fine on my local machine, but on on vercel.

the error message

no such file or directory, open '/var/task/node_modules/shiki/languages/abap.tmLanguage.json'

lili21 avatar Oct 16 '22 08:10 lili21

Hi, see https://github.com/code-hike/codehike/issues/283#issuecomment-1277017015

this fixed the issue for me on getServerSideProps

// in your next.js page 
export const config = {
  unstable_includeFiles: ['node_modules/**/shiki/**/*.json'],
};

pomber avatar Oct 16 '22 10:10 pomber

I'm using the remix framework. what config should I apply?

lili21 avatar Oct 16 '22 11:10 lili21

should be fixed with v0.8.0, let me know how it goes

pomber avatar Jan 16 '23 10:01 pomber

Could not resolve "@code-hike/mdx/dist/components.cjs.js"

I'm using it with mdx-bundler.

lili21 avatar Jan 25 '23 06:01 lili21

Could not resolve "@code-hike/mdx/dist/components.cjs.js"

I'm using it with mdx-bundler.

Can you share more details? We have a remix example and a mdx-bundler example (in the examples folder), compare them with yours and check what's different

pomber avatar Jan 25 '23 07:01 pomber

sure. I'm doing it on the server side.

import { bundleMDX } from "mdx-bundler";
import { remarkCodeHike } from "@code-hike/mdx";
import theme from "shiki/themes/nord.json";

export const loader = async () => {
  const data = await fetchFromCRM();

  const result = await bundleMDX({
      source: data,
      mdxOptions(options, frontmatter) {
        options.remarkPlugins = [
          ...(options.remarkPlugins ?? []),
          [
            remarkCodeHike,
            {
              showCopyButton: true,
              theme,
            },
          ],
        ];

        return options;
    },
  });

  return { result }
}

lili21 avatar Jan 25 '23 12:01 lili21

hmm, you may need to use autoImport: false

pomber avatar Jan 25 '23 12:01 pomber