-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
"RangeError: Maximum call stack size exceeded" when compiling a file with many requires #771
Comments
@Gobie Thanks for issue |
Using |
Can't be solved on |
Hi @alexander-akait, we are encountering this too, due to the same underlying issue (too many string concatenations because we have so many URLs). I think there are two solutions: Use a template literal to interpolate the resolved URLs, or use |
The other option is to just call |
Honestly, could you count the number of them?
Will be very bad for perfromance, because if you will have mini-css-extract-plugin, you will do it twicy, but evalation is always slow |
We can add |
Let me try to create a minimal reproduction for you. It looks like the one in the original ticket is gone. |
@sgarfinkel Feel free to ping me when it will be ready |
@sgarfinkel Reproduce it, with 100_000 URLs 😄 |
The original problem was solved and our limits are more than 6k, the code was reworked, but yeah, using very many string concatination (binary expressions) are still broken |
I reproduced it with 10_000 concatenations. I don’t know what the limit is, but in my use case I’m loading many sass style sheets, possibly multiple times. I minify at the end to eliminate the duplicates but it causes many concatenations. I was able to solve this by switching to using templated strings instead. Would you accept that PR? |
@sgarfinkel I am afraid we can't use |
I have solution to split code into multiple parts between replacers (i.e. urls/locals/etc) using variables, but I tested the performance of this code and it drops quite a lot... |
In that case you could use |
The last option is to use |
Sorry, no, we can't, it decrases perfomance very very very, because on every thing we need to execute JS |
@sgarfinkel Okay, let' use this #1525, shorty:
|
Created based on comment #689 (comment)
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Given CSS file with 10000 or more classes with URLs, in our case generated from sprites.
The css-loader creates such a JS file, which on compile throws
RangeError: Maximum call stack size exceeded
.What is the expected behavior?
The expected behaviour is to generate a JS file, which can be compiled and executed.
Please mention other relevant information such as your webpack version, Node.js version and Operating System.
Reproducible on 1.0.0, Node 6.11.3 & Node 8.9.4.
Technical details
The issue is that URLs are replaced by requires and
cssAsString
inloader.js
is built by string concatenation"..." + "..." + ... + "..."
which has upper limit in each version of v8, given by it's default stack size.Experimentally measured:
The fix is straightforward, group the string concatenations by fixed amount so it can be compiled using default stack size.
("..." + ... + "...") + ("..." + ... + "...")
Smallest possible test-case for css-loader
Repo with reproducible test-case https://github.com/Gobie/css-loader/tree/issue-771
The text was updated successfully, but these errors were encountered: