ngx-charts icon indicating copy to clipboard operation
ngx-charts copied to clipboard

19.1 triggers angular import warning: swimlane-ngx-charts.js depends on 'clone-deep'. CommonJS or AMD dependencies can cause optimization bailouts.

Open bbarry opened this issue 3 years ago • 23 comments

Describe the bug

Warning: C:\temp\updatecheck\node_modules\@swimlane\ngx-charts\__ivy_ngcc__\fesm2015\swimlane-ngx-charts.js depends on 'clone-deep'. CommonJS or AMD dependencies can cause optimization bailouts.

in a new angular cli app using ngx-charts 19.1.0

For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies To Reproduce Steps to reproduce the behavior:

  1. ng new a temp app
  2. script (note: npm installs other than ngx-charts here are undocumented dependencies necessary to fix build errors):
    cd updatecheck
    npm i @angular/cdk --save
    npm i @swimlanes/ngx-charts --save
    npm i @types/d3 --save-dev
    
  3. add NgxChartsModule to AppModule
  4. put <ngx-charts-legend></ngx-charts-legend> in app.component.html
  5. run ng serve

Expected behavior

app builds without warnings

ngx-charts version

19.1.0

Additional context Add any other context about the problem here.

bbarry avatar Oct 12 '21 20:10 bbarry

The clone-deep package is only used in one spot where is it completely unnecessary. It looks like clone-deep was not even added as a dependency. It is in node_modules only because of:

Hoisted from "@angular-devkit#build-angular#webpack-merge#clone-deep"

The warning should not be ignored, the usage should be removed.

maknapp avatar Jan 28 '22 15:01 maknapp

The warning should not be ignored, the usage should be removed.

I completely agree, suppressing warnings is not a solution.

thomasturrell avatar Feb 15 '22 11:02 thomasturrell

Agreed - usage should be removed if at all possible

jpduckwo avatar Feb 20 '22 22:02 jpduckwo

This should be fixed by now. This package has been built with angular in mind, but doesn't respect angular requirement. Using CommonJS or AMD dependencies will result in optimization bailouts which cause the application to be slower. This should be a priority fix.

Leccho avatar Apr 11 '22 19:04 Leccho

This should be a priority fix. This was built for Angular, and this issue was opened 7 months ago.

brantunger avatar Apr 18 '22 00:04 brantunger

I proposed a fix by writing a custom function to clone the data, #1763. or you can use the lodash-es version in #1750

Either way, I don't care how we fix it, this should be resolved by now. Can the maintainers choose a fix and just go with it? cloneDeep is only used in a single place, and even there the usage isn't really about cloning something. Seems like people just want immutable data, and are going about it in the easiest way at the time.

bryanrideshark avatar Jun 28 '22 15:06 bryanrideshark

Please can the maintainers provide some feedback on this? Like @bryanrideshark, I agree that either proposed solution would be fine, although I feel like @bryanrideshark solution is cleaner, as long as we can resolve this 👏

dasco144 avatar Jul 06 '22 08:07 dasco144

@marjan-georgiev any chance you could look at this? Do you need help maintaining?

jpduckwo avatar Jul 06 '22 08:07 jpduckwo

There's a new pull request that fixes this issue #1763 It corrects the underlying issue, and passes the build tests.

David-Mawer avatar Jul 22 '22 06:07 David-Mawer

I now get a warning for rfdc: @swimlane/ngx-charts/fesm2020/swimlane-ngx-charts.mjs depends on 'rfdc'. CommonJS or AMD dependencies can cause optimization bailouts.

ChrTall avatar Dec 29 '22 23:12 ChrTall

Facing similar issue in our project

image

sushmeex avatar Apr 07 '23 06:04 sushmeex

With the following versions on Angular 13.0.0:

"@swimlane/dragula": "^3.8.0",
"@swimlane/ngx-dnd": "^9.0.0",
"@types/dragula": "^3.7.1",

I am seeing the following warning:

\node_modules\@swimlane\ngx-dnd\__ivy_ngcc__\fesm2015\swimlane-ngx-dnd.js depends on '@swimlane/dragula'. CommonJS or AMD dependencies can cause optimization bailouts.

ac-ih avatar Apr 14 '23 15:04 ac-ih

I do also get the warning on rfdc now. Is there any fix for this yet?

StevenGee3398 avatar May 01 '23 05:05 StevenGee3398

I updated to Angular 16 and still get @swimlane\ngx-charts\fesm2020\swimlane-ngx-charts.mjs depends on 'rfdc'. CommonJS or AMD dependencies can cause optimization bailouts, warning.

cristopher55 avatar Jun 05 '23 06:06 cristopher55

Same here as @cristopher55, I'm having this warning. Is there anyone working on a fix for this?

FredyValstrauss avatar Jul 19 '23 17:07 FredyValstrauss

I updated to Angular 16 and still get @swimlane\ngx-charts\fesm2020\swimlane-ngx-charts.mjs depends on 'rfdc'. CommonJS or AMD dependencies can cause optimization bailouts, warning.

Hi @StevenGee3398 can you evaluate and test this workaround :

"build": { "builder": "@angular-devkit/build-angular:browser", "options": { "allowedCommonJsDependencies": ["rfdc"],

hdkcreative avatar Jul 27 '23 20:07 hdkcreative

@hdkcreative This is not a work around, it's just hiding the problem from the console so you forget all about it. I'd leave the message and wait for a fix

Leccho avatar Aug 09 '23 15:08 Leccho

@hdkcreative This is not a work around, it's just hiding the problem from the console so you forget all about it. I'd leave the message and wait for a fix

we decided to stop using that library!

hdkcreative avatar Aug 09 '23 20:08 hdkcreative

@hdkcreative This is not a work around, it's just hiding the problem from the console so you forget all about it. I'd leave the message and wait for a fix

we decided to stop using that library!

What did you use as replacement?

Leccho avatar Aug 10 '23 13:08 Leccho

@hdkcreative This is not a work around, it's just hiding the problem from the console so you forget all about it. I'd leave the message and wait for a fix

we decided to stop using that library!

What did you use as replacement?

hi, sorry for answering so late . . .

we are using https://primeng.org/ and https://developers.google.com/chart?hl=es-419

hdkcreative avatar Aug 22 '23 15:08 hdkcreative

Add clone-deep to angular.json in allowedCommonJsDependencies

image

matudelatower avatar Sep 01 '23 16:09 matudelatower

I think this issue should be locked. I don't think there is much else to add.

If anyone is looking to hide the message they can simply look back through the previous comments.

Anyone waiting for a fix can simply subscribe to this issue and wait for the status to change.

thomasturrell avatar Sep 01 '23 16:09 thomasturrell

Ok, I believe I found a solution to my issue. My warning says swimlane-ngx-charts.mjs depends on 'rfdc'. rfdc only contains 2 functions; rfdc (opts) and rfdcCircles (opts). So, what I did is, I copied both functions into swimlane-ngx-charts.mjs and removed the line that imports that reference (import rfdc from 'rfdc';). This fixed the issue for me, as I'm not allowing CommonJS dependencies and the warning is gone. P.S. I only made that change on the fesm2015. The file in fesm2020 did not thrown any warning for me.

FredyValstrauss avatar Sep 12 '23 16:09 FredyValstrauss