-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unable use swal with src/sweetalert2.js for use in ES6 #1160
Comments
Thanks for the report @altbdoor! Confirming the issue, the temp solution could be import swal from 'sweetalert2/dist/sweetalert2.js'
// ^^^^ But we need to figure out what's happening here. @zenflow do you have any quick guess? I wonder how the same working in sweetalert2-parcel-demo. |
@limonte yeah, I am using the same temporary solution as well 😄 thanks! To test things out, I have forked the sweetalert2-parcel-demo repo, and did a fresh |
@zenflow I need your help on this issue. |
@zenflow did you maybe have a chance to take a look at this issue? |
@limonte no, i lost this issue, so thanks for the reminder.. i'm having a look now |
@altbdoor what is your use-case? why do you need to use the source instead of the compiled build? |
Hi @zenflow Nope, there was no particular use-case. I was only trying to import the |
In that case, we can consider this as a documentation issue which is fixed now both for https://sweetalert2.github.io/ and the README.md |
@limonte We could also remove the src folder from the published package.. what do you think? |
To quote the usage instructions:
However, after importing
sweetalert2/src/sweetalert2.js
, any calls toswal
throws up an error of:TypeError: class constructors must be invoked with |new|
.Class constructor SwalWithGlobalDefaults cannot be invoked without 'new'
As per required for a bug report:
a JS Bin in order for us to be able to reproduce the issue
I used CodeSandbox since it allows a
npm install
-like environment. https://codesandbox.io/s/n0mx3jn7nmexpected behavior of the plugin
A SweetAlert2 popup should appear.
actual behavior
An error occurs when attempting to call
swal
.The text was updated successfully, but these errors were encountered: