-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: react-docgen-loader generates invalid code when re-exporting a component with a different name since 7.6 #26074
Comments
I tried to take a look into diagnosing/fixing this, but I couldn't find any tests for the docgen loader - are these covered by some e2e/integration suites? If anyone is able to give me a pointer on whereabouts to look to get a regression test set up that would be great. |
Hi @glenjamin! We have TS test cases here: https://github.com/storybookjs/storybook/blob/next/code/renderers/react/template/stories/ts-argtypes.stories.tsx And JS test cases here: https://github.com/storybookjs/storybook/blob/next/code/renderers/react/template/stories/js-argtypes.stories.jsx Hope that helps! |
Interestingly changing the docgen to // main.ts
export default {
typescript: {
reactDocgen: false,
}
} @valentinpalkovic you touched all of this recently, any ideas? Given that this is broken in |
Something that occurred to me while reading up on this is that react-docgen-loader is run on many files, and it also follows imports - so probably spends quite a lot of time parsing components that aren't used I wonder if there's a way to only apply it to the components actually used in story files 🤔 |
From what I can see, the edit: aha, I see the docgen-loader is pretty new, it was only added in #24762 edit 2: I suspect it might be a bug that react-docgen-loader always uses react-docgen, regardless of the |
If react-docgen-typescript should be used, react-docgen still runs on non-TypeScript files since react-docgen-typescript can’t process JavaScript files, only TypeScript. See the |
totally valid, got the same issue |
got the same issue and it helps, but could this cause any problems in the future?
|
same issue |
Experiencing same issue here |
Describe the bug
When defining a component in one file, but then re-exporting it with a different name in another file, react-docgen-loader generates invalid code which then errors when loading
In particular, the
actualName
of the docgen handler gets the__docgenInfo
assigned, but in the re-importing file this name isn't present, leading to an "is not defined" error.I haven't quite established whether this is a bug because react-docgen-loader should be adding the code differently, or because react-docgen should
To Reproduce
npm i
npm run storybook
The key parts of the example are
Which produces the following compiled code in the webpack bundle
System
Additional context
No response
The text was updated successfully, but these errors were encountered: