-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Vue 3 support (prev. 'Error in initialisation with Vue3 createApp') #489
Comments
Hi @jessepcc and thanks for your issue. |
Hi, when can we expect support for Vue 3? I'm starting a new project and wanted to do it with the newest version of vue. Is there any option to release it at least in beta version? |
Is this the issue to track the migration to Vue3? |
@probil do you think it's still achievable in 2020? I'm also starting a new project on Vue3 and thinking whether to go with the library or go with pure socket.io... |
@matrunchyk The migration is not hard, I'm just struggle to find enough time to deal with it. BTW in 2020 you don't have to use socket.io anymore since plain websockets are well supported in browsers. https://caniuse.com/websockets I'll try to migrate it to Vue 3 later this year but can't guarantee you anything. |
@probil I know about native websockets, but socket.io is still preferable for me as it has a good abstraction layer and fallback support of long polling. Thanks for the answer anyways! |
I've made a pull request containing a (definitely not production ready) migration to vue 3. #499 |
I gave this a try too. #507 My version maybe still need some work but it's working for me at the moment. |
Thanks guys will try to tackle this during the holiday |
I created a PR #507 for the migration to Vue 3 but am stuck at changing the documentation for usage with Nuxt.js and Quasar Framework. If anybody knows what needs to be changed there, please provide me the changes so we all can get vue3 support :) |
I've just published alpha version of the library with Vue 3 support in @jnt0r could you check how it work for you? Unfortunately my project at work doesn't use socket.io at all For some reason library has grown considerably after migration:
In original MR it was even larger, 25kb due to part of the vue compiled into the library. So I made it external but there is something more. I suspect BTW Nuxt.js and Quasar are not supporting vue 3 just yet so we shouldn't worry about them |
@probil Nice 👍🏽 I don't know why it's getting that big ... I haven't read into how you build the plugin. Maybe I catch something up than I will let you know. |
@probil A quick investigation into |
Thanks for investigation @jnt0r <!-- App.vue -->
<script>
import { Options, Vue } from 'vue-class-component';
import Socket from 'vue-socket.io-extended/decorator'
@Options({})
export default class App extends Vue {
@Socket() // --> listens to the event by method name, e.g. `connect`
connect () {
console.log('connection established');
}
@Socket('tweet') // --> listens to the event with given name, e.g. `tweet`
onTweet (tweetInfo) {
// do something with `tweetInfo`
}
}
</script> But it would require to change the build process a bit 🤔 |
It turned out the build process doesn't have to.be changed that much. Using of It would also allow to remove an indecent solution (with 2 entrypoints) introduced in the v4. |
Just published a new version with the decorator exported in a separate entry point. Library size went back to 6k (minified) Installation is still with Need to hear some feedback to make sure it works for both common usage and decorator usage. Some set of tests would probably be better but it would take more time. |
Just tried this using Vue3 + Ts + CompositionApi and everything seems to be working! ❤️ |
I'll update my project either later today or this week aswell to test this👍 |
I do not have the The issue I have now is @Socket() // --> listens to the event by method name, e.g. `connect`
connect(): void {
console.log('connection established', this);
} In the terminal I have the following error too |
@DblK There are some breaking changes in Try to import decorator from a different path please: - import { Socket } from 'vue-socket.io-extended'
+ import Socket from 'vue-socket.io-extended/decorator' Also, make sure you are using socket.io-client and socket.io v2 as v3 is not yet supported |
With this import I have got the following error: |
@DblK No. I haven't tested importing this new path in TS. Will take a look. Thanks for reporting |
Just started using this. Typescript seems to think that the |
@MrBrax I'm not really good at TS so if you could provide the MR (to |
MR? I actually don't know how to fix it myself, I've never written type/definition files :( |
Ah, ok. Maybe someone else can help here. |
It probably stems from this: https://github.com/probil/vue-socket.io-extended/blob/alpha/types/vue.d.ts#L9 Seems to be changed from the stable version. |
This seems to have fixed it on the editor side, but i can't really test it out in my docker container. No idea if it breaks anything either. edit: yep that fixed it |
@probil I just investigated #528 and came to this issue where you stated the breaking change for the import of the Socket Decorator. I tried it out and it didn't work as it said |
@probil can you explain why the project is built into several files with .esm, .min and not into a single index.js file. And also why you extracted the decorator into a separate file. |
Mostly for compatibility purpose. ESM is not fully supported by all the browsers but it's prefered format for modern bundlers (Webpack, Rollup, etc) especially for tree-sharking. As far as I know the format is not supposed to impact type definition, so don't worry about this.
Because having everything in one file make is harder to work with. Take a look at the issue here #464 . The point is that the extra dependency of import Socket from 'vue-socket.io-extended/decorator' while having core available to without decorator (so it's not imported to the codebase by default) |
The problem with decorator might be that we need to make sure TS can follow redirects specified in I'm also pondering the idea of full TS rewrite in order to prevent issue with TS declarations |
Okay, I understand that. Had some hard time figuring out this types thing with the submodules. But got it working => PR is opened. So no need to use Babel or anything else for that. Hopefully, I can assist at full TS rewrite :) Just ping me if you decided to start. |
@jnt0r Merged you PR. Thanks! 💪 Could you also rebase your PR regarding |
@probil I will take a look at it. But first, need to understand what it should do... to be able to test it out :) |
I've spend some time today to create an example of Usage of decorator syntax is coming soon, should help to fix potential issues, e.g. #528 |
Hello, I hope you're doing well please I have a problem in my project when I try to send an event to execute an action in my store, the action not executed I don't know where is the problem
this is my action that sends an event to execute another action
and the rest is the file who contains our action chat_message
and thank you so much |
There is an issue with the dependency - @types/socket.io-client. It has been deprecated in favor of built-in typing inside |
hi @probil I'm trying to get vue-socket.io-extended to get to work with typescript and the following packages.
main.ts
which gives me this error:
I've also tried to add this linem as suggested in the earlier posts
but then I am getting this error: Any ideas? |
Initialization with instructions of doc from Vue3 as follow
Getting errors in runtime
Uncaught TypeError: e is not a constructor
After some research, seems the problem is from the breaking change from Vue2 to Vue3, with the createApp api
https://nystudio107.com/blog/a-taste-of-vue-js-3-async-components-and-plugins/amp
https://alvarosaburido.dev/blog/how-to-migrate-your-library-from-vue2-to-vue3
Is there any timeline to cope with Vue3 updates?
The text was updated successfully, but these errors were encountered: