Internet Explorer ES6 function not compiled
See original GitHub issueDescribe the bug
Internet Explorer ES6 function not compiled, which comes from socket.io-parser
module a dependency of socket.io-client
.
I have been trying to force the compilation for this specific module, but babel-loader
can’t reach it because I am not making a straight ES6 import of socket.io-parser
in my pages.
import parser from 'socket.io-parser'
otherwise I would have compiled this module easily 😃 But I need you to do it for me. And get a top notch module 🥇
function excludeNodeModulesExcept(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
}
}
webpackRule = [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: excludeNodeModulesExcept(['query-string', 'socket.io-parser']),
loader: 'babel-loader'
}
]
Expected behavior I want the javascript bundles to run on Internet Explorer 11, as simple as that.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
ES6 arrow (=>) functions incompatible with IE? - Stack Overflow
No, arrow functions aren't supported in IE. Use Babel to compile ES6 code to ES5. – 4castle. Dec 8, 2016 at 17:50.
Read more >Module Methods - webpack
This section covers all methods available in code compiled with webpack. ... ES6 module syntax natively, meaning you can use import and export...
Read more >Going from JavaScript to WebAssembly in three steps
Written in ES6 JavaScript (or ECMAScript 6, the latest version of JavaScript), it still compiles to ES5 to support Internet Explorer 11.
Read more >BabelJS - Quick Guide - Tutorialspoint
We have used the ES6 Arrow function; the same does not work on all browsers as seen above. To get this working, we...
Read more >When can I actually use ES6? - Marius Gundersen
TL;DR ES6 modules can be compiled to ES5 code in the browser. As long as a browser implements modules, it can compile the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi there,
I’ve run into the same issue. But the solution is quite simple. Webpack uses the ES6 build, and by adding a
browser
field to theexports
field inpackage.json
this can be solved. Created a PR for this.In the meantime, you can use the following workaround by adding an alias to your
webpack.config.js
:Hope this helps!
Please use babel to transpile the code to ES5/ES3. This is the best tool for this job.
More information here: https://github.com/sindresorhus/ama/issues/446
Thanks!