TrilonIO / aspnetcore-angular-universal

ASP.NET Core & Angular Universal advanced starter - PWA w/ server-side rendering for SEO, Bootstrap, i18n internationalization, TypeScript, unit testing, WebAPI REST setup, SignalR, Swagger docs, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.46k stars 433 forks source link

Error encountered resolving symbol values statically. Calling function 'InjectionToken' #194

Closed pjmagee closed 7 years ago

pjmagee commented 7 years ago

Would you happen to know why trying to use InjectionToken as a Provide value in my Providers for an Angular Module would blow up?

[31mERROR in Error encountered resolving symbol values statically. Calling function 'InjectionToken', function calls are not supported. Consider rep
lacing the function or lambda with a reference to an exported function, resolving symbol ORIGIN_URL in
MarkPieszak commented 7 years ago

Can you show how you're doing it? Is this the ORIGIN_URL we're automatically providing in the engine?

pjmagee commented 7 years ago

Yeah it's the same code from the repo. I think something funny is going on here. I pulled down a fresh repo and added barrels in to see if our project was having side effects and after adding barrels/paths into this template project for things like app-models, app-modules, app-shared I'm getting errors like this....

    ERROR in Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', 
    function calls are not supported. Consider replacing the function or lambda with a reference to an 
    exported function, resolving symbol NgModule in c:/projects/github/aspnetcore-angular2-
    universal/node_modules/@angular/core/core.d.ts, resolving symbol ServerTransferStateModule in 
    c:/projects/github/aspnetcore-angular2-universal/Client/modules/transfer-state/server-transfer-
    state.module.ts, resolving symbol ServerTransferStateModule in c:/projects/github/aspnetcore-angular2-
    universal/Client/modules/transfer-state/server-transfer-state.module.ts

We're still currently based off the 2.0 branch of this template. But we have tons of components and shared services for api calls etc and we really wanted to push for the Angular4 template for things like productionising our application because of things like the baseURI and Cookies in transferData.

MarkPieszak commented 7 years ago

There's definitely some kind of error when it's trying to statically analyze the code, not sure why it's pointing at server transfer that's a pretty basic NgModule that doesn't even use useFactory, browser one does, but it's being exported properly.

I'm wondering if it's the barrels themselves that are causing this issue, right? Are you doing export * or export { Whatever } for everything.

Wondering if it's something like this https://github.com/angular/angular/issues/15767 causing it

Also for AoT references this is a great list: https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5

pjmagee commented 7 years ago

With the barrels I have the index.ts files with export * from './something'. I'll check the links you provided.

MarkPieszak commented 7 years ago

Yeah try to export the actual item export { Something } from './something'; I think * is one of the (many) things AoT static analysis isn't a fan of.

pjmagee commented 7 years ago

Yeah, I updated the * and replace it with export { ActualClass } from './actual-class' but the same problems occur. I think I've spent far too much time on just getting something to work 💃

MarkPieszak commented 7 years ago

Haha I feel you on that one 😿 So I just tried and was able to get Paths working, I only setup app-shared so far in development, but no luck in AoT :(