Next.js Discord

Discord Forum

Unable to load remark/rehype plugins with turbo

Unanswered
Lazuli Bunting posted this in #help-forum
Open in Discord
Avatar
Lazuli BuntingOP
Since recently, I'm encountering a weird error that doesn't go away when loading MDX plugins with --turbo enabled. It used to work just find, but even when downgrading nextjs, it doesn't go away for some reason. Cleared node_modules and lockfile, but still.

Error: loader /Users/xxx/dev/yyy/nodemodules/.pnpm/@next+mdx@15.0.0-rc.1@mdx-js+loader@3.0.1_webpack@5.95.0esbuild@0.21.5__@mdx-js+react@3.0._3bd4xfm4qsleqtadshqh6vkxza/node_modules/@next/mdx/mdx-rs-loader.js for match "*.mdx" does not have serializable options. Ensure that options passed are plain JavaScript objects and values

It works fine if I remove all plugins, but as soon as I add even one, it fails.

const withMDX = createMdx({
  options: {
    remarkPlugins: [remarkGfm],
   }
});

export default withMDX({
   experimental: {
       mdxRs: {
         mdxType: "gfm",
       }
   }
});


Runs just fine without --turbo

2 Replies

Avatar
Northern snakehead
You are using Turbo, right?
There is a function ensureLoadersHaveSerializableOptions being called and it does not like the plugins being passed as parameters (they are not serializable)!
Avatar
Lazuli BuntingOP
Yes, I was. But I stopped using next-mdx / mdxrs altogether. It doesn't provide a good way to build reusable mdx pages anyways (and causes more problems than provides solutions), so migrated to content collections instead.