Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application is generating a chunk of my lazy load module with prefix default ~ .. even before its getting invoked

I have implemented lazy-loading in my Angular Application (using CLI 7.3.4)

Its compiling successfully but when I route to a lazy-loaded module (say module1 path), its loading one more chunk which is actually other lazy loaded module (Module2) path.

Chunk Name: "../default~lazy-load-modules-module1-module1-module~lazy-load-modules-module2-mo~be6d77c5.js"

I am unable to understand why this default ~ is getting generated.

I am expecting to load modules only when one of its component is invoked.

like image 370
Akhil Avatar asked May 13 '19 07:05

Akhil


People also ask

How do I know if a module is lazy loaded?

You can check to see that a module is indeed being lazy loaded with the Chrome developer tools. In Chrome, open the dev tools by pressing Cmd+Option+i on a Mac or Ctrl+Alt+i on a PC and go to the Network Tab. NOTE: Another important check is to make sure that a module loaded lazily is not loaded again.

What is lazy loading of modules?

Lazy loading is the process of loading components, modules, or other assets of a website as they're required. Since Angular creates a SPA (Single Page Application), all of its components are loaded at once. This means that a lot of unnecessary libraries or modules might be loaded as well.

Which router module is used for lazy loading?

Lazy loaded routes need to be outside of the root app module. You will want to have your lazy loaded features in feature modules. First, let's use Angular CLI to create a new project with Angular Router: ng new angular-lazy-loading-example --routing --style=css --skip-tests.

Why do we need lazy loading of modules and how is it implemented?

Lazy loading is a technique that allows you to load JavaScript components asynchronously when a specific route is activated. This ensures that when the application is loaded for the first time, only the required modules are loaded and utilized.


1 Answers

Its just means the generated chunk belongs to both module1 and module2.

I believe you had an shared module. If yes, then this is chunk of that module.

Please let me know if you want further information.

like image 106
Jeff booz Avatar answered Oct 13 '22 12:10

Jeff booz