Search code examples
spartacus-storefront

Lazy Loading Custom module in Spartacus 3.3.0 not working


trying to lazy load one of my custom feature module. it creates chunk but not lazily working in browser. it loads at first time . please suggest what I am missing here...

enter image description here


Solution

  • Based on the fact the chunk is created it looks like you are missing the cmsComponents array.

    You need to list the CMS components present in your lazy loaded module, that way Spartacus will know when to load the chunk. Please see https://angular.io/guide/router#getting-route-information and also a quick example I sprung up https://github.com/LTiger14/custom-style-spartacus/blob/main/src/app/app.module.ts#L26-L33.