Unverified Commit 560bb266 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

MDX: Only set experimental.turbo if enabled (#72856)

To prevent this warning when only using Webpack
```
   ▲ Next.js 15.0.2
   - Experiments (use with caution):
     · turbo
```

cc @ztanner 


https://vercel.slack.com/archives/C03S8ED1DKM/p1731604512615979?thread_ts=1731602213.367809&cid=C03S8ED1DKM
parent dafe819f
module.exports = module.exports =
(pluginOptions = {}) => (pluginOptions = {}) =>
(nextConfig = {}) => { (inputConfig = {}) => {
const extension = pluginOptions.extension || /\.mdx$/ const extension = pluginOptions.extension || /\.mdx$/
const userProvidedMdxOptions = pluginOptions.options const userProvidedMdxOptions = pluginOptions.options
const mdxRsOptions = nextConfig?.experimental?.mdxRs const mdxRsOptions = inputConfig?.experimental?.mdxRs
const loader = mdxRsOptions const loader = mdxRsOptions
? { ? {
loader: require.resolve('./mdx-rs-loader'), loader: require.resolve('./mdx-rs-loader'),
...@@ -23,8 +23,28 @@ module.exports = ...@@ -23,8 +23,28 @@ module.exports =
}, },
} }
return Object.assign({}, nextConfig, { let nextConfig = Object.assign({}, inputConfig, {
experimental: Object.assign({}, nextConfig?.experimental, { webpack(config, options) {
config.resolve.alias['next-mdx-import-source-file'] = [
'private-next-root-dir/src/mdx-components',
'private-next-root-dir/mdx-components',
'@mdx-js/react',
]
config.module.rules.push({
test: extension,
use: [options.defaultLoaders.babel, loader],
})
if (typeof inputConfig.webpack === 'function') {
return inputConfig.webpack(config, options)
}
return config
},
})
if (process.env.TURBOPACK) {
nextConfig.experimental = Object.assign({}, nextConfig?.experimental, {
turbo: Object.assign({}, nextConfig?.experimental?.turbo, { turbo: Object.assign({}, nextConfig?.experimental?.turbo, {
rules: Object.assign({}, nextConfig?.experimental?.turbo?.rules, { rules: Object.assign({}, nextConfig?.experimental?.turbo?.rules, {
'*.mdx': { '*.mdx': {
...@@ -41,23 +61,8 @@ module.exports = ...@@ -41,23 +61,8 @@ module.exports =
} }
), ),
}), }),
}),
webpack(config, options) {
config.resolve.alias['next-mdx-import-source-file'] = [
'private-next-root-dir/src/mdx-components',
'private-next-root-dir/mdx-components',
'@mdx-js/react',
]
config.module.rules.push({
test: extension,
use: [options.defaultLoaders.babel, loader],
}) })
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
} }
return config return nextConfig
},
})
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment