You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been getting very close to migrating a feathers4 client to vite. My last hurdle is socket.io-client a CommonJS module that expects to be built with Webpack 4, as it uses Node.js only APIs and hard coded Webpack specific polyfills.
The first error you'll get is TypeError: url.parse is not a function, which can be addressed by installing the url npm package manually.
The second I get is something that transpiles to this line, from engine.io-client's xmlhttprequest-ssl
"TypeError: doRequest is not a function
at XMLHttpRequest.send (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:2473:21)
at Request.create (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4200:13)
at new Request (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4122:12)
at XHR.request (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4077:14)
at XHR.doPoll (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4091:22)
at XHR.Polling.poll (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:3940:12)
at XHR.Polling.doOpen (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:3905:12)
at XHR.Transport.open (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:3381:14)
at Socket.open (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4827:17)
at new Socket (https://30n1s.sse.codesandbox.io/node_modules/.vite/socket_io-client.js?v=7119379e:4747:12)"
Expected behavior
socket.io should connect.
Actual behavior
socket.io is full of Node.js dependencies that are hard to shim on Webpack 5 backed browser bundlers like Vite.
This is a known common issue with a lot of socket.io-client versions, luckily there is a good workaround, manually resolving the problematic xmlhttprequest-ssl module to the one provided by engine.io-client/lib/xmlhttprequest-ssl.js
Steps to reproduce
I've been getting very close to migrating a feathers4 client to vite. My last hurdle is socket.io-client a CommonJS module that expects to be built with Webpack 4, as it uses Node.js only APIs and hard coded Webpack specific polyfills.
The first error you'll get is
TypeError: url.parse is not a function
, which can be addressed by installing theurl
npm package manually.The second I get is something that transpiles to this line, from engine.io-client's xmlhttprequest-ssl
Expected behavior
socket.io should connect.
Actual behavior
socket.io is full of Node.js dependencies that are hard to shim on Webpack 5 backed browser bundlers like Vite.
System configuration
Module versions: Feathers 4
NodeJS version: 16
Module Loader: Vite 2
I'll work on this next week and hopefully file the solution / workaround.
The text was updated successfully, but these errors were encountered: