-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Bug Report or Feature Request (mark with an x)
- [x ] bug report -> please search issues before submitting
- [x ] feature request
Versions.
Windows 7 and MacOS
$ ng --version
@angular/cli: 1.0.0
node: 7.7.2
os: win32 x64
@angular/common: 4.0.2
@angular/compiler: 4.0.2
@angular/core: 4.0.2
@angular/forms: 4.0.2
@angular/http: 4.0.2
@angular/platform-browser: 4.0.2
@angular/platform-browser-dynamic: 4.0.2
@angular/router: 4.0.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.2
Repro steps.
Stack Overflow Question:
http://stackoverflow.com/questions/43441732/angular-2-error-when-ng-build-aot-lazy-loading-from-different-package
Sample Repo:
https://github.com/chorew/AngularSample
Running the app
- clone the repo
- npm install
- npm run dev:library
const routes: Routes = [
{ path: 'library', loadChildren: '@myapp/library/src/index#ModuleAModule' } // lazy loading a module from a different package
];
The log given by the failure.
main.app@0.0.0 build C:\Users\Juan.Pablo\projects\POC\AngularSample\packages\main.app
> ng build --aot
Hash: dfaf89ef3b1bb2e81c75
Time: 6307ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 28.3 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 9.77 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 1.37 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve 'C:\Users\Juan.Pablo\projects\POC\AngularSample\packages\main.app\src\node_modules\@myapp\library\src\index.
d.ngfactory.ts' in 'C:\Users\Juan.Pablo\projects\POC\AngularSample\packages\main.app\src\$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts
Notice how it is trying to find the lazy loaded module inside the main.app\src folder
App src path
C:\Users\Juan.Pablo\projects\POC\AngularSample\packages\main.app\src\
Lazy loaded from package
@myapp\library\src\index.d.ngfactory.ts
### Desired functionality.
<!--
What would like to see implemented?
What is the usecase?
-->
This is a sample app with 2 sub-packages.
packages/main.app
packages/library
the goal is to have a library package with different modules of the app
and have some specific modules lazy loaded.
The use case is to be able to load modules from different packages/repos developed by different teams and pull just the needed packages from npm to configure the routes.
const routes: Routes = [
{ path: 'library', loadChildren: '@myapp/library/src/index#ModuleAModule' }, // developed by Team A
{ path: 'anotherLibrary', loadChildren: '@myapp/anotherLibrary/src/index#ModuleAModule' } // developed by Team B
];
and so on.
### Mention any other details that might be useful.
<!-- Please include a link to the repo if this is related to an OSS project. -->
Main.app was generated with ng cli
Library package is custom project using ngc and gulp