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 report server dependencies as not esm #27553

Closed
1 task
robertIsaac opened this issue Apr 27, 2024 · 3 comments
Closed
1 task

angular report server dependencies as not esm #27553

robertIsaac opened this issue Apr 27, 2024 · 3 comments

Comments

@robertIsaac
Copy link

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

when building using application builder with SSR Angular warn about node dependencies
this is the same as my problem
firebase/firebase-js-sdk#7914
by removing the server configuration this warning disappear

expected behavior
not to show warning about node modules

Minimal Reproduction

  1. generate new angular project with SSR
  2. ng add @angular/fire and choose Authentication
  3. run ng build

Exception or Error

▲ [WARNING] Module 'undici' used by '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

Your Environment

Angular CLI: 17.3.6
Node: 20.11.0
Package Manager: npm 10.4.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.6
@angular-devkit/build-angular   17.3.6
@angular-devkit/core            17.3.6
@angular-devkit/schematics      17.3.6
@angular/fire                   17.0.1
@schematics/angular             17.3.6
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.4

Anything else relevant?

No response

@JoostK
Copy link
Member

JoostK commented Apr 27, 2024

undici is, in fact, a CJS module: https://unpkg.com/browse/undici@6.14.1/index.js. AFAICS undici is not a Node builtin; it being the backing implementation for Node's fetch global doesn't necessarily mean that importing undici leverages the same built in Undici module.

@robertIsaac
Copy link
Author

undici is, in fact, a CJS module: https://unpkg.com/browse/undici@6.14.1/index.js. AFAICS undici is not a Node builtin; it being the backing implementation for Node's fetch global doesn't necessarily mean that importing undici leverages the same built in Undici module.

I might have misunderstand the warning, but I feel the main purpose of showing the warning is the browser bundle size, which means if the package is used only in SSR then it shouldn't warn since the browser bundle size is unaffected

@alan-agius4
Copy link
Collaborator

Though mainly linked to enhancing front-end performance, ESM treeshaking proves valuable for server-side applications for these key reasons:

  1. Smaller, Efficient Bundles: By removing unused code, treeshaking shrinks server bundles. This leads to:

    • Quicker Server Startup: Less code to process means the server gets up and running faster.
    • Reduced Memory Use: Smaller bundles demand less memory from the server, enhancing its efficiency.
  2. Cost-Effective Serverless: Serverless functions or Edge workers (e.g., AWS Lambda, Google Cloud Functions, CloudFlare Pages) are becoming increasingly popular. These functions are billed based on execution time and memory consumption. By minimizing code size through treeshaking, you can directly reduce the costs associated with serverless deployments.

Hence, while the impact of smaller bundles might not be as noticeable in server-side applications as in client-side scenarios, the benefits are still tangible. They include faster startup times, reduced resource consumption and cost savings in serverless environments.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
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

3 participants