epam / UUI

React-based components and accelerators library built by EPAM Systems.
https://uui.epam.com/
MIT License
162 stars 62 forks source link

[Dead code elimination] Improve ability of unused code to be removed by minifiers #2178

Open siarheiyelin opened 2 months ago

siarheiyelin commented 2 months ago

Now

Certain parts of UUI codebase cannot be removed by minifiers even if unused

To Do

1. Convert class-based React components with static props to functional React components

2. Wrap initialization of 'heavy' constants into "TREE_SHAKEABLE_INIT"

Notes:
1. It is only for those constants which are initialized during module load, use next example as a reference: uui/i18n.ts

  1. If such constant contains side-effect during initialization, then DO NOT wrap it into TREE_SHAKEABLE_INIT. Otherwise it might cause weird issues in the apps which use UUI library. Instead, try to get rid of side effect upon initialization if possible.
  2. The"@epam/uui-core" and "@epam/uui-components" modules must not have side effects at all, because they are marked as side effect free in their package.json files ("sideEffect": false)

3. Replace CommonJs 3rd party libs by ESM version (if possible)