Skip to content

Ivy fails with firebase #29939

Closed
Closed

Description

@StephenFluin

🐞 bug report

Is this a regression?

Yes, this is a regression

Description

AngularFire works well with v7 and v8 without Ivy, but turning on Ivy prevents me from doing builds.

🔬 Minimal Reproduction

https://github.com/StephenFluin/ivy-firebase-repro/commits/master

  1. Create new app
  2. Add firebase & realtime database
  3. Update to v8 (works)
  4. Turn on Ivy (fails)

🔥 Exception or Error


$ ng build --prod --source-map
 10% building 3/3 modules 0 active 10% building 3/4 modules 1 active ...ce/te 10% building 3/4 modules 1 active ...ce/test/my-firebase-app/ 3 3 92%                                                                                                                   
Date: 2019-04-16T20:25:06.901Z - Hash: 9f64d91c0f0234d69e04 - Time: 29315ms
1 unchanged chunks
chunk {0} runtime-es5.741402d1d47331ce975c.js, runtime-es5.741402d1d47331ce975c.js.map (runtime) 1.47 kB [entry] [rendered]
chunk {2} polyfills-es5.db1ca970d93c3d6854ef.js, polyfills-es5.db1ca970d93c3d6854ef.js.map (polyfills) 111 kB [initial] [rendered]
chunk {3} styles.3f414165053c69a0bfa1.css, styles.3f414165053c69a0bfa1.css.map (styles) 59 bytes [initial] [rendered]

WARNING in ./src/app/app.component.ts 24:200-222
"export 'AngularFireDatabase' (imported as 'i1') was not found in '@angular/fire/database'

WARNING in ./src/app/app.component.ts 44:38-60
"export 'AngularFireDatabase' (imported as 'i1') was not found in '@angular/fire/database'

WARNING in ./src/app/app.module.ts 24:16-41
"export 'AngularFireDatabaseModule' was not found in '@angular/fire/database'

WARNING in ./src/app/app.module.ts 30:48-73
"export 'AngularFireDatabaseModule' was not found in '@angular/fire/database'

WARNING in ./src/app/app.module.ts 48:20-45
"export 'AngularFireDatabaseModule' was not found in '@angular/fire/database'

WARNING in ./src/app/app.module.ts 30:26-46
"export 'AngularFireModule' (imported as 'i1') was not found in '@angular/fire'

WARNING in ./src/app/app.module.ts 16:16-33
"export 'AngularFireModule' was not found in '@angular/fire'

WARNING in ./src/app/app.module.ts 40:20-37
"export 'AngularFireModule' was not found in '@angular/fire'

ERROR in ./node_modules/@angular/fire/__ivy_ngcc__/index.js
Module not found: Error: Can't resolve './public_api' in '/usr/local/google/home/stephenfluin/workspace/test/my-firebase-app/node_modules/@angular/fire/__ivy_ngcc__'
ERROR in ./node_modules/@angular/fire/__ivy_ngcc__/database/index.js
Module not found: Error: Can't resolve './public_api' in '/usr/local/google/home/stephenfluin/workspace/test/my-firebase-app/node_modules/@angular/fire/__ivy_ngcc__/database'
ERROR in chunk main [initial]
main-es5.b02852a167e1fde953ab.js
/usr/local/google/home/stephenfluin/workspace/test/my-firebase-app/node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js??ref--16-0!/usr/local/google/home/stephenfluin/workspace/test/my-firebase-app/node_modules/@ngtools/webpack/src/index.js!/usr/local/google/home/stephenfluin/workspace/test/my-firebase-app/src/main.ts 77d72dccf0f5f5a9ddce59dbb9489804
Cannot read property 'isProvided' of null

🌍 Your Environment

Angular Version:


Angular CLI: 8.0.0-beta.15
Node: 11.10.0
OS: linux x64
Angular: 8.0.0-beta.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-beta.15
@angular-devkit/build-angular     0.800.0-beta.15
@angular-devkit/build-optimizer   0.800.0-beta.15
@angular-devkit/build-webpack     0.800.0-beta.15
@angular-devkit/core              8.0.0-beta.15
@angular-devkit/schematics        8.0.0-beta.15
@angular/@types                   
@angular/cli                      8.0.0-beta.15
@angular/events                   
@angular/fire                     5.1.2
@angular/firebase                 
@angular/rxjs                     
@angular/source-map               
@angular/tslib                    
@angular/typescript               
@ngtools/webpack                  8.0.0-beta.15
@schematics/angular               8.0.0-beta.15
@schematics/update                0.800.0-beta.15
rxjs                              6.4.0
typescript                        3.4.3
webpack                           4.29.6


Activity

  1. added this to the Backlog milestone on Apr 16, 2019
  2. m-henderson commented on Apr 21, 2019

    @m-henderson

    @StephenFluin have you looked into the issue at all and could maybe provide your findings? If not, no big deal(: would save me some legwork

  3. JoostK commented on Apr 21, 2019

    @JoostK
    Member

    Initial findings are that the CLI will first kickof ngcc with "browser", "module", "main", resulting in the ES5 sources being analyzed and because it is the first request, will also update the .d.ts files.

    That is all fine, however the ES5 analysis ends up completely empty. I found using ts.Program.getSourceFiles().map(sf => sf.fileName).filter(n => n.endsWith('.js')) that the program's sources only included the entry point's index.js, its import to ./public_api was not within the list.

    So, what is going on? Some more debugging let me to the root problem here: the typing files and JS source files are all located in the same directory. Hence, when TypeScript resolves ./public_api its module resolution system will end up with ./public_api.d.ts! Hence, the actually interesting source files that ngcc needs to process never become part of the analysis program; causing ngcc to conclude there's nothing to update in the source nor in the typings but the package is marked as being processed regardless (which is correct).

    We'll probably need some way of customizing TypeScript's module resolution system here, such that it prefers '.js' files over '.d.ts'.

    cc @m-henderson

  4. sarunint commented on Apr 21, 2019

    @sarunint
    Contributor
  5. JoostK commented on Apr 21, 2019

    @JoostK
    Member

    @sarunint Thanks for your investigation, it is spot on! If I knew that before it would have saved me a lot of time :) I am actually trying to come up with customized module resolution logic in ngcc to support this.

  6. sarunint commented on Apr 21, 2019

    @sarunint
    Contributor

    Well, I spent hours on why ES5 bundle won't compile. Lol

  7. JoostK commented on Apr 21, 2019

    @JoostK
    Member

    Well, I spent hours on why ES5 bundle won't compile. Lol

    Me too 🤡

  8. sarunint commented on Apr 21, 2019

    @sarunint
    Contributor

    Now that the root cause is known, are we going to fix ivy-ngcc, or fix AngularFire?

  9. sarunint commented on Apr 21, 2019

    @sarunint
    Contributor

    By "fixing AngularFire", I mean "make amendments to Angular Package Format to specify that the bundles (ESM/FESM 5/2015) must be in a subfolder, then make changes to AngularFire".

  10. 6 remaining items

  11. added a commit that references this issue on Apr 30, 2019
    9d06ff3
  12. StephenFluin commented on May 13, 2019

    @StephenFluin
    ContributorAuthor

    @alxhub says we don't correctly compile this under ES5.

  13. added a commit that references this issue on May 21, 2019
    cb50608
  14. vdjurdjevic commented on May 30, 2019

    @vdjurdjevic

    Any progress on this? It works with ng serve and ivy enabled, but with build --prod it fails

  15. JoostK commented on Jun 1, 2019

    @JoostK
    Member

    @vladimirdjurdjevic Should be fixed once #30591 is in.

  16. kara commented on Aug 20, 2019

    @kara
    Contributor

    #30591 is in

  17. angular-automatic-lock-bot commented on Sep 20, 2019

    @angular-automatic-lock-bot

    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.

  18. locked and limited conversation to collaborators on Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions