socket.io-client icon indicating copy to clipboard operation
socket.io-client copied to clipboard

Failing to load the file in IE

Open shyam1992 opened this issue 7 years ago • 34 comments

t.log = function(...e) { return "object" == typeof console && console.log && console.log(...e) } this code fails to execute in IE11. Expected Identifier error.

shyam1992 avatar Sep 25 '19 13:09 shyam1992

Same here on v2.3.0 and IE 11

jmaslin avatar Sep 25 '19 18:09 jmaslin

Same here on v2.3.0 and IE 11

We reverted back to 2.2.0 and it is woking fine.

shyam1992 avatar Sep 26 '19 06:09 shyam1992

I also reverted to 2.2.0 and it works fine. Seems like the code exported by the module is not valid ES5.

fmoessle avatar Sep 26 '19 09:09 fmoessle

Well, it shoud have been transpiled by babel... I'll take a look at this.

Le jeu. 26 sept. 2019 à 11:09, orangejuice [email protected] a écrit :

I also reverted to 2.2.0 and it works fine.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/socketio/socket.io-client/issues/1328?email_source=notifications&email_token=ADDNSFI5LWY4MJXY24WZNNLQLR333A5CNFSM4I2MYYBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7U4IVQ#issuecomment-535413846, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDNSFNC7OUW4Z3BEWLSNRLQLR333ANCNFSM4I2MYYBA .

darrachequesne avatar Sep 27 '19 07:09 darrachequesne

This happened after updating debug from v3 to v4 which uses spread operator in its distributable. Very often node_modules are excluded from babel compilation for performance reasons.

rafalmaciejewski avatar Sep 30 '19 11:09 rafalmaciejewski

Got this in IE11 as well.

"SyntaxError: Syntax error
   at ../node_modules/socket.io-client/node_modules/debug/src/browser.js (http://192.168.86.48:3000/static/vendors~vehicle-Vehicle.jsx.eb6d2ebd6bfc7172757c.js:510:1)
   at __webpack_require__ (http://192.168.86.48:3000/static/client.js?1571655164758:107:12)
   at eval code (eval code:7:1)
   at ../node_modules/socket.io-client/lib/url.js (http://192.168.86.48:3000/static/vendors~vehicle-Vehicle.jsx.eb6d2ebd6bfc7172757c.js:488:1)
   at __webpack_require__ (http://192.168.86.48:3000/static/client.js?1571655164758:107:12)
   at eval code (eval code:6:1)
   at ../node_modules/socket.io-client/lib/index.js (http://192.168.86.48:3000/static/vendors~vehicle-Vehicle.jsx.eb6d2ebd6bfc7172757c.js:444:1)
   at __webpack_require__ (http://192.168.86.48:3000/static/client.js?1571655164758:107:12)
   at eval code (eval code:55:22)
   at ./shared/components/catalogue/ValuationCatalogue.jsx (http://192.168.86.48:3000/static/vehicle-Vehicle.jsx.b7e97db41986fa53caa6.js:344:1)"

Affected lines

/**
 * Invokes `console.log()` when available.
 * No-op when `console.log` is not a "function".
 *
 * @api public
 */
function log(...args) {
	// This hackery is required for IE8/9, where
	// the `console.log` function doesn't have 'apply'
	return typeof console === 'object' &&
		console.log &&
		console.log(...args);
}

Don't really have much to add as it's been identified as non transpiled code.

dalyr95 avatar Oct 21 '19 11:10 dalyr95

Same here on v2.3.0 and IE 11

and iOS9 Safari

shusiwei avatar Oct 23 '19 05:10 shusiwei

This is a breaking change on a point release that we got automatically upgraded too. For those who still support IE11 this is quite serious, took us a few days to realise.

dalyr95 avatar Oct 23 '19 20:10 dalyr95

How long do you expect to take them to fix the issue?

christosv94 avatar Oct 28 '19 11:10 christosv94

this issue is related to debug:4.1.0 They have already replaced the method but sill no new build where this issue is fixed.

fix for socket.io-client and engine.io-client would be to replace the current version debug with version 4.0.1.

ErfanNaz avatar Jan 29 '20 15:01 ErfanNaz

Unfortunately, it seems like the maintainer of debug is not willing to hear our problem at all: https://github.com/visionmedia/debug/issues/668#issuecomment-576262641

stnwk avatar Feb 06 '20 15:02 stnwk

Hi @darrachequesne :)

Can you please pin the debug package for socket.io-client to 4.0.1? Thank you!

stnwk avatar Feb 06 '20 15:02 stnwk

In the mean time I tried to approach the maintainer of debug and asked him to please re-consider his choice not to transpile the package to ES5 code anymore: https://github.com/visionmedia/debug/issues/745

stnwk avatar Feb 06 '20 15:02 stnwk

I've heard the problem a thousand times. I've heard it since the problem was first created. Please transpile your application if you want it to work on archaic browsers; debug is just the first of many dependencies you'll run into that are written and published as ES6 modules.

Very often node_modules are excluded from babel compilation for performance reasons.

This doesn't mean package maintainers should keep their code pinned to the stone ages. The javascript ecosystem is slow, yes, but it's even slower when e.g. IE11 keeps us held back. The reason why debug is picked on a lot is because it's one of the top 10 most depended upon packages and thus is usually one of the first packages to encounter errors or issues, even though 100's of other dependencies will slow you down, too.

If you don't believe me, manually transpile debug in your node_modules and try to bundle your app again. Most likely, depending on the size of your application, the bundling process will fail elsewhere.

If you have a problem with Babel's efficiency, open an issue at Babel. If you have a problem with CRA not performing proper transpilation, open an issue with CRA.

I don't want to come off as dismissive; this just isn't debug's problem.

Qix- avatar Feb 06 '20 16:02 Qix-

From what they say in this link here. It seems to be a babel configuration problem, maybe if the staff changes the configuration inside the socket-io-client it can solve the problem.

jsilveira2 avatar Feb 07 '20 11:02 jsilveira2

Correct; that is the official response from the Babel team. Please take your issues there.

Qix- avatar Feb 07 '20 14:02 Qix-

What official response? Linked issue was about babel not transpiling selected packages from node_modules when configured to, and it's fixed.

Socket.io-client doesn't even use babel for transpiling. It only uses webpack to bundle all dependencies into a single distributable.

So now, if socket.io-client is to be supported in older browsers it needs either a transpilation step while building or it needs to downgrade or replace debug.

Publishing packages for web that need transpilation is actually not that common. Over the years of transpiling i encountered it only a few times even on projects with literally GBs of dependencies in node_modules. Until now every maintainer was nice enough to treat it as a bug...

rafalmaciejewski avatar Feb 07 '20 15:02 rafalmaciejewski

This is the response I was referring to:

I agree that this is not a debug bug, but a problem with how Babel has been configured.

If you configure Babel to transpile node modules but it still isn't working, please provide a minimal repository I can clone to investigate.


So now, if socket.io-client is to be supported in older browsers it needs . . . a transpilation step

Correct. That is the state of modern web development.

with literally GBs of dependencies in node_modules

This is the real problem. Not debug choosing not to transpile. By using ES6 modules, this is generally not an issue because your application will only bundle the dependencies it uses, and thus will only transpile the dependencies it uses. People do this to great effect every day.

Until now every maintainer was nice enough to treat it as a bug...

Using perfectly valid versions of Javascript is not a bug.

Qix- avatar Feb 07 '20 15:02 Qix-

Saying transpile node_modules instead of publishing a package that supports as many active environments as possible is such a middle finger to anyone running a business. I need to carefully select each package to transpile since transpiling everything from node_modules more than quadruples build time of some projects - sometimes from several minutes to an hour. Nobody has time for that. Today more people are still using IE11 than Firefox. IE11 is still supported by Microsoft. I don't think that forcing personal beliefs about JS community not moving fast enough is really doing any good.

rafalmaciejewski avatar Feb 07 '20 15:02 rafalmaciejewski

Saying transpile node_modules instead of publishing a package that supports as many active environments as possible is such a middle finger to anyone running a business.

That's not really a constructive attitude, and not the kind of discourse I'd like to have in open source, personally.

I think I've said my piece here. Sorry my decision to improve the maintainability of a module downloaded nearly 60 million times a week doesn't fit your business model.

Qix- avatar Feb 07 '20 16:02 Qix-