In latest angular-cli: 1.0.0-beta.22 getting exceptions.... #3384
Copy link
Copy link
Closed
Description
In latest angular-cli: 1.0.0-beta.22 getting exceptions....
$ ng serve
** NG Live Development Server is running on http://localhost:4200. **
0% compilingError encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 41:36 in the original .ts file), resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 41:36 in the original .ts file), resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
at positionalError (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:595:18)
at simplifyInContext (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:473:27)
at StaticReflector.simplify (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:478:22)
at StaticReflector.annotations (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:60:36)
at NgModuleResolver.resolve (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14261:46)
at CompileMetadataResolver._loadNgModuleMetadata (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14646:45)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14636:23)
at addNgModule (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12944:43)
at C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12956:28)
at analyzeNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12700:16)
at analyzeAndValidateNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12704:20)
at OfflineCompiler.compileModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12775:20)
at CodeGenerator.codegen (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\codegen.js:58:30)
at AotPlugin._make (C:\msweb\msbarcode\node_modules\@ngtools\webpack\src\plugin.js:193:43)
at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\@ngtools\webpack\src\plugin.js:157:75)
at Compiler.applyPluginsParallel (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:156:14)
at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:463:8)
at Compiler.applyPluginsAsync (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:73:70)
at Compiler.compile (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:456:7)
at Watching.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:46:17)
at next (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:81:11)
at Compiler.invalidAsyncPlugin (C:\msweb\msbarcode\node_modules\webpack-dev-middleware\middleware.js:119:3)
at next (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:83:14)
at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\CachePlugin.js:31:4)
at Compiler.applyPluginsAsync (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:85:13)
at Watching._go (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:44:16)
at Watching.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:36:8)
at Compiler.readRecords (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:367:10)
at new Watching (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:33:16)
at Compiler.watch (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:204:17)
at module.exports (C:\msweb\msbarcode\node_modules\webpack-dev-middleware\middleware.js:146:27)
at new Server (C:\msweb\msbarcode\node_modules\webpack-dev-server\lib\Server.js:43:20)
at Class.run (C:\msweb\msbarcode\node_modules\angular-cli\tasks\serve-webpack.js:85:22)
at C:\msweb\msbarcode\node_modules\angular-cli\commands\serve.js:102:26
at process._tickCallback (internal/process/next_tick.js:103:7)
As you can see I have a simple providing array which causes the problem (works fine in ng cli beta .21)
export var providing = [{
provide: AppStore, useFactory: (ngRedux: NgRedux<any>, devTools: DevToolsExtension) => {
const reducers = combineReducers({notify, sample_reducer});
const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
const enhancers: any = compose(middlewareEnhancer, applyDevTools);
const store = createStore(reducers, enhancers);
ngRedux.provideStore(store);
return new AppStore(store);
}, deps: [NgRedux, DevToolsExtension]
}, {
provide: "OFFLINE_ENV",
useValue: false
}, {
provide: SampleActions,
useClass: SampleActions
}];
@NgModule({
declarations: [
AppComponent,
// MyComp
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
// MsLibModule.forRoot(),
// NgReduxModule.forRoot(), //toggle
MaterialModule.forRoot()
],
providers: [providing],
bootstrap: [AppComponent]
})
so ng cli is not happy about the fact I am running a factory with functions (which is the proper way of setting up Redux). If I remove the entire providing function, .22 passes the ng serve, but again, have to do it in order to bootstrap Redux.
You can take a look at the very small project at:
https://github.com/born2net/msbarcode/tree/hmr
will be happy to help test as I'd like to get hmr running which requires .22.
regards,
Sean
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
slubowsky commentedon Dec 4, 2016
Almost certainly due to AOT. See #3354
clydin commentedon Dec 4, 2016
Try extracting the lambda into a separate function for the provider factory.
born2net commentedon Dec 4, 2016
tried this with same results:
anyway to disable AOT for now so I can focus on hrm testing?
born2net commentedon Dec 4, 2016
this is the error:
beeman commentedon Dec 5, 2016
@born2net ran into the same issue trying to get @ngrx/store working.
This fixed it for me: ngrx/store#190 (comment)
ruggedy commentedon Dec 5, 2016
@beeman Is there a way to make dev tools and store log monitor work with AOT?
Thanks
born2net commentedon Dec 5, 2016
I tried to modify my code as follows with no luck:
any ideas?
regards
Sean
ruggedy commentedon Dec 5, 2016
@born2net have you tried making the var "fac" into an untyped funciont rathar than a var .... eg
that might work
born2net commentedon Dec 5, 2016
I haven't gotten that far to trying and getting the dev tools work...
regards
born2net commentedon Dec 5, 2016
ya same error:
born2net commentedon Dec 5, 2016
actually that fixed it!!!! tx!!!!!!!!!!
born2net commentedon Dec 5, 2016
and no, dev tools is not working :(
seems like AOT is still in very early stages...
born2net commentedon Dec 5, 2016
the issue seems to be that while it is compiling now, it's not running my fac function
born2net commentedon Dec 5, 2016
@beeman
Do you know of any way to run ng cli experiential in JIT mode instead of AOT?
ruggedy commentedon Dec 5, 2016
maybe try changing useFactory: fac => useFactory: fac()
just a thought as you are not actually running the function.
5 remaining items
hansl commentedon Dec 6, 2016
Okay I cloned your repo and checked out the
hmrbranch.Putting back the
MsLibModulein your app results inError encountered resolving symbol values statically.. I checked theMsLibModuleand it doesn't have ametadata.jsonfile, so it's not compatible with the CLI. We will contact them and have them try to deploy the proper files on npm.Closing this as working as intended.
born2net commentedon Dec 6, 2016
ok but let just make sure we are on the same page.
MsLibModuleis my module andNgReduxModuleis Redux.Redux now seems fine for me on .22 (not sure what changed but now it works).
My own
MsLibModulegets the cli to hang (but works fine .21)...hansl commentedon Dec 6, 2016
We don't use static analysis in .21 to get your lazy routes, and because of that we were missing some routes. Both options have pros and cons, but we will not move back to reading your TS. External dependencies can define lazy routes and we were missing those.
I just checked and didn't know it was your library. In order to build
metadatafiles you need to install@angular/tsc-wrappedand run./node_modules/.bin/ngcwith the same arguments you would your typescript compiler.If you need further help, let us know.
hansl commentedon Dec 6, 2016
BTW, it doesn't hang locally. You might have something wrong in your node_modules.
born2net commentedon Dec 6, 2016
ok but I don't use lazy loading...
so if I understand correctly there is a major change between .21 and .22 that is causing this?
if you can provide me more info (or command to run since you cloned my project now) I would greatly appreciate it. Also, once all is working I will share this with the community as I am working with @beeman to get the docs corrected for proper --hmr
so to recap, I want to be able to use .22 and uncomment the line of:
MsLibModule.forRoot(),inapp.modulesand have it work with .22 just as it is in .21.tx again,
Angular 2 Kitchen sink: http://ng2.javascriptninja.io
and source@ https://github.com/born2net/Angular-kitchen-sink
Regards,
Sean
born2net commentedon Dec 6, 2016
and you mean to run
tsc-wrapped and run ./node_modules/.bin/ngcin my npm project MsLibModule?MsLibModule is my external npm lib project (module) which I import in.
hansl commentedon Dec 6, 2016
Sorry, more info here (it's actually
compiler-cli): https://angular.io/docs/ts/latest/cookbook/aot-compiler.htmlThat should cover questions you have about the process. Cheers!
hansl commentedon Dec 6, 2016
And yes, I mean you need to generate
metadatafiles in your MsLibModule.hansl commentedon Dec 6, 2016
It's our best practices and our recommended way to publish Angular component libraries to also publish
metadata.jsonfiles alongjsandd.tsfiles.born2net commentedon Dec 6, 2016
perfect tx
born2net commentedon Dec 6, 2016
didn't have much luck with ngc.
and still same issue with latest .22-1
hangs at 20%
root@DESKTOP-VEUHFOL /cygdrive/c/msweb/msbarcode
$ ng serve
** NG Live Development Server is running on http://localhost:4200. **
20% building modules 85/85 modules 0 active
davyvanlaere commentedon Jan 2, 2017
Problem seems to have disappeared in beta 24 ...
angular-automatic-lock-bot commentedon Sep 6, 2019
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.