Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use MDX with turbopack #74424

Open
max-degterev opened this issue Dec 30, 2024 · 0 comments
Open

Unable to use MDX with turbopack #74424

max-degterev opened this issue Dec 30, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Markdown (MDX) Related to Markdown with Next.js.

Comments

@max-degterev
Copy link

Link to the code that reproduces this issue

https://github.com/max-degterev/nextjs-mdx-bugged

To Reproduce

  1. Follow official documentation steps described here https://nextjs.org/docs/pages/building-your-application/configuring/mdx#add-an-mdx-componentstsx-file
  2. Attempt to use plugins with turbopack as described here https://nextjs.org/docs/pages/building-your-application/configuring/mdx#using-plugins-with-turbopack

Current vs. Expected behavior

Next fails with an error:

 ⨯ ./src/app/test/page.mdx
Error evaluating Node.js code
TypeError: Expected usable value, not `remark-breaks`
    [at add (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/unified/lib/index.js:1100:15)]
    [at addList (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/unified/lib/index.js:1134:11)]
    [at Function.use (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/unified/lib/index.js:1074:9)]
    [at createProcessor (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/@mdx-js/mdx/lib/core.js:209:6)]
    [at split (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:85:37)]
    [at process (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:62:31)]
    [at Proxy.loader (file:///Users/max/Repositories/nextjs-mdx-bugged/node_modules/@mdx-js/loader/lib/index.js:89:3)]
    [at /Users/max/Repositories/nextjs-mdx-bugged/node_modules/@mdx-js/loader/index.cjs:32:26]

Using this config:

const withMDX = createMDX({
 options: {
   remarkPlugins: ['remark-breaks'],
   rehypePlugins: [['rehype-external-links', {
     target: '_blank', rel: ['noopener', 'noreferrer', 'nofollow'],
   }]],
 },
})

Which also produces type errors. Is there something I'm missing?

Provide environment information

~/Repositories/nextjs-mdx-bugged │ master  npx --no-install next info                                                                                                         ✔
/bin/sh: yarn: command not found
/bin/sh: pnpm: command not found

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.12.0
  npm: 10.9.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.1.3 // Latest available version is detected (15.1.3).
  eslint-config-next: 15.1.3
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

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

Markdown (MDX)

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

next dev (local), next build (local), next start (local), Other (Deployed)

Additional context

No response

@max-degterev max-degterev added the bug Issue was opened via the bug report template. label Dec 30, 2024
@github-actions github-actions bot added the Markdown (MDX) Related to Markdown with Next.js. label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Markdown (MDX) Related to Markdown with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant