Skip to content

ivy-ngcc is unable to recognise AngularFireModule.initializeApp as ModuleWithProviders #29078

@sarunint

Description

@sarunint

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler-cli

Is this a regression?

No

Description

Take a look at this code (taken from https://unpkg.com/@angular/fire@5.1.1/es2015/firebase.app.module.js):

let AngularFireModule = AngularFireModule_1 = class AngularFireModule {
    static initializeApp(options, nameOrConfig) {
        return {
            ngModule: AngularFireModule_1,
            providers: [
                { provide: FirebaseOptionsToken, useValue: options },
                { provide: FirebaseNameOrConfigToken, useValue: nameOrConfig }
            ]
        };
    }
};
AngularFireModule = AngularFireModule_1 = __decorate([
    NgModule({
        providers: [FirebaseAppProvider],
    })
], AngularFireModule);
export { AngularFireModule };

ivy-ngcc cannot recognise the AngularFireModule.initializeApp and mark it as ModuleWithProviders.

This is because the current implementation of ivy-ngcc which looks for ts.ClassDeclaration. Instead, the code above is a variable assignment to ts.BinaryExpression which includes ts.ClassExpression.

There are 2 solutions to this issue:

  1. Make ivy-ngcc to able to recognise class declaration like this.
  2. Tell library authors to use angularCompilerOptions.annotationsAs as static fields during packaging.

My voice is with solution 2, though.

🔬 Minimal Reproduction

N/A

🔥 Exception or Error

N/A

🌍 Your Environment

Angular Version:



8.0.0-beta.6

Anything else relevant?

This causes #28603.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions