Skip to content
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

Failing to load the file in IE #1328

Closed
shyam1992 opened this issue Sep 25, 2019 · 34 comments
Closed

Failing to load the file in IE #1328

shyam1992 opened this issue Sep 25, 2019 · 34 comments
Milestone

Comments

@shyam1992
Copy link

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

@jmaslin
Copy link

jmaslin commented Sep 25, 2019

Same here on v2.3.0 and IE 11

@shyam1992
Copy link
Author

Same here on v2.3.0 and IE 11

We reverted back to 2.2.0 and it is woking fine.

@fmoessle
Copy link

fmoessle commented Sep 26, 2019

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

@darrachequesne
Copy link
Member

darrachequesne commented Sep 27, 2019 via email

@rafalmaciejewski
Copy link

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.

@dalyr95
Copy link

dalyr95 commented Oct 21, 2019

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.

@shusiwei
Copy link

Same here on v2.3.0 and IE 11

and iOS9 Safari

@dalyr95
Copy link

dalyr95 commented Oct 23, 2019

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.

@christosv94
Copy link

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

@ErfanNaz
Copy link

ErfanNaz commented Jan 29, 2020

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.

@stnwk
Copy link

stnwk commented Feb 6, 2020

Unfortunately, it seems like the maintainer of debug is not willing to hear our problem at all: debug-js/debug#668 (comment)

@stnwk
Copy link

stnwk commented Feb 6, 2020

Hi @darrachequesne :)

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

@stnwk
Copy link

stnwk commented Feb 6, 2020

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: debug-js/debug#745

@Qix-
Copy link

Qix- commented Feb 6, 2020

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.

@jsilveira2
Copy link

jsilveira2 commented Feb 7, 2020

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.

@Qix-
Copy link

Qix- commented Feb 7, 2020

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

@rafalmaciejewski
Copy link

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...

@Qix-
Copy link

Qix- commented Feb 7, 2020

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.

@rafalmaciejewski
Copy link

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.

@Qix-
Copy link

Qix- commented Feb 7, 2020

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.

@rautex
Copy link

rautex commented Feb 10, 2020

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.

the problem in this case is more thaht companies using ie11 massive, after my logs 25% of my visitors come by ie.

I would like to show the middle finger to ie but when u run a business u cant send them to hell because u want there money :)

@jeremylcarter
Copy link

What is the current workaround for this issue?

@rautex
Copy link

rautex commented Feb 17, 2020

What is the current workaround for this issue?

2.2.0 when u can after fmoessle

@tomtom94
Copy link

Took me 3 days to find out the bug was coming from socket.io-client module lol

Me too I downgrade module version to 2.2.0 cheers all

@govinddk4444
Copy link

Downgrading to 2.2.0 worked for me as well. Thanks.

@Rob-ot
Copy link

Rob-ot commented Apr 15, 2020

Maybe a good solution is to switch socket.io to this fork of debug debug-es5 that is transpiled to es5.

I've spent an entire day trying to get babel and webpack to transpile debug/src/browser.js and from the many threads I've stumbled on it seems like a lot of people are running into this too. Seems like a lot of engineering time that could be saved.

By the way, socket.io v2.2.0 has a memory leak that was fixed in 'ws' v7.1.2 (websockets/ws#1617) so be careful downgrading.

Edit: got it fixed
Most posts I found were recommending to stop excluding /node_modules/ from webpack but this didn't work and also is slow. (pretty sure webpack was hitting the file but babel wasn't transpiling it, maybe related to babel/preset-env)

Instead, I just installed debug-es5 and had webpack use that in place of debug by adding this to the webpack.config.js

  resolve: {
    alias: {
      debug: 'debug-es5',
    },
  },

@kmaraz
Copy link

kmaraz commented Apr 15, 2020

I am using:

{
  test: /\.js$/,
  use: babelLoader,
  exclude: excludeNodeModulesExcept(['debug']),
},
const babelLoader = {
    loader: 'babel-loader',
    options: {
      // Don't waste time on Gzipping the cache
      cacheCompression: false,
      // This is a feature of `babel-loader` for webpack (not Babel itself).
      // It enables caching results in ./node_modules/.cache/babel-loader/
      // directory for faster rebuilds.
      cacheDirectory: true,
      plugins: ['@babel/plugin-syntax-dynamic-import'],
      presets: [['@babel/env', { modules: false }]],
      sourceMaps: includeSourcemap && !isDevelopmentMode,
    },
  };
const excludeNodeModulesExcept = function (modules) {
  var pathSep = path.sep;
  if (pathSep == '\\')
    // must be quoted for use in a regexp:
    pathSep = '\\\\';
  var moduleRegExps = modules.map(function (modName) {
    return new RegExp('node_modules' + pathSep + modName);
  });

  return function (modulePath) {
    if (/node_modules/.test(modulePath)) {
      for (var i = 0; i < moduleRegExps.length; i++)
        if (moduleRegExps[i].test(modulePath)) return false;
      return true;
    }
    return false;
  };
};

@craigPeckett
Copy link

changing socket.io-client to 2.2.0 works for me but only after building and starting the application.

in dev mode I still get the error

TypeError: Object doesn't support property or method 'cbrt'
{
[functions]: ,
proto: { },
description: "Object doesn't support property or method 'cbrt'",
message: "Object doesn't support property or method 'cbrt'",
name: "TypeError",
number: -2146827850,
stack: "TypeError: Object doesn't support property or method 'cbrt'
at cielabForwardTransform (eval code:39754:3)
at fromXYZ (eval code:39763:3)
at lighten (eval code:39706:3)
at genVariations (eval code:39696:5)
at parse (eval code:39606:7)
at parsedTheme.get (eval code:39498:7)
at generatedStyles.get (eval code:39466:7)
at Theme.prototype.applyTheme (eval code:39297:5)
at handler (eval code:39449:13)
at Vue.prototype.$watch (eval code:4941:9)",
Symbol(Lang fallback)_i.t81c9tw05xo: undefined,
Symbol(react.element)_h.t81c9tw05xo: undefined,
Symbol(stop)_n.t81c9tw05xo: undefined
}

@laxell
Copy link

laxell commented Sep 6, 2020

Maybe a good solution is to switch socket.io to this fork of debug debug-es5 that is transpiled to es5.

I've spent an entire day trying to get babel and webpack to transpile debug/src/browser.js and from the many threads I've stumbled on it seems like a lot of people are running into this too. Seems like a lot of engineering time that could be saved.

By the way, socket.io v2.2.0 has a memory leak that was fixed in 'ws' v7.1.2 (websockets/ws#1617) so be careful downgrading.

Edit: got it fixed
Most posts I found were recommending to stop excluding /node_modules/ from webpack but this didn't work and also is slow. (pretty sure webpack was hitting the file but babel wasn't transpiling it, maybe related to babel/preset-env)

Instead, I just installed debug-es5 and had webpack use that in place of debug by adding this to the webpack.config.js

  resolve: {
    alias: {
      debug: 'debug-es5',
    },
  },

This saved me hours of work - thank you!

@kmaraz
Copy link

kmaraz commented Sep 8, 2020

I have created a very small repo with this issue solved with basic Webpack configuration: https://github.com/kmaraz/debug-to-es5

@darrachequesne
Copy link
Member

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).

@darrachequesne darrachequesne added this to the 2.3.1 milestone Sep 30, 2020
@qiulang
Copy link

qiulang commented Jun 22, 2021

This is an old issue but I need to add this, even with 'webpack-remove-debug' I still failed to make 4.x work on IE 11.

I have gave it up, don't think worth effort any more. 😱

{
    module: {
        rules: [
            {
				test: './node_modules/**/debug/**/*.js',
				loader: 'webpack-remove-debug'
			}
        ]
    }
};

@darrachequesne
Copy link
Member

@qiulang please check our own webpack configuration: https://github.com/socketio/socket.io-client/blob/master/support/webpack.config.js

@zzkkui
Copy link

zzkkui commented Nov 10, 2023

I am using:

{
  test: /\.js$/,
  use: babelLoader,
  exclude: excludeNodeModulesExcept(['debug']),
},
const babelLoader = {
    loader: 'babel-loader',
    options: {
      // Don't waste time on Gzipping the cache
      cacheCompression: false,
      // This is a feature of `babel-loader` for webpack (not Babel itself).
      // It enables caching results in ./node_modules/.cache/babel-loader/
      // directory for faster rebuilds.
      cacheDirectory: true,
      plugins: ['@babel/plugin-syntax-dynamic-import'],
      presets: [['@babel/env', { modules: false }]],
      sourceMaps: includeSourcemap && !isDevelopmentMode,
    },
  };
const excludeNodeModulesExcept = function (modules) {
  var pathSep = path.sep;
  if (pathSep == '\\')
    // must be quoted for use in a regexp:
    pathSep = '\\\\';
  var moduleRegExps = modules.map(function (modName) {
    return new RegExp('node_modules' + pathSep + modName);
  });

  return function (modulePath) {
    if (/node_modules/.test(modulePath)) {
      for (var i = 0; i < moduleRegExps.length; i++)
        if (moduleRegExps[i].test(modulePath)) return false;
      return true;
    }
    return false;
  };
};

This does not work for me, I found that babel/core also uses debug@4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests