lib/products-values
is currently a large monolith, consisting of many different imports and exports. This makes it hard for the bundler to tree-shake effectively, and introduces potential problems because of circular dependencies between lib/products-values
and lib/plans
, for example.
This PR splits the library into many small modules, while re-exporting everything from the index file. This should result in minimal changes in consumers of this library, while enabling better tree-shaking.
I don’t expect immediate performance benefits from this PR, as there are likely other large libraries to untangle first. I was wrong; see the comments below.
This PR is working towards the end goal of removing the dependency on lib/plans from the critical path, which may yet turn out to be impossible.
Changes proposed in this Pull Request
- Split the various exports in
index.js
into individual modules
- Split
assertValidProduct
into a new utils/
folder
- Move all of the translated constants from
constants.js
to a new translations.js
- Add
package.json
with sideEffects
config, to enable the bundler to take advantage of the modularisation of the library
- Ensure
lib/plans
and lib/domains
refer to the new individual modules instead of the index file, to avoid circular dependencies
Testing instructions
This PR doesn’t change any functional code, it only moves some code around. As such, a correct build and passing automated tests should be enough to ensure that nothing got broken.
Unfortunately, no screenshots were provided by the developer.