Add env replacer based on VisitMut #9852
Merged
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.
#9828
This is aimed at improving moving SWC usage to visit for all parcel
use-cases as we are facing memory errors due to stack-overflow. Errors
include segmentation faults and bus errors.
This is part of #9828. Adds exhaustive tests for the folder.
Update transformer to use the VisitMut impl.
This replaces the Fold env replacer with a VisitMut implementation.
All tests pass on both old/new versions.
The following behaviours of the fold implementation should be revised in
the future as they might be unwanted:
process.browser = ...
assignment expressions are replaced withprocess.browser = true
, which is not a safe replacementconst x = ({ x } = process.env);
aresupported but insert an extra trailing object `const x = (x = 'asdf', {});
replace_env
replacement is off the transformer still replacesseveral cases that aren't the base declarations case
Overall could simplify this so that less cases are supported, and then
shift it to be a generalised inline variable replacement implementation.