-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Open
Labels
Markdown (MDX)Related to Markdown with Next.js.Related to Markdown with Next.js.
Description
Link to the code that reproduces this issue
https://github.com/fullyherge/next-mdx-import-repro/blob/main/src/app/page.tsx
To Reproduce
- Run the application locally (
npm run dev) - 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/AWhich 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
pjlife, itsjokerdev and richardasymmetric
Metadata
Metadata
Assignees
Labels
Markdown (MDX)Related to Markdown with Next.js.Related to Markdown with Next.js.