sweetalert2 / ngx-sweetalert2

Declarative, reactive, and template-driven SweetAlert2 integration for Angular
MIT License
652 stars 94 forks source link

CommonJS or AMD dependencies can cause optimization bailouts. #230

Closed manishaquil closed 1 year ago

manishaquil commented 1 year ago

When added in package json and build processing showing this message.

/node_modules/@sweetalert2/ngx-sweetalert2/fesm2020/sweetalert2-ngx-sweetalert2.mjs depends on 'sweetalert2'. CommonJS or AMD dependencies can cause optimization bailouts.

limonte commented 1 year ago

duplicate of https://github.com/sweetalert2/sweetalert2/issues/2467

toverux commented 1 year ago

And you can use provideSwal to change the import (as shown by @limonte):

SweetAlert2Module.forRoot({ provideSwal: import('sweetalert2/src/sweetalert2.js') })

Then you'll have to import the SweetAlert SCSS or CSS separately, in your styles.[s]css or angular.json, example with themes here: https://github.com/sweetalert2/ngx-sweetalert2/wiki/Use-a-theme-from-@sweetalert2-themes-(and-or-customize-SCSS-variables)#using-a-theme-from-sweetalert2sweetalert2-themes.

iGanja commented 1 year ago

Just thought I'd point out, - from another thread where this is mentioned - the error message also provides a link "For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies" which pretty much explains how to silence this warning. There is no way to eliminate the risk, which is not significant, IMHO. The issue that CommonJS can increase your bundle size is certainly true, but if you are happy with the size of your package, yada yada, pun intended.