3

While doing lazy loading of a module in another module, getting build error. The lazy loading works fine while doing the ng serve.

Angular version :11.1.2

[error] Error: When building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.

2 Answers 2

15

Please export lazy loaded modules in public-api.ts

Sign up to request clarification or add additional context in comments.

2 Comments

Could you please elaborate? or add an example? I am adding module to the projects/lib-name/src/public-api.ts (to both, module which is going to be lazy loaded, and to public-api of the module which is loading the module) but still I am getting this issue
Yes it fixes the issue, but after adding lazy module into public-api.ts it becomes a part of main chank js. So lazy component becomes not lazy, so isuue is gone. Congrats! ((
0

As one of developers of ng-packager said: Libraries shouldn't contain any lazy-loaded module or routing. These are the responsibility of the application.

That is means you need somehow move lazy part of you library into another library, and lazy load it from application or from you library where you removed code.

https://github.com/ng-packagr/ng-packagr/issues/1960#issuecomment-827543254

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.