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
Maximum call stack size exceeded when building lib via babel CLI (T7402) #4323
Comments
Okay, I've tracked down the cause of this. Given content like
we currently generate:
The problem in this case is this line:
which when you get to a file like this: https://github.com/callemall/material-ui/blob/cbf3280ee58fed33c4ef12e62d00d09ac35fd087/src/svg-icons/index.js gives you nearly 1000 nested assignment nodes in the AST. Then when you multiply that by the fact that each call to generate the child assignment via the generator introduces not just one but several new stack frames, means that we get a pretty call sizable stack. The quickest fix for this would probably be split this assignment into groups once you past a certain number of exports being assigned. This issue was also probably excacerbated by #3463 which introduced an extra stack frame per call, so another alternative would probably be to replace |
It appears this is still a problem. I have encountered this issue using material-ui in a React Native Webview. The assignment produces a stack that causes a stack overflow. I'd be interested in tackling this if someone would lend a little guidance on what part of the codebase to look into. |
Feel free to hop on our Slack if you have questions. Essentially what we'd want to do is change this loop:
so that for very large sets of nonHoistedExportNames, we break the expression into multiple expression statements. Maybe we can limit each one to 100 exports? |
Signed-off-by: Matthew Stewart <mattdste@gmail.com>
Limit export node default assignment stack size #4323
Signed-off-by: Matthew Stewart <mattdste@gmail.com>
Signed-off-by: Matthew Stewart <mattdste@gmail.com>
Bug information
Input code
Description
Encountering the following error when trying to build the following lib: https://github.com/callemall/material-ui
Reproducible by doing:
npm install
npm run build:babel
Note: When I break down the build process and build a smaller set of files, say, just the
svg-icons
folder, it works fine. But when I try build the entire lib with a single command, I get a stack overflow at the same point in the build process every single time.The text was updated successfully, but these errors were encountered: