Question: How to load Socket.io-client and other libraries that only support require?
See original GitHub issueSorry in advance for opening this as an issue but trying to get my head around all the new changes that are happening within vue 3 and their libraries within vite.
For 2-3 days now I’ve been struggling to import a ‘smarter’ library (like socket.io-client) than a simple ws wrapper or native web-sockets and whatever I try throw errors of ‘default’ is not been exported by these libraries. I realised that any library without support of ES6 import is not supported. Also tried vue & vue-next implementations of web-socket libraries but without any luck.
Can someone please explain with a few words how and if possible to overpass this problem within vite?
I have a simple vite codesandbox; if you can use it please to explain:
https://codesandbox.io/s/vite-tailwind-starter-04mrv?file=/src/main.js
Many Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
I fixed it with:
in
vite.config.js
Still not ideal, but better than having to import from a different path in code.
import socket from "socket.io-client/dist/socket.io.js";
worked for me. Sadly this breaks IntelliSense.