Skip to content

Commit dad39f0

Browse files
wbinnssmitheps1lon
authored andcommitted
Turbopack: Add support for extension regex in @next/mdx (#78734)
Closes #78563 (replaces it) Resolves #78348 This allows users the same flexibility they have with `@next/mdx` for webpack. It depends on #78733. Test Plan: Included the integration test from #78563
1 parent 94237fb commit dad39f0

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

packages/next-mdx/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ module.exports =
4949
if (process.env.TURBOPACK) {
5050
nextConfig.turbopack = Object.assign({}, nextConfig?.turbopack, {
5151
rules: Object.assign({}, nextConfig?.turbopack?.rules, {
52-
'*.mdx': {
52+
'#next-mdx': {
5353
loaders: [loader],
5454
as: '*.tsx',
5555
},
5656
}),
57+
conditions: {
58+
'#next-mdx': {
59+
path: extension,
60+
},
61+
},
5762
resolveAlias: Object.assign({}, nextConfig?.turbopack?.resolveAlias, {
5863
'next-mdx-import-source-file':
5964
'@vercel/turbopack-next/mdx-import-source',
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import MDXContent from './mdx-file.mdx'
1+
import MDContent from './md-file.md'
2+
23
export default function Page() {
34
return (
45
<>
5-
<MDXContent />
6+
<MDContent />
67
</>
78
)
89
}
File renamed without changes.

test/e2e/app-dir/mdx/types/mdx.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ declare module '*.mdx' {
44
let MDXComponent: (props) => JSX.Element
55
export default MDXComponent
66
}
7+
8+
declare module '*.md' {
9+
import type { JSX } from 'react'
10+
let MDXComponent: (props) => JSX.Element
11+
export default MDXComponent
12+
}

0 commit comments

Comments
 (0)