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
fix: skip merging large input sourcemaps #10890
fix: skip merging large input sourcemaps #10890
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we already do something similar in @babel/generator
: if the input is >500K (I think) we disable the formatting.
// when `lastComment` is non-null, EXTERNAL_SOURCEMAP_REGEX must have matches | ||
const match: [string, string] = (EXTERNAL_SOURCEMAP_REGEX.exec( | ||
lastComment, | ||
): any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guaranteed to never return null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because the capturing group
([^\s'"`]+)
has a +
quantifier, if the whole regex passed, the capturing group must not be null
.
@nicolo-ribaudo Correct. I have tested on |
This PR addresses #10875 where a large input source map is consumed and causing OOM error. It is not an ideal fix but still preserve basic support for practical size input source map.
Note that #10885 misidentified the memory bottleneck. But I preserve the change here since we need to detect the source map file size.
Ideally the mergeSourceMap in babel generator should operate in a streaming mode. But this does not fit in a patch release.
I don't consider it as a regression since in 7.6.4 the
inputSourceMap
is not working properly on external sourcemaps.@artisb45 @midgethoen Though the URL does not change, here is a new fix. You can download it and overwrite
node_modules/@babel/core/lib/transformation/normalize-file.js
.