dspace-angular
dspace-angular copied to clipboard
Size regression in `main.js` bundle caused by standalone component migration
Describe the bug
Looks like migrating to standalone components in #2750 increased the size of our main.js bundle by about 30kB.
While this is not a significant increase, it's a bit counter-intuitive since the claim is that standalone components should improve the bundle structure.
Here are some improvements we can make:
- Move route-specific components out of
ListableModuleand reduce the number of imports- Mainly: Standalone Item pages, MyDSpace components
- This can easily save us ~60kB (gz)
- A little fragile though: we've already seen that overwriting these components in themes causes regressions. We can propose a workaround to mitigate this.
- Make dynamic form code lazy again
- Dynamic forms are only used on a select number of routes, many of which are not even accessible by anonymous users, so it would be good to keep them out of the main bundle
- Looked into this for a short while, and it's not as easy but could save us another ~40kB (gz)
Note: for the numbers above I compared a8f31948bc9 and 41eccbbfe15, the "potential gains" from splitting up ListableModule may be different after the Angular 16 upgrade
Just re-checked: main.js is ~600kB currently (down from ~670kB)
But the potential size reductions from ↑ still apply.