therufa / mdi-vue

Material design icons for vue.js
https://www.npmjs.com/package/mdi-vue
MIT License
88 stars 13 forks source link

Vue named property import on Vue3 generates a compilation warning #50

Closed philippedasilva-orizone closed 3 years ago

philippedasilva-orizone commented 3 years ago

Environment used:

As per v2.2.1, we can note after a fresh install the following compilation warning on a fresh new install:

WAIT  Compiling...                                               13:14:12

98% after emitting CopyPlugin

WARNING  Compiled with 1 warning                                 13:14:13

warning  in ./node_modules/mdi-vue/main.js

"export 'default' (imported as 'Vue') was not found in 'vue'

App running at:
- Local:   http://localhost:8080/ 
- Network: http://192.168.1.93:8080/

This is pointing specifically to the main.js file where we can see the current implementation to support both Vue 2.x and Vue 3.x using the same package.

Any idea how to prevent that? I'm more than happy to help fixing that but I have no experience dealing with conditional compilation using javascript.

therufa commented 3 years ago

hi @philippedasilva-orizone, thanks for choosing the library and taking time to report this issue. 🙏

I proposed a potential fix for the problem you've described. I had to change the import of vue 3's render function, I want to test it before I make a new release though.

In the meantime if you want to make the warning disappear, you could just replace the main.js in your local node_modules/mdi-vue folder with the one in the current master branch of this project.

In fact, what you can do until the release isn't out, you could just paste the git repository's uri in the packages.json of your project. That way you can test the latest changes. If it works for you, please let me know.

I'll get back to you once it's tested and ready to go. 😉

philippedasilva-orizone commented 3 years ago

Hi @therufa,

Thanks for the quick reply. I just did what you suggested and both options (simple replacement of the main.jsfile or the entire master branch received the same result on my end:

Uncaught ReferenceError: Vue is not defined
     at eval (main.js?3048:7)
     [...]

I'm falling back to the v2.2.1 release for the time being but I'd be more than happy to help. I believe it is just a matter of safely testing whether Vue is actually defined or not... Or even better, checking at runtime if we are using a version of Vue >= than 3.x

The only way I came up with (which sounds like a hack is using the package.json approach... I'll submit a quick PR for you to check ;)

philippedasilva-orizone commented 3 years ago

I made a quick pull request with an approach that prooved to work on my system using either vue js 2 or 3. Let me know if the approach (a little bit "hacky") satisfies your guidelines as I didn't find any on the repository ;)

therufa commented 3 years ago

Since the warning seems to be gone in the latest release, I'm closing this issue. Please reopen in case I missed something.