Skip to content

Library is not compatible with Edge runtime #175

Open
@bmamouri

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions