How to generate component with module.ts?


#1

Hello there

I have a complex application with around 50 components. I’ve just using the components.module.ts file to import my components, but I realised it has been slowing down app launch by around 6-7 seconds on average. I’ve since been manually creating a module.ts file for each component, and that load time is down to 1-2 seconds depending on the number of components.

Does the ionic CLI provide a way of generating a component with a module.ts file (rather than clumping everything into one mega-module)? The documentation and help screen don’t show an option to do this.

Thanks


#2

I think what you want is utilizing ionic pages, those will be lazy loaded and boost up boot up time a lot.

If you are creating components that are essentially getting viewed as a page, then you should be creating ionic pages instead. Ionic pages are essentially angular components too, but an extra decorator is added IonicPage on top of them and they get their own module once generated.

Your approach is pretty nice, but your modules are probably still getting bootstrapped at start up time anyway. If you create ionic pages. They will be lazy loaded for you.

To generate an ionic page, try the ionic generate page command .