Support tree shaking without scope hoisting #10191
Draft
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.
Small transform to remove unused exports in the non-scope hoisting packager. Basically just removes the
parcelHelpers.export
call, or assignment toexports
, which lets the minifier delete the code if it is side effect free.This is mostly an experiment to see how much scope hoisting itself really helps, vs tree shaking but still wrapping all modules in function scopes. In reality, very few modules are actually scope hoisted because they get shared between bundles and therefore get wrapped anyway (in an app I tested < 5% of the modules were not wrapped). Tree shaking without scope hoisting is much simpler, and if we can get most of the size benefits and only maintain a single packager that would be nice.
The ReactStaticPackager also doesn't work with scope hoisted bundles since it executes modules in a dev-packager like environment at build time, so this also enables tree shaking in those builds.