govuk-frontend
govuk-frontend copied to clipboard
Investigate tree shaking of common js utilities
What
Investigate ways to ensure that our common js utilities, primarily the multiple modules in common/index/mjs, are correctly tree-shaken when bundled. This includes but is not limited to splitting the modules in index.mjs into their own files.
Why
We found during https://github.com/alphagov/govuk-frontend/issues/4957 that whilst we were able to effectively get tree shaking to work as expected for components, bundlers were importing all of common/index.mjs when not all of common was being used. It would be good to further optimise our js and understand why our "sideEffects": true
solution in https://github.com/alphagov/govuk-frontend/pull/4961 didn't work for common.
Who needs to work on this
Developers
Who needs to review this
Developers
Done when
- [ ] Test if splitting out common/index.mjs fixes tree shaking
- [ ] Optional: Investigate alternative methods to fix the tree shaking