-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 building parcel with a debug build of itself #9829
Conversation
This commit fixes a segmentation fault in parcel when building itself using a debug build of its native extensions. This would previously crash due to usage of `Fold` and its recursive nature. All expressions will recurse in the typeof replacer code, so SWC will crash if a module has large enough expressions, which is a case that does happen within parcel own dependencies. This should improve performance and is the recommended usage by SWC * #9828 We should replace all SWC transformations from `Fold` to `VisitMut`. /discussions/9828
@@ -388,7 +384,12 @@ pub fn transform( | |||
), | |||
); | |||
|
|||
module.fold_with(&mut passes) | |||
let mut module = module.fold_with(&mut passes); | |||
if config.source_type != SourceType::Script { |
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.
Should this be done before passes
so that the other optimisations (e.g. dead branch, paren remover, etc) are guaranteed to execute?
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 I think you're right; I've put it back in the same place surrounded with an as_folder
which will wrap the visit-mut with a top-level Fold instance that just implements fold_module by calling into the visitor
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.
👏 for figuring this out! It looks like this broke a couple of tests legitimately, it's probably something subtle that needs to be fixed prior to merging.
This commit fixes a segmentation fault in parcel when building itself using a debug build of its native extensions.
This would previously crash due to usage of
Fold
and its recursive nature.All expressions will recurse in the typeof replacer code, so SWC will crash if a module has large enough expressions, which is a case that does happen within parcel own dependencies.
This should improve performance and is the recommended usage by SWC
Fold
toVisitMut
./discussions/9828