I'm currently working on a project in polymer 3, one of the components needs to import socket.io-client but whatever i try i can't get it to work.
I have tried:
import io from 'socket.io-client';
what i get back:
Uncaught SyntaxError: The requested module '../../node_modules/socket.io-client/lib/index.js' does not provide an export named 'default'
same for this:
import io from 'socket.io-client/dist/socket.io.js';
what i get back:
Uncaught SyntaxError: The requested module '../../node_modules/socket.io-client/dist/socket.io.js' does not provide an export named 'default'
I have also tried this:
import * as io from 'socket.io-client'
what i get back:
ReferenceError: require is not defined at index.js:4
and this:
import * as io from 'socket.io-client/dist/socket.io.js'
what i get back:
TypeError: Cannot read property 'Buffer' of undefined
I later on looked trough the code from socket.io-client and there really don't appear to be any es6 exports used in the code, that would explain why it indeed doesn't work.
What i find weird tho is that the import syntax is even listed on their site as supported. I assume i may be using a wrong build or something but i don't know why that would be true as i use "socket.io-client": "^2.1.1" if anyone knows what i'm doing wrong i'd be happy to hear.