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?

2
  • "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? Commented Feb 22, 2017 at 8: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 Commented Feb 22, 2017 at 11:42

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

10 Comments

Yes, That's what am thinking of. But I would like to know whether there is any betterb way to do that.
No. You can still create a module that exports several other modules. This way you can get a set of modules by one import.
Then all imports in the module will be added to bundle right?
Not sure what you mean with "to bundle". You can than either add the small modules individually, or a set of them at once.
When i analyzed the bundles it shows these modules will be in all bundles. I think that's normal
|
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.