Angular best practices: CoreModule vs SharedModule

Mehdi Benmoha
2 min readDec 26, 2018
The CoreModule and SharedModule concepts are very simple just come in !!

The Angular style guide is describing this three kinds of modules, but when I was reading the documentation, I was so confused that I don’t remember how many times I said WTFF !!

After some researches on the internet, I still didn’t figure out the difference between the CoreModule and the SharedModule. The FeatureModule was the most obvious for me because I was used to write feature modules. But the two others were so ambiguous for me until I started playing with them and experimenting the both.

So what is the CoreModule and the SharedModule and how to use them ?

Core module or Core feature module

The core module is a module that is only imported once in the AppModule and never again in the other modules. To ensure your module is only imported one time (if you are working on a team of sneaky members) , you can put this code in the class constructor that will prevent the module from being imported twice:

--

--