fix: fallback terser to main thread when function options are used #18987
+71
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR makes terser to run in the main thread when function options are used.
I also tested out calling functions on the main thread side from the workers, but it was slower than simply running in the main thread.
the way I tested and the results
I ran the script below with each implementation.
The results was:
resolve
playgroundcss
playgroundIt is expected that "call main thread" is slower for the
resolve
playground because it only has a single chunk.css
playground generates multiple chunks but it's still slower than "fallback".We can improve this by detecting if the passed function is serializable (i.e. does not use variables outside the function) and serializing the function in that case. But I think we can first merge this PR as it's better than nothing.
fixes #17409
refs #17589