Fix ng build warnings
There are several warnings
Its a waste of time. No one even looks at these issues.
@1001daysofcode Thanks for the report, and apologies that it sat unanswered this long.
I tried to reproduce this from the screenshot, and I want to share what I found. I may be missing something about your project, and I'd like your help confirming or refuting this before anything is decided.
What I tried
- A fresh Angular app using the webpack
browserbuilder - File layout mirroring the paths in your screenshot:
*-private.resolve.tsfilestheme.stubs.ts- the
environment.alpha/beta/production.tstrio src/test.tstheme.service.tsthat imports thecolorpackage
- Building that app before adding AngularFire at all produced what appears to be the same warning set as your screenshot.
- Adding
@angular/fireto the same app didn't add or change any warning.
My working theory
So my working theory is that these warnings aren't coming from AngularFire:
- The
…is part of the TypeScript compilation but it's unusedwarnings come from the Angular CLI's webpack builder: any.tsfile matched bytsconfig.app.json'sinclude(the defaultsrc/**/*.ts) that isn't reachable from an entry point gets flagged.- Your
environment.*.tsreplacement files andsrc/test.tsare exactly this case: matched byinclude, but not reached from an entry point (see e.g. angular/angular-cli#17485). - Narrowing
files/includeintsconfig.app.jsonsilences it.
- Your
- The
theme.service.ts depends on 'color'warning is about thecolornpm package being CommonJS (its v4 line; v5 is ESM).- Adding
colortoallowedCommonJsDependenciesinangular.json, or upgrading tocolor@5, addresses that one.
- Adding
Background (if the theory holds)
- Both warnings come from the Angular CLI's webpack builder (
angular/angular-clirepo), not from anything in your dependency list, and both look like intended diagnostics rather than bugs.- On the unused-file warning, the CLI maintainers have pointed reporters at their tsconfig
files/includerather than treating it as a CLI defect. - See angular/angular-cli#17485, where the resolution was to narrow
tsconfig.app.jsonto entry points, matching the shape the CLI's own generated template uses.
- On the unused-file warning, the CLI maintainers have pointed reporters at their tsconfig
- On the
colorside, the maintainers resolved this on their end by shipping v5 as native ESM. - The webpack
browserbuilder is deprecated (per Angular's build-system docs), and the newer esbuildapplicationbuilder that replaced it simply doesn't perform this unused-file analysis, so the warning doesn't occur there.
Concrete fixes for your project
- For the unused-file warnings: change
tsconfig.app.jsonto"files": ["src/main.ts"]plus"include": ["src/**/*.d.ts"].- In my reproduction this took the unused-file warning count to zero, with AngularFire installed and
fileReplacementsstill working (thecolorwarning is separate; see below). - Alternatively, keep the broad
includeand delete or wire up the files nothing reaches.
- In my reproduction this took the unused-file warning count to zero, with AngularFire installed and
- For the
colorwarning: upgrade tocolor@5, which ends the warning at the source.allowedCommonJsDependenciesinangular.jsonis the way to acknowledge it deliberately if you need to stay on v4.
- Longer-term: migrating to the
applicationbuilder is the durable path (the tweaks above work without it).
What would help me verify
I'd prefer to gather more information before committing to these conclusions. A few things would help me verify:
- Which versions are you on:
ng versionoutput, and the@angular/fireentry in yourpackage.json? - Is there more build output below the screenshot's last line, in particular anything that mentions
@angular/fireorfirebase? - Could you paste your
tsconfig.app.json(especiallyfiles/include/exclude)? - Did the warnings start after a particular upgrade or after
ng add @angular/fire, or have they always been there?
One more AngularFire-side detail
- Old versions (≤ 7.x) of
ng add @angular/firedid createenvironment.*.tsfiles, so if this project goes back that far, some of the flagged files may originally have been generated by AngularFire. - The warning itself is still the tsconfig-include behavior above, but I mention it in case it explains where those files came from.
If your provided details point somewhere I've missed, I'll dig back in.
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
I removed angularfire and just used the sdk instead
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Hey @1001daysofcode. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
@armando-navarro Can you just close this? An email about it every 2 weeks for the past 16 weeks is noisy, and 1001daysofcode responded already. Maybe not fully, but it really seems like this item is dead.
@rgant Fair point, and sorry about the repeated emails. I'm closing this now.
@1001daysofcode Thanks for letting us know you've moved to the Firebase SDK directly. In my reproduction these warnings were already there before AngularFire was added and didn't change after adding it, so I don't see an AngularFire change to make here. If you or anyone else hits a build warning that does trace back to @angular/fire, please open a new issue with your ng version output and the full build log, and I'll take a look.