-
-
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: Disable react-docgen #7743
Comments
Could another solution to be disable terser? I'm trying to build a very small project with the new docs page and am seeing the same out of memory errors during |
tl:dr; - Fof module.exports = ({ config }) => {
config.module.rules[0].use[0].options.plugins.pop();
return config;
}; More detailsI've just run into this issue after adding It always gets to 38% and then crashes. I saw the 'Use hack...' commits and tried the same. It seemingly goes into an infinite loop as it just eats all the memory I give it (tried up to 16GB, it just keeps using more and eventually crashes) After finding this issue and seeing the plan to allow caveat - My documentation is outside of Storybook so I'm not using The default config uses the following babel rule: config.module.rules ( [
{
"test": {},
"use": [
{
"loader": "babel-loader",
"options": {
"cacheDirectory": "PATH_TO_NODE_MODULES/.cache/storybook",
"presets": [
[
"PATH_TO_NODE_MODULES/@babel/preset-env/lib/index.js",
{
"shippedProposals": true,
"useBuiltIns": "usage",
"corejs": "3"
}
],
"PATH_TO_NODE_MODULES/@babel/preset-react/lib/index.js",
"PATH_TO_NODE_MODULES/@babel/preset-flow/lib/index.js"
],
"plugins": [
"PATH_TO_NODE_MODULES/@babel/plugin-proposal-object-rest-spread/lib/index.js",
"PATH_TO_NODE_MODULES/@babel/plugin-proposal-class-properties/lib/index.js",
"PATH_TO_NODE_MODULES/@babel/plugin-syntax-dynamic-import/lib/index.js",
[
"PATH_TO_NODE_MODULES/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
{
"sourceMap": true,
"autoLabel": true
}
],
"PATH_TO_NODE_MODULES/babel-plugin-macros/dist/index.js",
"PATH_TO_NODE_MODULES/@babel/plugin-transform-react-constant-elements/lib/index.js",
"PATH_TO_NODE_MODULES/babel-plugin-add-react-displayname/index.js",
[
"PATH_TO_NODE_MODULES/babel-plugin-react-docgen/lib/index.js",
{
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES"
}
]
]
}
}
],
... I manually (somewhat hackily) removed the last config.module.rules[0].use[0].options.plugins.pop(); This works for the default config in Versions used
Custom webpack configMy full module.exports = ({ config }) => {
config.module.rules[0].use[0].options.plugins.pop();
config.module.rules.push(
{
test: /stories\.(js|jsx)?$/,
loaders: [require.resolve('@storybook/source-loader')],
enforce: 'pre',
},
);
return config;
}; |
@shilman I'm a little confused on how this is a solution to a max memory issue with webpack, if i need docgen in my project and want to use this feature, am i somewhere down the line prone to getting a memory issue? |
@shilman I still don't understand if this bug is just a fact of life right now if you want to work with docgen? This makes doc-gen unworkable for us, would love to clear this because I'm probably missing something |
@EdenTurgeman Ok a few different things going on here: I want to move as much as possible out of the core. You can see this with The other option is to allow disabling the At any rate, neither of these things are truly storybook issues, they are issues with those specific plugins and how they interact with your project (there are tens of thousands of storybooks in the wild that don't experience this issue). From my perspective, we should support as many Storybooks as we can (including yours), but when we hit up against a wall with the libraries we depend on, the solution is to give users more control to solve it themselves. That's basically what this issue is about. LMK if that makes sense! |
@shilman Absolutely! I understand your need to support as many as possible and doing that through configuration options seems to be the right way to do it. |
Here's my crude understanding:
What I've seen, anecdotally, is that terser works much better with smaller input files. In your case, I don't know how much of it is due to your code vs docgen vs terser vs maybe some other loaders that you're ALSO using (??!!) but that's probably what's giving you problems. |
@shilman I know this isn't a storybook official plugin, but in your opinion, does docgen need to support typescript docs natively? |
@EdenTurgeman That's really useful to know. Apparently |
@EdenTurgeman - I have published a similar /but lighter / https://github.com/atanasster/webpack-react-docgen-typescript Can you please try it and see if it solves your issues |
@shilman Would love to contribute to the project in my free time, though I think i might start with something simpler to get me into the loop. |
I had this same problem. I also found it mainly contributed to the |
FYI, I'm looking at the 6.0 move to |
Awesome, would love to see some updates on that! |
@EdenTurgeman work in progress #9838 |
yarn build:storybook was failing locally due to a node out of memory error. This appears to be related to react-docgen, which should be fixed in v6 of storybook. See storybookjs/storybook#7743
FYI - I just ran into this issue and spent several hours trying to debug and fix the problem. My problem also was with But I noticed that my bundle size jumped from 5.5MB to 25.5MB when I upgraded So what I did is just exclude module.exports = ({ config }) => {
config.module.rules.push(
// Include react-docgen-typescript-loader to help generate prop type
// docs for components. Exclude the icons folder because we don't need
// to generate docs for those components and there are hundreds of them.
{
test: /\.tsx?$/,
exclude: resolve(__dirname, '../src/icons'),
use: [
'babel-loader',
{
loader: 'react-docgen-typescript-loader',
options: { shouldExtractLiteralValuesFromEnum: true },
},
],
},
// Do regular babel-loader for just the icons
{
test: /\.tsx?$/,
include: resolve(__dirname, '../src/icons'),
use: ['babel-loader'],
},
);
return config;
}; That brought the bundle size back down to 5.5MB and everything works like before! 🎉 |
Fixed as part of #10790 |
React-docgen can cause the
terser
plugin to blow up, e.g. @nicholasbraun's issue in #7092#5935
We should:
The text was updated successfully, but these errors were encountered: