angular report server dependencies as not esm
robertIsaac opened this issue · 4 comments
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
- generate new angular project with SSR
ng add @angular/fire
and chooseAuthentication
- 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
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.
undici
is, in fact, a CJS module: https://unpkg.com/browse/undici@6.14.1/index.js. AFAICSundici
is not a Node builtin; it being the backing implementation for Node'sfetch
global doesn't necessarily mean that importingundici
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
Though mainly linked to enhancing front-end performance, ESM treeshaking proves valuable for server-side applications for these key reasons:
-
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.
-
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.
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.