AoT can't do a direct import/export of a module from another ngc'd library
Please provide us with the following information:
OS?
Mac OSX El Capitan
Versions.
Angular 2.4.4, CLI Beta.24
Repro steps.
Created some NgModule and compiled it using NGC. tsconfig-aot.json:
{
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"noImplicitAny": false,
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"mapRoot": "",
"outDir": "./dist",
"stripInternal": true,
"skipLibCheck": true,
"baseUrl": ""
},
"exclude": [
"node_modules",
"**/*.spec.ts",
"./vendor.ts",
"./polyfills.ts"
],
"files": [
"src/app/index.ts", ...
],
"angularCompilerOptions": {
"strictMetadataEmit": true,
"debug": true
}
}
The compiled NgModule is then imported and lazy loaded in another CLI app,
app.routes.ts:
... { path: 'auth', loadChildren: 'path/to/auth/module#AuthModule' } ...
path/to/auth/module.ts:
export { AuthModule } from "client-angular2-components/dist/pages/auth";
The log given by the failure.
ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/Users/aaron/repos/my-app/src/$$_gendir/app/pages/auth/module.ngfactory.ts' in '/Users/aaron/repos/my-app/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
@ ./src/$$_gendir/app/app.module.ngfactory.ts
@ ./src/main.ts
@ multi main
Mention any other details that might be useful.
App and imported pages work fine when ng serve without AoT. Only when --aot flag enabled.
Current workaround is to wrap the imported AuthModule in another @NgModule({imports: [..]}) and have the route point to the wrapper module instead.
@aaronleeucla maybe you can provide the module from the imported ngModule? I followed this pattern with my component lib and was able to get around the above. Then when you import you can use the CbVdlModule.forRoot() syntax.
export class CbVdlModule {
public static forRoot(): ModuleWithProviders {
return {ngModule: CbVdlModule};
}
}
I think this might be fixed in master by @filipesilva changes to the way lazy modules are sent to webpack. Filipe?
@aaronleeucla I can test against latest master if you give me a repo I can use.
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.