diff --git a/admin/test-bad-package/README.mdx b/admin/test-bad-package/README.mdx index d05a79ed3949..a07deee44cfb 100644 --- a/admin/test-bad-package/README.mdx +++ b/admin/test-bad-package/README.mdx @@ -1,8 +1,8 @@ # test-bad-package -This package declares a wrong React version on purpose +This package declares a wrong React version on purpose (v15.7.0) -The goal is to test that the MD/MDX content of this package can still be rendered by the website. +The goal is to test that the MD/MDX content of this package can still be imported/rendered by our website. See related issue https://github.com/facebook/docusaurus/issues/9027 diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index 5d3ab12bedf9..c02857d13994 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -31,6 +31,14 @@ const LibrariesToTranspileRegex = new RegExp( LibrariesToTranspile.map((libName) => `(node_modules/${libName})`).join('|'), ); +const ReactAliases: Record = process.env + .DOCUSAURUS_NO_REACT_ALIASES + ? {} + : { + react: path.dirname(require.resolve('react/package.json')), + 'react-dom': path.dirname(require.resolve('react-dom/package.json')), + }; + export function excludeJS(modulePath: string): boolean { // Always transpile client dir if (modulePath.startsWith(clientDir)) { @@ -136,6 +144,7 @@ export async function createBaseConfig({ process.cwd(), ], alias: { + ...ReactAliases, '@site': siteDir, '@generated': generatedFilesDir, ...(await loadDocusaurusAliases()),