0

I have got multiple features/components which are being used in different Angular modules.. currently loading them all separately

Module 1:
  Feature 1
  Feature 2
  Feature 3
  Feature 4

Module 2:
  Feature 3
  Feature 5

Module 3:
  Feature 1
  Feature 2
  Feature 6
  Feature 7

if i put all these features in a shared module and then call it in all the function modules like below:

Shared Module 1:
  Feature 1
  Feature 2
  Feature 3
  Feature 4
  Feature 5
  Feature 6
  Feature 7


Module 1:
  Shared Module 1

Module 2:
  Shared Module 1

Module 3:
  Shared Module 1

Will it cause lag or be slow as there will be many features not being used by all the modules.. for eg: Module 2 only need feature 3 and 5, but as i will be importing whole of shared module.. will it affect performance while loading Module 2.

Shubham Shaw
  • 841
  • 1
  • 11
  • 24
  • if you're making individual exports and destructuring when importing it should be fine like "import {Feature 1} from 'Module1' – Rogelio Jul 03 '20 at 04:00
  • So using shared module not required?? – Shubham Shaw Jul 06 '20 at 03:23
  • I guess so. I'm guessing your aim is only to import one at a time and not all? – Rogelio Jul 06 '20 at 05:41
  • @ShubhamShaw if you have such segregation on modules I suggest not to have 'shared' module because you just loose all benefits of having many modules. Imagine case when you creating lazy module and you need just only a few features, but you just use SharedModule instead which results to all linked modules be included into your final bundle size. Instead just import necessary modules where they are needed, this is not so painful in comparison to benefits you get. – simply good Jun 01 '21 at 14:28

0 Answers0