rsnext/packages/next-mdx/index.js
Travis Arnold c6dafda053
(next/mdx) set providerImportSource to react by default (#39954)
Hello, this PR simply configures the `next/mdx` package to use `{ providerImportSource: '@mdx-js/react' }` by default. This is now [required in version 2](https://mdxjs.com/packages/mdx/#optionsproviderimportsource) and causes a lot of confusion personally because `MDXProvider` seems to not work when all is needed is to set this option.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-26 15:45:53 -05:00

29 lines
736 B
JavaScript

module.exports =
(pluginOptions = {}) =>
(nextConfig = {}) => {
const extension = pluginOptions.extension || /\.mdx$/
return Object.assign({}, nextConfig, {
webpack(config, options) {
config.module.rules.push({
test: extension,
use: [
options.defaultLoaders.babel,
{
loader: require.resolve('@mdx-js/loader'),
options: {
providerImportSource: '@mdx-js/react',
...pluginOptions.options,
},
},
],
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
})
}