Skip to content

ivy-ngcc is unable to compile AngularFire due to AngularFire not following APF #2021

Closed
@sarunint

Description

@sarunint

Version info

Angular: 8.0.0-beta.6

Firebase: 5.8.4

AngularFire: 5.1.1

Other (e.g. Ionic/Cordova, Node, browser, operating system): N/A

See AngularFire code structure: https://unpkg.com/@angular/fire@5.1.1/

I tried using Angular Compatibility Compiler to compile AngularFire. The ES2015 is compiled correctly. But ESM5 is not compiled.

During FESM5 pass, ivy-ngcc will parse index.js in the library root, because that is specify in module field in package.json.

Unfortunately, during ts.createProgram call in makeBundleProgram, TypeScript cannot load file public_api.js that is specified in index.js. This is due to the resolve order of TypeScript. It goes .ts, .tsx, .d.ts, .js, .jsx. (Reference 1 and 2) TypeScript finds public_api.d.ts first, as it also resides in the library root.

This problem will not occur if AngularFire decide to follow Angular Package Format.

  1. module key is meant for flattened ESM5.
  2. Keep the flattened ESM5 in a separate folder

I believe this cannot be fixed in the ivy-ngcc itself, since the order of file resolving is hard coded in TypeScript library. So, the best course of action would be turning AngularFire to match the Angular Package Format.

I can do the PR to fix this, but I want some approval before doing so.

Please take a look and let me know what I can help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions