What is actually happening?
Following the official example of using:
import io from 'socket.io-client';
in a JS app results in a broken site in IE 11.
By broken I don't mean the socket-io functionality doesn't work, but that it breaks loading the whole web app's bundle, including error reporting etc. Because no one tests on IE 11 probably no one really noticed this bug.
Just add import io from 'socket.io-client'
in a web app and test in IE 11.
What is expected?
IE 11 should load the bundle
The reason this is happening is because the "main" value in package.json specifies the unbundled source code, not the bundled dist folder, thus the source code gets bundled. Probably some bundlers also process the imported modules, but my version of Webpack doesn't, it only processes user's source code.
The solution would be very simple, to specify one of the dist files as the "main" value.
As a workaround I am using this line, which works:
import io from 'socket.io-client/dist/socket.io.slim.js'
Have this same problem. The workaround works for me :+1:
Good!
Workaround works for me as well, thanks!
It works for me as well, Good Job. thanks @hyperknot!!
So that others know, here it is in console:
The debug
dependency was reverted to 3.1.0
, which does not need to be transpiled. Released in 2.3.1.
Please note that you can also use the webpack-remove-debug plugin, in order to remove any call to the debug dependency (until we find a proper way to provide a build with and without debug).
Most helpful comment
Workaround works for me as well, thanks!