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

@next/mdx - import() breaks .mdx files in development #77554

Open
fullyherge opened this issue Mar 27, 2025 · 0 comments
Open

@next/mdx - import() breaks .mdx files in development #77554

fullyherge opened this issue Mar 27, 2025 · 0 comments
Labels
Markdown (MDX) Related to Markdown with Next.js.

Comments

@fullyherge
Copy link

Link to the code that reproduces this issue

https://github.com/fullyherge/next-mdx-import-repro/blob/main/src/app/page.tsx

To Reproduce

  1. Run the application locally (npm run dev)
  2. Get error
 ⨯ TypeError: Cannot read properties of undefined (reading 'A')
    at _createMdxContent (webpack-internal:///(rsc)/./src/app/stuff.mdx:15:73)
    at MDXContent (webpack-internal:///(rsc)/./src/app/stuff.mdx:37:16) {
  digest: '4239156248'
}

Changing to import Stuff from "stuff.mdx" works fine, but my use case in existing application that I just updated to Next 15 and React 19 is to import all .mdx files from a certain folder, via require.context.
It works fine in production builds.

Current vs. Expected behavior

Importing .mdx file via import() gives an error.
Expected behaviour is for it to work, like import x from does.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.18.2
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4).
  eslint-config-next: 15.2.4
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.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)

Additional context

No response

@github-actions github-actions bot added the Markdown (MDX) Related to Markdown with Next.js. label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Markdown (MDX) Related to Markdown with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant