Allow treeshaking by adding sideEffects: false in package.json of every framework.
This will allow the callers that use modern bundlers (Webpack 5, Vite, Rollup etc), to only import the components they use instead of everything.
Currently, if we do import { VtmnAccordion } from '@vtmn/react' we will only have one big index.js in the build, whereas we only need the chunk related to the Accordion and its deps.
Context
It reduces perf issues for all apps.
Here is an example of Vitamin in a Next 12 app :
We can see that Vitamin dist only contains an index.es.js instead of different chunks of used components like the other modules. This is a small app and and we can see that @vtmn/react is taking a lot of space on its own without the ability to load a small portion of it.
This change would allow the bundler to understand that the package is written in ESM and that it can treeshake it without worrying about anything.
Checklist
[x] Make sure you are requesting to pull a topic/feature/bugfix branch. Please, don't request directly from your main!
Hi @Shyrro, thanks a lot for this contrib!
As @thibault-mahe said, I completely missed this (I've just learned this, thanks to you)
Approved ✅ @thibault-mahe I let you merge this.
Signed-off-by: Shyrro zakaria.sahmane@decathlon.com
Changes description
Allow treeshaking by adding
sideEffects: false
inpackage.json
of every framework. This will allow the callers that use modern bundlers (Webpack 5, Vite, Rollup etc), to only import the components they use instead of everything.Currently, if we do
import { VtmnAccordion } from '@vtmn/react'
we will only have one bigindex.js
in the build, whereas we only need the chunk related to the Accordion and its deps.Context
It reduces perf issues for all apps.
Here is an example of Vitamin in a Next 12 app :
We can see that Vitamin dist only contains an
index.es.js
instead of different chunks of used components like the other modules. This is a small app and and we can see that@vtmn/react
is taking a lot of space on its own without the ability to load a small portion of it. This change would allow the bundler to understand that the package is written inESM
and that it can treeshake it without worrying about anything.Checklist
I have tested on related showcases.If it includes design changes, please ask for a reviewdesign-system-core-team-design
GitHub team.Does this introduce a breaking change?
Other information
This is a small change that can improve everyones lives when working with
esm