Lazy Load Non-Routable Modules in Angular with angular-meteor

426 views Asked by At

I followed this tutorial https://netbasal.com/the-need-for-speed-lazy-load-non-routable-modules-in-angular-30c8f1c33093 to load a non-routable module.

But the step of instruct Angular to ask Webpack to create a separate chunk for our module so we can lazy load it later on in angular.json could not implement it since I am using MeteorCLI as in the following example of Urigo / angular-meteor https://github.com/Urigo/angular-meteor/tree/master/examples/MeteorCLI/all-in-one

The error that I get when trying to load the module through the load-module.directive.ts is this:

ERROR ReferenceError: System is not defined

at SystemJsNgModuleLoader.loadAndCompile (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:42359)
at SystemJsNgModuleLoader.load (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:42351)
at LoadModuleDirective.ngOnInit (load-module.directive.ts:48)
at checkAndUpdateDirectiveInline (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:46075)
at checkAndUpdateNodeInline (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47339)
at checkAndUpdateNode (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47301)
at debugCheckAndUpdateNode (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47935)
at debugCheckDirectivesFn (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47895)
at Object.eval [as updateDirectives] (provider-details.component.html:296)
at Object.debugUpdateDirectives [as updateDirectives] (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47887)

Technical specifications:

  • Angular 7
  • Meteor 1.8

Can someone tell me how to implement lazy load non-routable modules in angular-meteor

1

There are 1 answers

2
Paul Cochrane On

Have a look at https://github.com/wishtack/wishtack-steroids/tree/master/packages/reactive-component-loader

This allows you to load angular modules without requiring a route. It’s not perfect or simple but it may help you get started.

There are a few issues with trying to compile with aot in my build and I’ve had to edit it slightly to get it to work but this may just be something I’m doing wrong.