Avoid using `debug` module and other node builtins in client library
See original GitHub issueNote: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
Current behaviour
Use socket-io.client
in an app and build it with rollup
JS file
const io = require('socket.io-client')
...
Build with rollup
5:44:40 PM watch.1 | (!) Unresolved dependencies
5:44:40 PM watch.1 | https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency
5:44:40 PM watch.1 | tty (imported by ../frappejs/node_modules/socket.io-client/node_modules/debug/src/node.js, commonjs-external:tty, ../frappejs/node_modules/socket.io-parser/node_modules/debug/src/node.js, ../frappejs/node_modules/debug/src/node.js)
5:44:40 PM watch.1 | util (imported by ../frappejs/node_modules/socket.io-client/node_modules/debug/src/node.js, commonjs-external:util, ../frappejs/node_modules/socket.io-parser/node_modules/debug/src/node.js, ../frappejs/node_modules/debug/src/node.js)
5:44:40 PM watch.1 | fs (imported by ../frappejs/node_modules/socket.io-client/node_modules/debug/src/node.js, commonjs-external:fs, ../frappejs/node_modules/socket.io-parser/node_modules/debug/src/node.js, ../frappejs/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js, ../frappejs/node_modules/bindings/bindings.js)
5:44:40 PM watch.1 | net (imported by ../frappejs/node_modules/socket.io-client/node_modules/debug/src/node.js, commonjs-external:net, ../frappejs/node_modules/socket.io-parser/node_modules/debug/src/node.js)
5:44:40 PM watch.1 | url (imported by ../frappejs/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js, commonjs-external:url, ../frappejs/node_modules/ws/lib/WebSocket.js, ../frappejs/node_modules/ws/lib/WebSocketServer.js)
5:44:40 PM watch.1 | child_process (imported by ../frappejs/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js, commonjs-external:child_process)
5:44:40 PM watch.1 | http (imported by ../frappejs/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js, commonjs-external:http, ../frappejs/node_modules/ws/lib/WebSocket.js, ../frappejs/node_modules/ws/lib/WebSocketServer.js)
5:44:40 PM watch.1 | https (imported by ../frappejs/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js, commonjs-external:https, ../frappejs/node_modules/ws/lib/WebSocket.js)
5:44:40 PM watch.1 | events (imported by ../frappejs/node_modules/ws/lib/WebSocket.js, commonjs-external:events, ../frappejs/node_modules/ws/lib/WebSocketServer.js)
5:44:40 PM watch.1 | crypto (imported by ../frappejs/node_modules/ws/lib/WebSocket.js, ../frappejs/node_modules/ws/lib/Sender.js, commonjs-external:crypto, ../frappejs/node_modules/ws/lib/WebSocketServer.js)
5:44:40 PM watch.1 | buffer (imported by ../frappejs/node_modules/safe-buffer/index.js, commonjs-external:buffer)
5:44:40 PM watch.1 | zlib (imported by ../frappejs/node_modules/ws/lib/PerMessageDeflate.js, commonjs-external:zlib)
5:44:40 PM watch.1 | path (imported by ../frappejs/node_modules/bindings/bindings.js, commonjs-external:path)
5:44:40 PM watch.1 | (!) Missing global variable names
5:44:40 PM watch.1 | Use output.globals to specify browser global variable names corresponding to external modules
5:44:40 PM watch.1 | tty (guessing 'tty')
5:44:40 PM watch.1 | util (guessing 'util')
5:44:40 PM watch.1 | fs (guessing 'fs')
5:44:40 PM watch.1 | net (guessing 'net')
5:44:40 PM watch.1 | url (guessing 'url')
5:44:40 PM watch.1 | child_process (guessing 'child_process')
5:44:40 PM watch.1 | http (guessing 'http')
5:44:40 PM watch.1 | https (guessing 'https')
5:44:40 PM watch.1 | buffer (guessing 'buffer')
5:44:40 PM watch.1 | path (guessing 'path')
5:44:40 PM watch.1 | zlib (guessing 'zlib')
5:44:40 PM watch.1 | crypto (guessing 'crypto')
5:44:40 PM watch.1 | events (guessing 'events')
Steps to reproduce (if the current behaviour is a bug)
See above
Expected behaviour
Should be include client library easily without nodejs builtins
Setup
- OS:
- browser:
- socket.io version: 2.0.4
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Client libraries should be dependent only on browser API.
Using nodejs builtins (debug) creates “dependency hell”. I had to include socket.io-client separately with the <script>
tag finally.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How To Debug Node.js with the Built-In Debugger and ...
In this article, you will use a debugger to debug some sample Node.js applications. You will first debug code using the built-in Node.js ......
Read more >Node.js Debugging: Tools, Techniques, Best Practices
Another better way than using the console.log is to use the debug module of Node.js. This module is available as a tiny JavaScript...
Read more >How to PROPERLY debug node.js with node inspector?
In javascript you can set breakpoints using the debugger; statement. However, they will only pause node if a debugger is actually attached.
Read more >Debug Node.js Apps using Visual Studio Code
js runtime and can debug JavaScript, TypeScript, and many other languages that are transpiled into JavaScript. Setting up a project for Node.js debugging...
Read more >How to Debug a Node.js Application: Tips, Tricks and Tools
Only use the built-in debugging client when there's absolutely no other option, you're feeling particularly masochistic, and you're not ...
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
For anyone still running into this issue (like me today), make sure to use the option
browser: true
for@rollup/plugin-node-resolve
.Excluding the debug module like in the slim webpack build mentioned above does still reduce the bundle size.
Added in the documentation here: https://socket.io/docs/v4/client-with-bundlers/#browser-1