A module for every component? A new standard?

I have been working with Ionic on and off for several years and generating a new page made the html/component plus registered it with the module.

Now, I have several lazy-loaded modules for this client, Crew, Fleet, Jobs, Finance. Each one has it’s own module.

Recently, I contracted a guy to add a few more pages to this app and he made a bunch of folders, each with their own module/component.ts and component.html. It was pretty annoying, so I redid the code, and got rid of the modules.

To my surprise, I added another and BOOM, there’s a new module for the component!

Has it always been this way and I just don’t remember, or is this a new thing and a new standard that I should try to follow?

I don’t want to tell my Ionic developer that he’s doing it improperly if it’s just me being outdated! He’s gonna start calling me grandpa!

Any advice out there?

This is a religious topic, so expect to hear from people with strongly held and differing opinions on the topic.

I’m personally 100% in your corner. I think Angular lazy loading is by and large a solution in search of a problem, that adds substantial ugly boilerplate, unnecessary maintenance hassle, and a gaggle of opportunities for creating hard-to-diagnose bugs, many of which choose to hide until you try to build for production. It buries your important code in piles of borderline-unreadable noise.

I suppose there are apps out there that are big enough that it makes sense at some point, but I strongly disagree with the choice to foist it upon newbies that are dependent on the generators and are just trying to follow what they see as community standards.

So I never use Ionic’s generators, ignore lazy loading entirely, declare everything in a single AppModule, and am happy as a clam.

2 Likes

Yes, this is baked into the Ionic CLI these days for performance reasons. Read all about it here. You certainly don’t have to use it, especially if your app is performing well enough for you, but we recommend it.