You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to compile my project with ngc, it throws the below error:
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 92:25 in the original .ts file), resolving symbol AppModule in
In my App Module I have the below providers and probably this is causing the project. I am not sure what exactly is wrong with this?
Reacted by Antony Budianto, Christopher Peisert, Satish POKALA, Daniel Eduardo, Julien Renaux, Aakash, Musa Haidari, 雪狼, Velin Kerkov, Andrey Kolkov and 29 more
Reacted by Naveed Ahmed, Sergey Vohmyanin, Seva, John Wenzler, Daniel Eduardo, Jan Kuri, Dinesh B, Robert Van Gorkom, David Herges, Thorsten Hans and 101 more
Reacted by John Wenzler, Akshay Vadher, Daniel Eduardo, Jan Kuri, Robert Van Gorkom, Thorsten Hans, Dan Garcia , Niedermann IT-Dienstleistungen, Matthias Langhard, a4201856 and 22 more
Reacted by Niedermann IT-Dienstleistungen, Matthias Langhard, Justin DuJardin, Jake Niemiec, Sengrith, Alfons Bengtegård, alex, Tim, Martin Pultz, Jehong Ahn and 17 more
@chuckjaz I don't see any .metadata.json file under node_modules\ng2-charts directory. I am not able to compile my project with any of the third part plugin. Is this any special file that the every third party plugin should have?
@vicb@chuckjaz I am able to compile project after commenting out external plugins. ngc has generated ngfactory folder and ngfactory files in it for my application.
@naveedahmed1 All referenced libraries must include the .metadata.json file along side any .d.ts files they produce otherwise they will not work correctly with ngc. The .metadata.json file contains the information we need that was in the original .ts file but was not included in the .d.ts file. If we don't have that information we cannot generate the factories for the library.
Reacted by Tomas, Anna Kovtoniuk, Oleksii Trekhleb, kmolerov, Justin, Denis and Tingan Ho
Reacted by Tom Schreck, Serhii Stotskyi, Alessandro Mitelli, zheng and Tingan Ho
@naveedahmed1 The .metadata.json files are produced automatically by ngc. They should be built and delivered by the library vendor and require the .ts files.
As for the 11mb factories maybe @tbosch would have better insight into that.
I have converted my sample app to use AOT and tree shaking. I noticed that using TypeScript (tsc) for the transpilation from esm to es5 was very slow, so I switched to babel.
Is there an equivalent to @vicb's method when dealing with imports rather than providers? My AOT compilation trips up over AgmCoreModule.forRoot(...) below, with Error encountered resolving symbol values statically...
(Strangely it's happy with RouterModule.forRoot(...) - why would that be? The lack of a .metadata.json perhaps?)
got the same error after changing it that way, but thanks for replying to my question.
vendor.bundle.js:168420 Unhandled Promise rejection: appInits[i] is not a function ; Zone: ; Task: Promise.then ; Value: TypeError: appInits[i] is not a function(…) TypeError: appInits[i] is not a function
at new ApplicationInitStatus
ERROR in 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 12:42 in the original .ts file), resolving symbol compose in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/node_modules/@ngrx/core/src/compose.d.ts, resolving symbol compose in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/node_modules/@ngrx/core/index.d.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts
webpack: Failed to compile.
Reacted by Brett, valerio, Oleg Sklyanchuk and Matheus Victor
You can't use anonymous functions or online lambdas. Anything that uses a
lambda for wiring services, you need to lift that lambda out, turn it into
a named function and call it instead.
The next question is why aot can't do this...
On Sat, Feb 4, 2017, 07:56 Jim Lynch ***@***.***> wrote:
None of these "solutions" are working for me...
ERROR in 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 12:42 in the original .ts file), resolving symbol compose in ***@***.***/core/src/compose.d.ts, resolving symbol compose in ***@***.***/core/index.d.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol reducers in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/state-management/reducers/root-reducer.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts, resolving symbol AppModule in /Users/jameslynch/Git-Projects/t2-2/t2/CypherApp/src/app/app.module.ts
webpack: Failed to compile.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11262 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA50lsW-rPoEnWgIskj3Mpzx3AcWmTMwks5rZJ-_gaJpZM4JzSyy>
.
--
Daniel Joyce
The meek shall inherit the Earth, for the brave will be among the stars.
@chuckjaz I've recently encountered a generated library that did not have metadata.json attached to it. It did, however, have the original TS files for the library. It was able to compile under AoT conditions perfectly. This leads me to believe instead of compiling myself under ngc I could just have a bigger package and deploy the ts code myself. Is this true?
Note: I understand that if i don't compile it down that JS writers would not be able to use my library unless they compiled the TS down first.
bug report
I cannot understand why all issues are closed but it got me annoyed to the death... Wasted whole day on this and still cannot understand why this code is not working
"Calling function 'SotreModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule"
I compared it with RouterModule in .ts and .js all the same. Tried to many of work arounds and nothing.
In dev mode all works fine, when this code is added stright to project it works fine too, but when exported as a separate package - BAM - nothing!
If this thing will not be resolved I will not have any other way just to drop Angular support and stay only in react since this issue with ngc aot is very old.
More than that - when compiling AOT with webpack all works fine, just after upgrading to Angular 5.0.0 ngc-weback plugin is not working any more.
Im having the same issue with Angular 4.4.5.
I've tried many different configurations -
@NgModule({
imports: [
CommonModule
],
exports: [ UserComponent ],
declarations: [ UserComponent ]
})
export class SecurityModule {
static forRoot(securityService: ISecurityService): ModuleWithProviders {
console.log('Creating SecurityModule instance forRoot with service:', securityService);
return {
ngModule: SecurityModule,
providers: [{
provide: SECURITY_SERVICE,
useValue: securityService
}]
};
}
constructor (@Optional() @SkipSelf() parentModule: SecurityModule) {
if (parentModule) {
throw new Error(
'SecurityModule is already loaded. Import it in the AppModule only');
} else {
console.log('Creating SecurityModule instance for child');
}
}
}
Error: Error: Error encountered resolving symbol values statically. Calling function 'SecurityModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function,
Activity
vicb commentedon Sep 2, 2016
pls try
/cc @chuckjaz
naveedahmed1 commentedon Sep 2, 2016
Thank you so much @vicb that actually fixed the error. But now I am having another issue.
In my project I am using ng2-charts (https://github.com/valor-software/ng2-charts) but now when I try to compile my project with Angular 2 Ahead of Time Compilation (AoT) using ngc it throws below error:
Error: Unexpected value 'CHART_DIRECTIVES' declared by the module 'AppModule'Despite of the fact that I have imported CHART_DIRECTIVES in AppModule and added it to declarations .
Same error with CKEditorComponent (https://github.com/chymz/ng2-ckeditor)
chuckjaz commentedon Sep 2, 2016
Does ng2-charts have
.metadata.jsonfiles?Error: Unexpected value...could be an indication that we could not find the metadata for the module that declaredCHART_DIRECTIVES.naveedahmed1 commentedon Sep 2, 2016
@chuckjaz I don't see any .metadata.json file under node_modules\ng2-charts directory. I am not able to compile my project with any of the third part plugin. Is this any special file that the every third party plugin should have?
singhjusraj commentedon Sep 2, 2016
I'm having the same CHART_DIRECTIVES issue with ngc
Error: Unexpected value 'CHART_DIRECTIVES' declared by the module 'ReportsModule'as @naveedahmed1 said, I don't see any
.metadata.jsonfilesIf a plugin doesn't have this file how do I make it happen?
singhjusraj commentedon Sep 2, 2016
With ngc I'm also having
Resource file not found:issues where it doesn't load my html template filesin the component, I have..
@Component({ selector: 'my-dashboard', templateUrl: 'app/Home/home.component.html' })while compiling with ngc I get
Error: Compilation failed. Resource file not found: C:/Users/sukhdeep/Documents/Angular/gd_dev_server/app/Home/app/Home/home.component.htmlSee that in the path there is
/app/Home/app/Home/I should just be
/app/Home/How do I resolve this?
It's just weird issue with file paths.
My
tsconfig.jsonis:{ "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "rootDir": "./" }, "angularCompilerOptions": { "genDir": "./ngfactory" } }I have absolutely no problems in JIT
naveedahmed1 commentedon Sep 2, 2016
@Sukh9212 regarding your paths issue, I would suggest using relative paths please visit https://angular.io/docs/ts/latest/cookbook/component-relative-paths.html for details
singhjusraj commentedon Sep 2, 2016
@naveedahmed1 thanks. Paths issue resolved now
naveedahmed1 commentedon Sep 2, 2016
@vicb @chuckjaz I am able to compile project after commenting out external plugins. ngc has generated ngfactory folder and ngfactory files in it for my application.
But now when I updated my main.ts file by following the instructions at http://angularjs.blogspot.com/ and tried to run my application. It seems that Typescript compile is stuck. Its been several minutes and its still running. Furthermore the ngfactory folder has a size of around 11mb, is it normal?
My above errors also still needs your attention and guidance.
chuckjaz commentedon Sep 2, 2016
@naveedahmed1 All referenced libraries must include the
.metadata.jsonfile along side any.d.tsfiles they produce otherwise they will not work correctly withngc. The.metadata.jsonfile contains the information we need that was in the original.tsfile but was not included in the.d.tsfile. If we don't have that information we cannot generate the factories for the library.naveedahmed1 commentedon Sep 2, 2016
@chuckjaz thank you so much for your reply. Is there any guideline about how to product that file?
Secondly is it okay to have ngfactory (folder containing factories) with size over 11 mb?
chuckjaz commentedon Sep 2, 2016
@naveedahmed1 The
.metadata.jsonfiles are produced automatically byngc. They should be built and delivered by the library vendor and require the.tsfiles.As for the 11mb factories maybe @tbosch would have better insight into that.
thelgevold commentedon Sep 3, 2016
I have converted my sample app to use AOT and tree shaking. I noticed that using TypeScript (tsc) for the transpilation from esm to es5 was very slow, so I switched to babel.
Here is my demo app running AOT/tree shaken code.
http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet
Source here:
https://github.com/thelgevold/angular-2-samples
Just follow the trail from package.json to see the steps I am using to AOT/shake.
robhogan commentedon Sep 10, 2016
Is there an equivalent to @vicb's method when dealing with
importsrather thanproviders? My AOT compilation trips up overAgmCoreModule.forRoot(...)below, withError encountered resolving symbol values statically...(Strangely it's happy with
RouterModule.forRoot(...)- why would that be? The lack of a.metadata.jsonperhaps?)Thanks!
28 remaining items
anrepppp commentedon Feb 1, 2017
got the same error after changing it that way, but thanks for replying to my question.
vendor.bundle.js:168420 Unhandled Promise rejection: appInits[i] is not a function ; Zone: ; Task: Promise.then ; Value: TypeError: appInits[i] is not a function(…) TypeError: appInits[i] is not a function
at new ApplicationInitStatus
anrepppp commentedon Feb 1, 2017
@DzmitryShylovich
It worked, this approach worked:
{provide: APP_INITIALIZER, useFactory:initFactory, deps: [AppConfig], multi: true },
export function initFactory(config: AppConfig) {
return () => config.load();
}
Thanks a ton, you saved couple of days of my effort. I was looking at this issue from long time. Thank you.
tytskyi commentedon Feb 1, 2017
@anvesh48 and others who want to use AOT, you could check https://github.com/rangle/angular-2-aot-sandbox for AoT Do's and Don'ts
anrepppp commentedon Feb 1, 2017
Thanks, @tytskyi it is very useful.
JimLynchCodes commentedon Feb 4, 2017
None of these "solutions" are working for me...
DanielJoyce commentedon Feb 4, 2017
kenisteward commentedon May 10, 2017
@chuckjaz I've recently encountered a generated library that did not have metadata.json attached to it. It did, however, have the original TS files for the library. It was able to compile under AoT conditions perfectly. This leads me to believe instead of compiling myself under ngc I could just have a bigger package and deploy the ts code myself. Is this true?
Note: I understand that if i don't compile it down that JS writers would not be able to use my library unless they compiled the TS down first.
vytautas-pranskunas- commentedon Nov 2, 2017
Bug Report
I cannot understand why all issues are closed but it got me annoyed to the death... Wasted whole day on this and still cannot understand why this code is not working
throwing an error:
I compared it with RouterModule in .ts and .js all the same. Tried to many of work arounds and nothing.
In dev mode all works fine, when this code is added stright to project it works fine too, but when exported as a separate package - BAM - nothing!
Anybody?
For example RouterModule:
If this thing will not be resolved I will not have any other way just to drop Angular support and stay only in react since this issue with ngc aot is very old.
More than that - when compiling AOT with webpack all works fine, just after upgrading to Angular 5.0.0 ngc-weback plugin is not working any more.
here is complete code of ng-state.module.ts:
chaosmonster commentedon Nov 3, 2017
I think this has nothing to do with this or any issue. I think you should ask this question at stack overflow
jdbranham commentedon Nov 6, 2017
Im having the same issue with Angular 4.4.5.
I've tried many different configurations -
Error: Error: Error encountered resolving symbol values statically. Calling function 'SecurityModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function,
Toxicable commentedon Nov 6, 2017
@jdbranham remove the
console.logjdbranham commentedon Nov 6, 2017
I removed the console logging but it still fails. This is the module + usage of the module -
jdbranham commentedon Nov 6, 2017
I opened a question at SO, in case this is not a bug, but rather an issue with my code.
https://stackoverflow.com/questions/47141105/angular-4-static-analysis-fails-for-usevalue-provider
angular-automatic-lock-bot commentedon Sep 12, 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.