gray-matter icon indicating copy to clipboard operation
gray-matter copied to clipboard

Library is not compatible with Edge runtime

Open bmamouri opened this issue 4 months ago • 0 comments

I am trying to use gray-matter in Next.js edge runtime. But it seems that the library is not compatible with edge runtime. I am getting the following error:

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

The error was caused by importing 'gray-matter/index.js' in './lib/api.ts'.

I get the error even when disabling eval:

  const {data, content} = matter(fileContents, {eval: false})

Is there any way to make this library edge friendly? Does anybody know any alternative that can be used with edge?

bmamouri avatar Oct 13 '24 13:10 bmamouri