0

I have 4 feature modules which will be loaded lazy. Have multiple popups components, which is need for the feature modules. Currently i have created a shared module which will export these component and each feature module will import this shared module. The tradeoff for this kind of design is, the shared module will be included in all the feature bundles. The problem is some popup component is not needed in some feature module.

Any ideas?

user3118041
  • 113
  • 5
  • "The problem is some popup component is not needed in some feature module." why is that a problem? What would you consider a better approach? – Günter Zöchbauer Feb 22 '17 at 08:37
  • suppose i had a, b, c components and 1,2,3 feature modules. a and b is needed in 1 module. b and c is needed in 2 module and module 3 need all a,b,c component – user3118041 Feb 22 '17 at 11:42

2 Answers2

1

Alternatively you can create a module per popup component and then only import the module with the component you actually want to use.

Günter Zöchbauer
  • 490,478
  • 163
  • 1,733
  • 1,404
0

According to best practices that I know, SharedModule should have directives, pipes and shared components.

Your question really depends on how frequent of those so-called "widget" components get imported and how big they are.

If they are small and get used frequent by many other modules, sure, put them in the SharedModule. Having components in SharedModule doesn't mean that you should use them in every other module. It's just that they are common "enough" to be put in SharedModule.

If they are big and not imported by majority of other modules, you may want to treat them as "feature" modules and import them when you need to.

gye
  • 1,114
  • 2
  • 12
  • 24