ng2-dragula icon indicating copy to clipboard operation
ng2-dragula copied to clipboard

Angular 10 build warning

Open spock123 opened this issue 5 years ago • 19 comments

After upgrading to Angular 10 we get these warnings when doing builds:

WARNING in /Users/lrj/project/mother-qorder/admin/node_modules/ng2-dragula/__ivy_ngcc__/dist/fesm2015/ng2-dragula.js depends on dragula. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

spock123 avatar Jun 28 '20 12:06 spock123

there are more warnings:

WARNING in .../node_modules/ng2-dragula/__ivy_ngcc__/dist/fesm2015/ng2-dragula.js depends on dragula. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in.../node_modules/dragula/dragula.js depends on contra/emitter. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in .../node_modules/dragula/dragula.js depends on crossvent. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

smlombardi avatar Jun 29 '20 16:06 smlombardi

This is because as of Angular 10.0, Angular will output a warning for all CommonJS dependencies, as they impact the tree-shaking of applications (this link explains it: https://web.dev/commonjs-larger-bundles/).

To fix this warning all packages referenced in the warnings (dragula, contra/emitter and crossvent) need to be released as es2015 modules.

codekrafter avatar Jun 30 '20 02:06 codekrafter

With regards to Angular 10 compatibility there is also this error which can prevent builds from passing:

node_modules/ng2-dragula/dist/components/dragula.module.d.ts:3:23 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).

3     static forRoot(): ModuleWithProviders;

jziggas avatar Jul 01 '20 17:07 jziggas

this could be fixed by changing it to static forRoot(): ModuleWithProviders<any>;

centigradeclemensP avatar Jul 09 '20 17:07 centigradeclemensP

Just a hotfix, until we don't get an update on this.

You can add the flag "skipLibCheck": true to your tsconfig.app.json, under compilerOptions.

prsevero avatar Jul 22 '20 14:07 prsevero

Ditched it and moved to Angular Material's drag and drop. Much simpler to use.

smlombardi avatar Jul 23 '20 22:07 smlombardi

Angular Material CDK doesn't support drag and drop in a grid with wrapping, if you need that, ng2-dragula is still a valid choice. https://github.com/angular/components/issues/13372

2ndClemens avatar Jul 24 '20 16:07 2ndClemens

Will this be done in the next version?

Gillardo avatar Aug 11 '20 12:08 Gillardo

Month later and no reply?? Is this being done or has this package been abandoned?

Gillardo avatar Sep 10 '20 08:09 Gillardo

Fixed in 1008, awaiting version bump and release.

Edit: Shoutout to @centigradeclemensP for providing the fix.

jziggas avatar Sep 14 '20 15:09 jziggas

I think the version of Angular in the demo folder needs to be updated in order for the build to pass.

jziggas avatar Sep 15 '20 18:09 jziggas

I tried to upgrade the demo's package.json but a slew of errors from ng-packagr occurred and I gave up. As well as what I think are red herrings like linting and unit test errors because it doesn't seem like those were kept up to date for the demo. I don't think I'm familiar enough with yarn and ng-packagr to fix the rest.

jziggas avatar Sep 16 '20 13:09 jziggas

Hi everyone! Сould you please tell when we can expect a new release version with a fix for this issue?

Peter-Zakharevich avatar Sep 24 '20 12:09 Peter-Zakharevich

Sad to say that - I replaced ng2-dragula with ngx-bootstrap because of this warning.

nealpatil01 avatar Sep 29 '20 04:09 nealpatil01

Hello Maintainer,

Is the fix released ?

sampath13 avatar Aug 10 '21 12:08 sampath13

Hello.

Is there any date set for a new npm package for newer Angular Versions? Thanks for the great work anyway. :)

Best regards.

ulrichmueller avatar Feb 23 '22 14:02 ulrichmueller

Seconding ulrichmueller's request. @jziggas

Xaivteev avatar Mar 30 '22 16:03 Xaivteev

I want this too

m-wheeler avatar May 13 '22 23:05 m-wheeler

@cormacrelf, @valorkin, @jziggas - Just curious if this will ever get published to NPM?

rg1220 avatar Sep 07 '22 15:09 rg1220