Skip to content

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

Closed
@carloscuesta

Description

@carloscuesta

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/@next+mdx@15.0.1_@mdx-js+loader@3.1.0_acorn@8.13.0_/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 --turbopack

exportdefaultwithMDX({options: {remarkPlugins: [remarkGfm]}})(nextConfig);

✅ No error: pnpm run dev --turbopack

exportdefaultwithMDX({options: {remarkPlugins: []}})(nextConfig);

✅ No error: pnpm run dev (without turbo flag)

exportdefaultwithMDX({options: {remarkPlugins: [remarkGfm]}})(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Markdown (MDX)Related to Markdown with Next.js.TurbopackRelated to Turbopack with Next.js.bugIssue was opened via the bug report template.linear: turbopackConfirmed issue that is tracked by the Turbopack team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close