Transpiling with webpack doesn't work.
See original GitHub issueFirst thing’s first:
- node v6.2.0
- webpack v1.13.1
- socket.io v1.4.6
Trying to transpile the following code:
import io from 'socket.io';
But the following error gets thrown:
fs.js:971
return binding.fstat(fd);
^
Error: EBADF: bad file descriptor, fstat
at Error (native)
at Object.fs.fstatSync (fs.js:971:18)
at tryStatSync (fs.js:456:13)
at fs.readFileSync (fs.js:504:12)
at eval (webpack:///../~/socket.io/lib/index.js?:27:20)
So I try to fiddle with it by commenting out socket.io/lib/index.js, line 27:20
// var clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8');
While also commenting out the following occurrence of clientSource
.
Afterwards, code transpiles beautifully without any errors.
It seems to me that the issue is with require.resolve
being incompatible with webpack transpilation.
Any thoughts on how I can fix this issue?
I would love to use some socket.io
with webpack.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Webpack not transpiling Typescript - Stack Overflow
I tried awesome-typescript-loader and ts-loader but both are not working when I try to use ES6/TypeScript features in my code, like defining ...
Read more >How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >Compiling and bundling TypeScript libraries with Webpack
Since I started working on UI-Router React I've been enjoying writing TypeScript. There are both advantages and disadvantages working with a typed and ......
Read more >Loaders | webpack
Webpack enables use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write...
Read more >A mostly complete guide to webpack 5 (2020)
If something doesn't work for you, drop me a polite email, and I'll try to fix the tutorial if I have time. Enjoy!...
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
@tyron-j , excluding node_modules from babel-loader doesn’t help. Excluding it entirely from the webpack bundle via the
externals
config does help, but it is an unwanted behavior. We would like to have one bundle file including all the dependencies in it.Forgot to mention where that object actually belongs:
^ as part of your
webpack.config.js
.