-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
React: Switch react-docgen-typescript-loader to react-docgen-typescript-plugin #11106
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import type { TransformOptions } from '@babel/core'; | ||
import type { Configuration } from 'webpack'; | ||
import type { StorybookOptions } from '@storybook/core/types'; | ||
import ReactDocgenTypescriptPlugin from 'react-docgen-typescript-plugin'; | ||
|
||
export function babel(config: TransformOptions, { typescriptOptions }: StorybookOptions) { | ||
const { reactDocgen } = typescriptOptions; | ||
if (!reactDocgen) { | ||
|
||
if (!reactDocgen || reactDocgen === 'react-docgen-typescript') { | ||
return config; | ||
} | ||
|
||
return { | ||
...config, | ||
overrides: [ | ||
|
@@ -27,24 +30,13 @@ export function babel(config: TransformOptions, { typescriptOptions }: Storybook | |
|
||
export function webpackFinal(config: Configuration, { typescriptOptions }: StorybookOptions) { | ||
const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions; | ||
if (reactDocgen !== 'react-docgen-typescript') return config; | ||
|
||
if (reactDocgen !== 'react-docgen-typescript') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer the new code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can change it back but one line if statement throw me for a loop. the function above this one also had this style of if statement. Can change back if wanted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was more pointing out that this change isn't related to any of the work. I think it's good practice to try to only change things related to the task at hand, unless something is being improved. But if you think the change is meaningful, then I'm OK with that. |
||
return config; | ||
} | ||
|
||
return { | ||
...config, | ||
module: { | ||
...config.module, | ||
rules: [ | ||
...config.module.rules, | ||
{ | ||
test: /\.tsx?$/, | ||
// include: path.resolve(__dirname, "../src"), | ||
use: [ | ||
{ | ||
loader: require.resolve('react-docgen-typescript-loader'), | ||
options: reactDocgenTypescriptOptions, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [...config.plugins, new ReactDocgenTypescriptPlugin(reactDocgenTypescriptOptions)], | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems to have only been partially removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment relates to the issue @shilman commented on. Will try to resolve this in the underlying library and remove this comment entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but one line was removed and now it doesn't make sense, right?