govuk-frontend icon indicating copy to clipboard operation
govuk-frontend copied to clipboard

Investigate tree shaking of common js utilities

Open owenatgov opened this issue 9 months ago • 0 comments

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

owenatgov avatar May 02 '24 10:05 owenatgov