angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.67k stars 2.19k forks source link

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

Closed sarunint closed 3 years ago

sarunint commented 5 years ago

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.

jamesdaniels commented 5 years ago

I'm open to any help with the packaging 😃Feel free to fire over a PR, even if just a proof of concept.

Ismaestro commented 5 years ago

any updates? This is a serious problem trying to use this library and Ivy. Reported here and here.

wmattei commented 4 years ago

Any updates?

hiepxanh commented 4 years ago

seem like relate to this issues I don't know how to help

hiepxanh commented 4 years ago

aw look like update to angularfire 6 (not release) will solve the problem https://github.com/angular/angularfire/pull/2282