question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular2 AoT Compiler Errors

See original GitHub issue

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?

providers: [
        GlobalService,
        {
            provide: Http,
            useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, globalService: GlobalService) => new HttpLoading(backend, defaultOptions, globalService),
            deps: [XHRBackend, RequestOptions, GlobalService]
        }
    ],

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:39
  • Comments:52 (23 by maintainers)

github_iconTop GitHub Comments

170reactions
vicbcommented, Sep 2, 2016

pls try

export function httpFactory(backend: XHRBackend, defaultOptions: RequestOptions, globalService: GlobalService) {
  return  new HttpLoading(backend, defaultOptions, globalService);
}

providers: [
        GlobalService,
        {
            provide: Http,
            useFactory:  httpFactory,
            deps: [XHRBackend, RequestOptions, GlobalService]
        }
    ],

/cc @chuckjaz

74reactions
DanielJoycecommented, Oct 20, 2016

Oh for crying out loud. So to get decent load times for Angular2 apps we need to use ngc. To use NGC, we now need every every vendor of angular2 libs to now include a .metadata.json file? So now we’re dependent on that as well?

So what are we going to do since Angular2 allows people to write components in pure JS, and since JS is not Typescript, these libraries/modules will never have a .metadat.json and thus can never be used by AOT?

I’ve tried three different ways to shrink down a angular2 app to a decent size and reduce download times by bundling stuff up into one module, and all three have been dead ends. Various, errors, poor documentation, and our app takes 10 seconds to start due to the hundreds of npm deps it loads at boot.

  • Angular-cli? Buggy. No go
  • Angular aot compiler? Not every already shipping angular2 lib has .metadata.json files
  • Rollup? Issues with libs being shipped in various incompatible module formats in npm. Some are commonjs, some amd, etc, and rollup can handle some but not others.

Is there a sane "WORKS NOW’ way to make a single js bundled app file? Even with no AOT? For a 1.0 release this is maddening.

If I were to jump through these hopes, would I finally a single file, or nearly single Angular2 app? Or do I need to find a bundler that would then work with everything else we use?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AOT metadata errors - Angular
The following are metadata errors you may encounter, with explanations and ... Avoid this error by sticking to the compiler's restricted expression syntax ......
Read more >
Improved Error Logging by the Angular AOT Compiler
In Angular 10.1, another error logging improvement by the AOT compiler is introduced. Let's see how the error logging has improved over the...
Read more >
angular - Why won't aot compiler error on missing property?
AoT compiles the template beforehand, and is looking for the bindings to be generated. On the other hand, having it in an ng-container...
Read more >
Angular 6 AOT compilation not working - Error in ... - GitHub
I created minimal sample app to reproduce this error. The key point is that this app is AOT compiled using the webpack plugin...
Read more >
Angular: Writing AoT-friendly applications | by David - Medium
Angular CLI comes with built-in AoT support. In the development target environment, it uses JiT (Just-in-Time) compilation for better developer experiences and ...
Read more >

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found