Closed fkolar closed 7 years ago
Can you provide a project that reproduce this? We're missing a lot of information, but from what I can see your CoreModule
is not declared properly.
Hi Hans,
This project is not a public yet. Do you want me to copy the Core Module? It was all working fine with build 22.
Thanks, Frank
export const UserConfig = new OpaqueToken('UserConfig');
/**
* Core mode includes all shared logic accross whole application
*/
// todo: for AOT use exported functions for factories insteads this inline ones.
@NgModule({
imports: [
BrowserModule , CommonModule , HttpModule ,
TranslateModule.forRoot({
provide: TranslateLoader ,
useFactory: initTranslateLoader ,
deps: [Http , Environment]
})
] ,
exports: [BrowserModule , CommonModule , HttpModule , TranslateModule , LocalizedImageDirective] ,
declarations: [LocalizedImageDirective , NotFoundComponent ] ,
bootstrap: []
})
export class MyCoreModule
{
static forRoot (config: {[key: string]: any} = {}): ModuleWithProviders
{
// when empty we asume we are in Test. Application should always have some basic initialization
if (Object.keys(config).length === 0) {
config[AppConfig.InTest] = true;
}
return {
ngModule: MyCoreModule ,
providers: [
{provide: UserConfig , useValue: config} ,
{provide: AppConfig , useFactory: makeConfig , deps: [UserConfig , Injector]} ,
{provide: DefaultRequestOptions , useClass: DefaultRequestOptions , deps: [AppConfig]} ,
{provide: RequestOptions , useClass: DefaultRequestOptions , deps: [AppConfig]} ,
{
provide: Http , useFactory: makeHttp ,
deps: [XHRBackend , DefaultRequestOptions , ErrorNotifierService , AppConfig]
} ,
{provide: RoutingService , useClass: RoutingService , deps: [Router]} ,
EntityResource ,
ErrorNotifierService ,
Environment ,
{
'provide': APP_INITIALIZER ,
'useFactory': initI18nSupport ,
'deps': [AppConfig] ,
'multi': true ,
}
]
};
}
}
export function initI18nSupport (appConfig: AppConfig): Function
{
return () => appConfig.initializeI18n();
}
export function initTranslateLoader (http: Http , env: Environment)
{
return new DefaultTranslateLoader(http , env , '/assets/i18n' , '.json');
}
Okay, could you try to change your tsconfig.json
file to add "files": ["main"]
, then from the command line, run node_modules/.bin/ngc -p src/tsconfig.json
? See if that shows an error (it should). Please paste the result if it does.
this is my tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
},
"files": ["main"]
}
When I run it the result is:
Type NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts is part of the declarations of 2 modules: NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts! Please consider moving NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts to a higher module that imports NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts. You can also create a new NgModule that exports and includes NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts then import that NgModule in NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts.
You should try to do what it says :)
Here it is pasted without the formatting:
Type NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts is part of the declarations of 2 modules: NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts! Please consider moving NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts to a higher module that imports NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts. You can also create a new NgModule that exports and includes NgbHighlight in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts then import that NgModule in NgbTypeaheadModule in /Neptun/aw7/AngularMetaUI/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.module.d.ts and NeptunComponentsModule in /Neptun/aw7/AngularMetaUI/src/app/shared/components/neptun.component.module.ts.
Changed and now it actually throws my original error
Error: Error encountered resolving symbol values statically. Calling function 'MyCoreModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /Neptun/aw7/AngularMetaUI/src/app/app.module.ts, resolving symbol AppModule in /Neptun/aw7/AngularMetaUI/src/app/app.module.ts at simplifyInContext (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:25713:25) at StaticReflector.simplify (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:25725:15) at StaticReflector.annotations (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:25223:62) at NgModuleResolver.resolve (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:17583:84) at CompileMetadataResolver.getNgModuleMetadata (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:18091:62) at addNgModule (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:24985:60) at /Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:24996:16 at Array.forEach (native) at _createNgModules (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:24995:28) at analyzeNgModules (/Neptun/aw7/AngularMetaUI/node_modules/@angular/compiler/bundles/compiler.umd.js:24870:16) Compilation failed
Or maybe the forRoot is too complex to be resolved by this StaticReflector.simplify
?
Sorry. I missed the if()
statement the first time around. forRoot()
macro functions can only be a single return
statement and does not contain any branching or complex logic.
Is this something new when build 22 did not catch this?
This should have not been working with beta 22 either. We enabled more features in beta 22 and this was one of the thing (lazy route splitting).
Excellent the if thingy is gone and the error is gone. Thanks for the quick response.
now I just need to resolved other ones as well, but probably will create new issue as this does not relates anymore to this context
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'app.component.html'
btw. I just double checked and I had version 21.
{
"project": {
"version": "1.0.0-beta.21",
"name": "angular-meta-ui"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets"
so my second errors does not seems to be problem anymore as my @component properties were before declared as:
templateUrl: 'app.component.html' ,
styleUrls: ['app.component.scss']
when I changed this to :
templateUrl: './app.component.html' ,
styleUrls: ['./app.component.scss']
it works
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.
Today I have upgraded into the latest Angular -CLi from 22 build and I started to see this error.
my module looks like this:
Any idea ? Why it started with buil #24. Is this related to the AOT?