question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transpiling with webpack doesn't work.

See original GitHub issue

First 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:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
omertscommented, Mar 22, 2017

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

0reactions
tyron-jcommented, Sep 6, 2016

Forgot to mention where that object actually belongs:

module.exports = [{
    // ...

    module: {
        loaders: [ babelLoader ]
    },

    // ...
}];

^ as part of your webpack.config.js.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found