avil13 / vue-sweetalert2

A convenient wrapper for sweetalert2.
https://avil13.github.io/vue-sweetalert2/
656 stars 75 forks source link

vue-sweetalert2 in electron/vue app #72

Closed wattsie closed 5 years ago

wattsie commented 5 years ago

Hi All, Just started playing with vue-sweetalert2 and run into an issue.

Any suggestions would be much appreciated?

In my renderer main.js I do the import, yet I can't even try to use it, as it fails to import.

import VueSweetalert2 from 'vue-sweetalert2'

When running, I get the following:

Uncaught /my-project/node_modules/vue-sweetalert2/dist/index.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import Swal from 'sweetalert2';
                                                                                                                                                                  ^^^^
SyntaxError: Unexpected identifier
    at new Script (vm.js:83:7)
    at createScript (vm.js:265:10)
    at Object.runInThisContext (vm.js:313:10)
    at Module._compile (internal/modules/cjs/loader.js:712:26)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Module.require (internal/modules/cjs/loader.js:685:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at eval (webpack-internal:///vue-sweetalert2:1:18)

Here are the versions I am using for reference.

yarn list |egrep -i "alert|vue"
    ├─ sweetalert2@8.17.6
    ├─ vue-electron@1.0.6
    ├─ vue-sweetalert2@2.1.1
    │  └─ sweetalert2@8.x
    ├─ vue@2.6.10
    ├─ vuelidate@0.7.4
    ├─ vuex-electron@1.0.3
avil13 commented 5 years ago

Hi. How works other imports?

avil13 commented 5 years ago

Looks like you have trouble with babel

wattsie commented 5 years ago

Strange, if I just use 'sweetalert2' and not the 'vue-sweetalert2' module

yarn add sweetalert2

import Swal from 'sweetalert2'

Then as a method call the following all works.

    methods: {
      test () {
        Swal.fire('Hello world!')
      }
    },

Alerts work as expected...

Weird.

wattsie commented 5 years ago

Thanks anyway, got back to native sweetalert2. Cheers.

avil13 commented 5 years ago

@wattsie  sorry couldn't help