2

I split my project between multiple Git Repos and now I have problem with Lazy loading

If I Copy the sourceCode from child repo to main repo, with use of the following syntax

{
    path: 'child-app',
    loadChildren: './shared/child/src/app/child-app.module#ChildAppModule'
},

I can build and serve my project without any problem But if I change the Route to point to node_modules like below

{
    path: 'child-app',
    loadChildren: '@mine/child/src/app/child-app.module#ChildAppModule'
},

OR

{
    path: 'child-app',
    loadChildren: '../../node_modules/@mine/child/src/app/child-app.module#ChildAppModule'
},

It will raise this error :

ERROR in ./src/$$_gendir lazy
Module not found: Error: Can't resolve '/Users/myuser/Projects/web-app
/src/node_modules/@mine/child/src/app/child-app.module.module.ngfact
ory.ts' in '/Users/myuser/Projects/web-app/src/$$_gendir'
 @ ./src/$$_gendir lazy
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.browser.ts
 @ multi ./src/main.browser.ts webpack-hot-middleware/client?path=/__webpa
ck_hmr&timeout=2000&reload=true&noInfo=true

I am using webpack 2 and ngtools/webpack to compiling my project

1

1 Answer 1

2

Lazy loading module from node_modules with JIT is working fine but Lazy loading with AOT is not working

github.com/angular/angular-cli/issues/5986

the best solution that I found is creating a symlink from src/app/something to node_modules/something

ln -s source destination

and it is working fine :)

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

2 Comments

Do you have a working prototype for it by any chance. A plunker or something.
unfortunately I am not able to create a plunker because it is a link and there is no option for link in plunker. this topic is related to an angular project which splited to multuple git repositories. just add them to your npm and create a link with that command from src to node_modules

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.