Skip to content

Commit

Permalink
Replace react-docgen-typescript-plugin with Storybook's `reactDocge…
Browse files Browse the repository at this point in the history
…n` option (#1594)
  • Loading branch information
Dogdriip authored Sep 8, 2023
1 parent 848167b commit 2d6b5f9
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1,876 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-tools-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@channel.io/bezier-react": patch
---

Replace `@channel.io/react-docgen-typescript-plugin` with Storybook's `reactDocgen` option
28 changes: 8 additions & 20 deletions packages/bezier-react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const ReactDocgenTypescriptPlugin = require('@channel.io/react-docgen-typescript-plugin').default
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')

module.exports = {
Expand All @@ -23,13 +22,15 @@ module.exports = {
typescript: {
/**
* @note
*
* default `typescript.reactDocgen` option is to use `react-docgen-typescript-plugin`,
* which is not compatible with TS <= 4.3
*
* so we need to disable and override it with our own plugin (@channel-io/react-docgen-typescript-plugin).
*
* `react-docgen-typescript-plugin` introduces significant overhead
* when HMR is enabled, so we enable it only in production.
*/
reactDocgen: false,
reactDocgen: process.env.NODE_ENV === 'production' && 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},
webpackFinal: async (config) => {
// Apply tsconfig alias path
Expand All @@ -48,19 +49,6 @@ module.exports = {

config.resolve.extensions.push('.ts', '.tsx')

if (process.env.NODE_ENV === 'production') {
/**
* @note
*
* `react-docgen-typescript-plugin` introduces significant overhead
* when HMR is enabled, so we enable it only in production.
*/
config.plugins.push(new ReactDocgenTypescriptPlugin({
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
}))
}

return config
}
}
1 change: 0 additions & 1 deletion packages/bezier-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@channel.io/bezier-icons": "^0.10.0",
"@channel.io/react-docgen-typescript-plugin": "^1.0.0",
"@mdx-js/react": "^1.6.22",
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-babel": "^6.0.3",
Expand Down
Loading

0 comments on commit 2d6b5f9

Please sign in to comment.