Open sfishel-splunk opened 5 months ago
Did you manage to resolve that?
Did you manage to resolve that?
We have a workaround for our particular setup, not sure how portable it is:
webpackFinal: async (config) => {
config.module.rules.forEach((rule) => {
if (
!!rule.use?.find(
(use) => use.loader === require.resolve('@storybook/mdx2-csf/loader')
)
) {
rule.use?.unshift({
loader: 'string-replace-loader',
options: {
search: "import React from 'react';",
replace: '',
},
});
}
});
return config;
},
Describe the bug
My project uses React 16 so I'm trying to set up the docs addon with "classic" jsx runtime mode for compiling mdx. When I do, mdx files fail to compile with the following error:
To Reproduce
https://stackblitz.com/edit/github-by2l74?file=.storybook%2Fmain.ts
Contents of my
main.js
file:System
Additional context
If I'm understanding the code correctly, the
@storybook/mdx2-csf
loader is explicitly inserting animport React from 'react';
statement, but when the MDX compiler itself is in "classic" jsx runtime mode, it also inserts that same import.