Skip to content
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

v3.2.1 document is not defined #3

Closed
roschaefer opened this issue Aug 1, 2019 · 9 comments
Closed

v3.2.1 document is not defined #3

roschaefer opened this issue Aug 1, 2019 · 9 comments

Comments

@roschaefer
Copy link

Hey, thanks for this great package! It's great to use just the animated icons of Sweetalert.

Unfortunately, we see an issue when upgrading from v3.2.0 to v.3.2.1:

Screenshot - 2019-08-01T233727 905

We do SSR with Nuxtjs.

I quickly tried out the unpublished version v.4.0.0, built the package because there is no dist folder pushed to Github and it seems that might resolve the issue. At least I don't get the error above, only the icons itself are missing. I'm sure the error is on my side, maybe I don't understand how to properly build the package.

How about publishing v4.0.0 to npm and we give it another try?

To reproduce the error try out this PR: Human-Connection/Human-Connection#791

@JorgenVatle
Copy link
Owner

If you're on Nuxt, styles from 4.0 aren't properly injected into the server response. This might explain why you don't see the icons render properly.

You should be able to work around the issue by wrapping the icons around the <no-ssr> component.

Let me know if this helps! 👍

@JorgenVatle
Copy link
Owner

4.0 is now available as a pre-release:

npm i vue-sweetalert-icons@next

@roschaefer
Copy link
Author

@JorgenVatle thank you for your quick reply!

On v4.0.0-rc1 I see this:

 WARN  Compiled with 1 warnings


 WARN  in ./components/Registration/CreateUserAccount.vue?vue&type=script&lang=js&

"export 'SweetalertIcon' was not found in 'vue-sweetalert-icons'

The exact same error as if I would yarn run build the package manually.

On v3.2.1, when I wrap all occurences of <sweetalert-icon> like this:

          <no-ssr>
            <sweetalert-icon icon="info" />
          </no-ssr>

The error persists. 😿

@JorgenVatle
Copy link
Owner

Oof. Sorry about that!

I'll take a crack at it first thing in the morning. 😊

@JorgenVatle
Copy link
Owner

JorgenVatle commented Aug 6, 2019

4.0 should be live now. 🎉
See the example sub-repo for a working example using Nuxt.

@roschaefer Let me know if this update does the trick for you. 👍

roschaefer added a commit to Human-Connection/Human-Connection that referenced this issue Aug 6, 2019
Updating the package to `v4.0.0` still gives me this warning:
```
 WARN  Compiled with 1 warnings
 WARN  in ./components/PasswordReset/ChangePassword.vue?vue&type=script&lang=js&
"export 'SweetalertIcon' was not found in 'vue-sweetalert-icons'
```

According to this thread JorgenVatle/vue-sweetalert-icons#3
I copy+pasted the example configuration:
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/nuxt.config.js
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/plugins/vue-sweetalert-icons.js

And now the compile warnings are gone. I'm going to ask the maintainer if the
local import is not possible with `v4.0.0` anymore.
@roschaefer
Copy link
Author

@JorgenVatle from my commit message:

Install vue-sweetalert-icon globally

Updating the package to v4.0.0 still gives me this warning:

 WARN  Compiled with 1 warnings
 WARN  in ./components/PasswordReset/ChangePassword.vue?vue&type=script&lang=js&
"export 'SweetalertIcon' was not found in 'vue-sweetalert-icons'

According to this thread #3
I copy+pasted the example configuration:
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/nuxt.config.js
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/plugins/vue-sweetalert-icons.js

And now the compile warnings are gone. I'm going to ask the maintainer if the
local import is not possible with v4.0.0 anymore.

The local import option is gone now? 😿 Maybe update docs? I'm going to close this because I can happily update to v4.0.0.

Thank you @JorgenVatle you are super responsive.

@JorgenVatle
Copy link
Owner

JorgenVatle commented Aug 6, 2019

@roschaefer Oh, thanks for the notice. Completely forgot about that! 😅

You should still be able to import the SFC directly.
Just update your import path accordingly:

import VueSweetalertIcon from 'vue-sweetalert-icons/src/components/icon';

export default {
  components: { VueSweetalertIcon }
}

I'll have to verify this though. 👍

@roschaefer
Copy link
Author

roschaefer commented Aug 8, 2019

@JorgenVatle I double-checked and it works. However when I run the tests I get the following error:

  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /home/robert/Development/human-connection/Human-Connection/webapp/node_modules/vue-sweetalert-icons/src/components/icon.vue:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<template>
                                                                                             ^

    SyntaxError: Unexpected token <

      49 | <script>
      50 | import gql from 'graphql-tag'
    > 51 | import SweetalertIcon from 'vue-sweetalert-icons/src/components/icon.vue'

which is obvious because jest is not supposed to parse vue single file components. It was my main motivation to do the local imports in order to avoid extra effort setting up the tests.

@JorgenVatle would you mind to simply export the SweetalertIcon along with the default export?

EDIT: For context, here's a PR Human-Connection/Human-Connection#1217 (review)

@JorgenVatle
Copy link
Owner

JorgenVatle commented Aug 8, 2019

@roschaefer Oh, totally! Can't believe I missed that. 😂

Went ahead an pushed out a new update (v4.2.0) this should have your named export for SweetalertIcon, exporting just the Vue component from the package entry-point as documented in the readme. 👍

roschaefer added a commit to Human-Connection/Human-Connection that referenced this issue Aug 9, 2019
In version `v4.2.0` of `vue-sweetalert-icons` the local import is back, see:
JorgenVatle/vue-sweetalert-icons#3 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants