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.
This PR will move
options.pureExternalModules
tooptions.treeshake.pureExternalModules
and make it configurable via config file and also the CLI via--treeshake.pureExternalModules
/--no-treeshake.pureExternalModules
.It also adds the new
options.treeshake.propertyReadSideEffects
which defaults totrue
but can be disabled by setting it to false. If it is disabled, the following side-effects will not be detected andresult
will be removed if it is not used elsewhere in the code:accessing a getter with side-effects
accessing members of
null
orundefined
:It is my guess that setting
options.treeshake.propertyReadSideEffects: false
or using--no-treeshake.propertyReadSideEffects
will work without problems in 95% of the use cases and can noticably reduce bundle size especially when passing around a lot of objects as function parameters.Also, a lot of unnecessary property access checks were removed in this PR which should give a slight speed boost.
Of course we should not forget to update the documentation once this is released.