-
Notifications
You must be signed in to change notification settings - Fork 3k
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
inconsistent typing and actual export structure would cause runtime error using with webpack and typescript [v3.0.0] #1396
Comments
My problem is probably caused by this so I'll just comment here instead of opening another ticket: import SocketIO from 'socket.io-client';
let socket = SocketIO.connect('some URL string', { transports: ['websocket'] }); Now I can't. v3.0.1 exposes only 4 properties: protocol, Manager, io, Socket. No methods or subproperties in any of them. Am I missing something? Did the usage pattern change, but it's missing from the changelog? Edit: Looking at the SocketIO docs I found that the SocketIO export should have a constructor that behaves like the previous connect method, but this is entirely missing from the typings. |
@Tallyrald you should be able to use: import { io } from 'socket.io-client';
let socket = io('some URL string', { transports: ['websocket'] }); I think we should have removed the @noe132 I could indeed reproduce the issue, as CommonJS and ES module definitions are out of sync. |
Oh, you're completely correct, it seems my train of thoughts derailed somewhere between the version upgrade and the seemingly missing exports. Everything is fine, thank you! |
Having the same issue. Was starting a new project using socket.io and socket.io-client. Set Up
IssueWebpack is complaining and saying Work AroundDowngrading to V2.3.1 allowed webpack to bundle everything together and run without issue |
The TypeScript (build/index.d.ts) and ES modules exports did not match, which caused issues with webpack and ts-loader. Related: #1396
The TypeScript (build/index.d.ts) and ES modules exports did not match, which caused issues with webpack and ts-loader. Related: #1396
I'm now getting this error when doing
|
This should be fixed in Closed by bec1524. |
The TypeScript (build/index.d.ts) and ES modules exports did not match, which caused issues with webpack and ts-loader. Related: socketio/socket.io-client#1396
You want to:
Current behaviour
When using with webpack and typescript,
is valid for typescript, but would result an error in runtime.
because when typescript looks for typing, it gets
build/index.d.ts
,and webpack try resolve path for the package, and it looks
package.json
, and found there is field["exports"]["."]["import"]
and use its value./wrapper.mjs
, but has an different export structure than the typing above.Steps to reproduce (if the current behaviour is a bug)
Setup a minimal webpack ts-loader build, and using
io
would get this error messageExpected behaviour
warpper.mjs should have same export structure as build/index.js
Setup
The text was updated successfully, but these errors were encountered: