Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 8.2.14 No provider for FaConfig #210

Closed
AmaelN opened this issue Dec 3, 2019 · 9 comments
Closed

Angular 8.2.14 No provider for FaConfig #210

AmaelN opened this issue Dec 3, 2019 · 9 comments
Milestone

Comments

@AmaelN
Copy link

AmaelN commented Dec 3, 2019

Describe the problem

I've follow the procedure describe on the readme to use font awsome and installed all required packages

"@fortawesome/angular-fontawesome": "^0.6.0-alpha.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.25",
    "@fortawesome/free-brands-svg-icons": "^5.11.2",
    "@fortawesome/free-solid-svg-icons": "^5.11.2",

When I'm using ng serve, everything is working well and my icons are present
but as soon as I'm using ng serve --prod
I'm getting the following error message

  StaticInjectorError(Platform: core)[angular_fontawesome_FaIconComponent -> FaConfig]: 
    NullInjectorError: No provider for FaConfig!```
<!--- What happened? What are you seeing? How did you arrive here? -->
I just open my browser when everything is compile succeful message from angular 
### What did you expect?
No issue en prod mode for NoProvider for FaConfig

### Reproducible test case
Angular CLI: 8.3.20
Node: 10.16.0
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.803.20
@angular-devkit/build-angular              0.803.20
@angular-devkit/build-optimizer            0.803.20
@angular-devkit/build-webpack              0.803.20
@angular-devkit/core                            8.3.20
@angular-devkit/schematics                 8.3.20
@angular/cli                                           8.3.20
@ngtools/webpack                                8.3.20
@nguniversal/common                          8.1.1
@nguniversal/express-engine                8.1.1
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        8.3.20
@schematics/update                         0.803.20
rxjs                                            6.5.3
typescript                                 3.5.3
webpack                                    4.39.2

@AmaelN
Copy link
Author

AmaelN commented Dec 4, 2019

My angular.cjson for production has the following parameters

               "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,

@AmaelN
Copy link
Author

AmaelN commented Dec 4, 2019

I had to use the version 0.5.0 of @fortawesome/angular-fontawesome instead of version 0.6.0-alpha.0

@AmaelN AmaelN closed this as completed Dec 4, 2019
@bgever
Copy link

bgever commented Dec 13, 2019

@AmaelN Thanks for the workaround of downgrading to 0.5.0, that worked.

However, this issue still persists with 0.6.0-alpha.0, could we keep the issue open so it can be resolved?

@devoto13
Copy link
Collaborator

@bgever Can you create a repository on GitHub with the minimal code to reproduce this issue?
I'm pretty sure I've tested 0.6.0-alpha.0 on the latest Angular/CLI 8.x at the time of the release and didn't experience any issues.

@devoto13 devoto13 reopened this Dec 13, 2019
@NorseJedi
Copy link

@devoto13 If you test it with aot enabled, you'll most likely get the error too. With aot disabled it works without any issues, and the default setting is aot: false on the development server, but true when building for production.

@bgever
Copy link

bgever commented Dec 16, 2019

@devoto13 Thanks for looking into it!

Please check out this repo for reproduction: https://github.com/bgever/ng-fa-aot

Commit messages should be explanatory.

  • I've put two coffee icons in the app.
  • Exposed FA via a SharedModule pattern.
  • Use one icon in a lazy loaded route (/lazy) — the 2nd coffee icon will appear at the bottom of the page, once you click the coffee icon above the 'Resources' heading.
  • Disabled production build optimization (AOT build is not minified).

Run npm run start-dist and open http://localhost:4200/ to see the run-time error appear in the JavaScript console:

ERROR NullInjectorError: StaticInjectorError(AppModule)[FaIconComponent -> FaConfig]: 
  StaticInjectorError(Platform: core)[FaIconComponent -> FaConfig]: 
    NullInjectorError: No provider for FaConfig!
    at NullInjector.get (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:8816:27)
    at resolveToken (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23605:24)
    at tryResolveToken (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23531:16)
    at StaticInjector.get (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23382:20)
    at resolveToken (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23605:24)
    at tryResolveToken (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23531:16)
    at StaticInjector.get (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:23382:20)
    at resolveNgModuleDep (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:34409:29)
    at NgModuleRef_.get (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:35473:16)
    at resolveDep (http://localhost:4200/main-es2015.5c479ad85e374062b8b9.js:36001:45)
defaultErrorLogger @ main-es2015.5c479ad85e374062b8b9.js:13146

(note that I've disabled build optimization in order to see the actual names instead of minified ones)

@devoto13
Copy link
Collaborator

devoto13 commented Dec 16, 2019

@ensnared I think you're right. Most likely I served the app in development mode and compiled in production mode, but never tried to serve in production mode.

@bgever Thanks for the reproduction! I've looked into it and in fact it crashes even with the basic setup described in the README using AoT. I've tried to debug it a bit and it seems that library build produced by Angular CLI 9.x does not really work for the Angular 8.x application as nothing really changed in the relevant source code of the angular-fontawesome.

Given that this is a tooling issue, which I don't think will be fixed by Angular/Angular CLI and the amount of problems people get trying to run 0.6.0-alpha.0 on Angular 8.x I'm going to resolve it by dropping support for Angular 8.x in 0.6.0 release of angular-fontawesome. So use 0.5.0 for Angular 8.x and 0.6.x for Angular 9.x.

@devoto13 devoto13 added this to the 0.6.0 milestone Dec 16, 2019
@bgever
Copy link

bgever commented Dec 16, 2019

0.5 is working well for me with Angular 8, so I don't see issues for dropping support in 0.6.

Thanks for looking into the issue! 👍

devoto13 added a commit to devoto13/angular-fontawesome that referenced this issue Dec 16, 2019
Also adds end-to-end test for VE mode.

Closes FortAwesome#208 FortAwesome#210
devoto13 added a commit to devoto13/angular-fontawesome that referenced this issue Dec 16, 2019
Also adds end-to-end test for VE mode.

Closes FortAwesome#208 FortAwesome#210
devoto13 added a commit to devoto13/angular-fontawesome that referenced this issue Dec 16, 2019
Also adds end-to-end test for VE mode.

Closes FortAwesome#208 FortAwesome#210
devoto13 added a commit that referenced this issue Dec 16, 2019
Also adds end-to-end test for VE mode.

Closes #208 #210
@devoto13
Copy link
Collaborator

Closed per #213.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants