0

My angular project is currently running in Angular 8 and I use HeroDevs\Hero-Loader (https://www.npmjs.com/package/@herodevs/hero-loader/v/2.0.1) for lazy loading of modules for a page containing tabs. Tabs data are lazy loaded whenever user clicks on a tab. Now I am trying to upgrade the Angular to the latest Angular 14 step-by-step. So while migrating to Angular 9 ng serve fails and I get the below error.

** Module not found: Error: Can't resolve '@herodevs/dynamic-component-service' ERROR in ./src/$$_lazy_route_resource lazy namespace object** The looks to be from the lazy loading of Hero Devs/hero-module module.

Any suggestions would be of great help.

My angular.json file with lazymodules for herodevs Thanks.

GokuSS3
  • 123
  • 1
  • 11

1 Answers1

0

how did you upgrade from Angular 8 to 9? did you use ng update?

I always use the Angular Update Guide for this (https://update.angular.io/?v=8.0-9.0)

From 8 to 9 the following is mentioned here regarding lazy loaded modules:

For lazy loaded modules via the router, make sure you are using dynamic imports. Importing via string is removed in v9. ng update should take care of this automatically.

So your Routes should look something like that

const routes: Routes = [{
    path: 'lazy',
    // The new import() syntax
    loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)
}];
Schmetti
  • 113
  • 14
  • Yes. Updated using the Angular update guide provided in angular site. Issue is not with the lazy loading provided by angular through routes. But with lazy loading done within a page without changing the routes. Check this doc for better understanding on what hero-devs/heroloader is used for -> https://www.npmjs.com/package/@herodevs/hero-loader/v/2.0.1 – GokuSS3 Jul 05 '23 at 11:58
  • You edited the error message "Module not found". Could you provide the code from angular.json and your ngModule? The path in angular.json should be relative and the HeroLoaderModule must be imported in every Module that uses it – Schmetti Jul 05 '23 at 12:08
  • I have given screenshot of the angular.json file in the question itself. – GokuSS3 Jul 06 '23 at 10:42