next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Dev server not working when using `@next/mdx` with plugins and `--turbo`

Open carloscuesta opened this issue 1 year ago • 4 comments

Link to the code that reproduces this issue

https://github.com/carloscuesta/next-mdx-turbo-plugins-issue

To Reproduce

  1. Clone the provided repository
  2. Install the dependencies
  3. Run the development server

Current vs. Expected behavior

I'm expecting that the dev server starts normally however the process ends with the following error:

Error: loader /Users/carloscuesta/Downloads/next-mdx-turbo-issue/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/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.

The error doesn't happen when I remove the plugin that I'm passing into the withMDX function:

❌ Error: pnpm run dev (with --turbo flag)

export default withMDX({
  options: {
    remarkPlugins: [remarkGfm]
  }
})(nextConfig);

✅ No error: pnpm run dev (with --turbo flag)

export default withMDX({
  options: { remarkPlugins: [] }
})(nextConfig);

error

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.1 // Latest available version is detected (15.0.1).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Markdown (MDX), Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

carloscuesta avatar Oct 24 '24 18:10 carloscuesta