Skip to content

Presence of undici while building for browser targets throws warnings about esm/cjs (used via @angular/fire) #7914

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

Closed
vajahath opened this issue Dec 30, 2023 · 4 comments

Comments

@vajahath
Copy link

Operating System

Ubuntu 22.04

Browser Version

Chrome

Firebase SDK Version

firebase 10.7.1

Firebase SDK Product:

Auth

Describe your project's tooling

I'm using @angular/fire along with Angular.

Angular CLI: 17.0.8
Node: 18.19.0
Package Manager: pnpm 8.13.1
OS: linux x64

Angular: 17.0.8
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.8 (cli-only)
@angular-devkit/build-angular   17.0.8
@angular-devkit/core            17.0.8 (cli-only)
@angular-devkit/schematics      17.0.8 (cli-only)
@angular/fire                   17.0.0              👈👈👈
@schematics/angular             17.0.8 (cli-only)
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Describe the problem

A fresh project ng build-ing after adding @angular/fire throws warnings:

image

▲ [WARNING] Module 'undici' used by 'node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/dist/node-esm/index.js' is not ESM

  CommonJS or AMD dependencies can cause optimization bailouts.
  For more information see: https://angular.io/guide/build#configuring-commonjs-dependencies
➜  hho git:(master) ✗ pnpm why firebase -r
Legend: production dependency, optional only, dev only

[email protected] /home/vaju/hho

dependencies:
@angular/fire 17.0.0
├── firebase 10.7.1
└─┬ rxfire 6.0.5
  └── firebase 10.7.1 peer

I found in this comment where @DellaBitta says (ref #7849 (comment)):

We've limited the use of undici to non browser-based targets (ie: node) so it shouldn't be included as a dependency when building for browser targets.

In that case, I was wondering this warnings should not happen. (maybe undici is not getting treeshaked, idk)

Steps and code to reproduce issue

npm i -g @angular/cli
ng new myapp

# try a build (should pass)
ng build

# add angular/fire
ng add @angular/fire
# proceed through project selection
# choose authentication 👈👈👈

# try the build again
ng build
@vajahath vajahath added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Dec 30, 2023
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 1, 2024
@hsubox76
Copy link
Contributor

hsubox76 commented Jan 4, 2024

You mention you're building for browser but the warning indicates the build tool is looking at the file @firebase/auth/dist/node-esm/index.js which is the Node ESM bundle. It should be looking at @firebase/auth/dist/esm2017/index.js if the build tool resolver is configured to point at the browser.

You can take a look at the package.json for @firebase/auth. If your resolver is looking at top-level fields "browser" or "module", or exports fields "browser" or "default", it should take you to the correct file. The resolver must be looking at the exports field "node" in order to end up resolving to the node-esm/index.js file. Do you know anything about your resolver settings?

@DellaBitta
Copy link
Contributor

While you're building for clients/browsers, the build system seems to have SSR enabled based on the logging you've provided:

Angular: 17.0.8
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Specifically that final element listed there.

While undici shouldn't be part of your browser based builds, I think that Angular Fire is detecting that undici is part of your build process (since it's brought in when SSR is enabled), and Angular Fire is warning you that undici isn't supported in the browser.

It shouldn't be the case that undici is brought into the client builds, however. If you find that there are any lasting negative effects then please do let us know, but I think that this warning can be ignored.

@google-oss-bot
Copy link
Contributor

Hey @vajahath. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 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!

@google-oss-bot
Copy link
Contributor

Since there haven't been any recent updates here, I am going to close this issue.

@vajahath if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants