This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
perf: mark design system modules as side-effect-free #389
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.
TODO: once this is merged and published, this needs a PR in
appsmithorg/appsmith
to bump the package version.Description
This PR adds the
sideEffects: false
flag topackage.json
s. When applied toappsmithorg/appsmith
on top of appsmithorg/appsmith#20964, this makes the bundle 680 minified kB smaller (8.14 → 7.46 minified MB).How does this work?
Webpack isn’t smart enough to figure out when importing a module will cause side effects (eg a console log, or a network request) vs when it won’t. So, by default, webpack keeps every module in the bundle (and just tries to remove unused consts/functions/classes instead).
Sometimes, this backfires. For example, if you have code like
webpack won’t be able to drop
big-third-party
from dependencies, even thoughToast
isn’t used anywhere. That’s because webpack doesn’t know whethertoast.js
orbig-third-party
have any side effects.By setting
sideEffects: false
, we tell webpack that, yes, no modules in this package will cause side effects, and it’s safe to removetoast.js
if its exports aren’t used.More about this: https://sgom.es/posts/2020-06-15-everything-you-never-wanted-to-know-about-side-effects/
Type of change
How Has This Been Tested?
Test Plan
Issues raised during DP testing
Checklist:
Dev activity
QA activity: