Skip to content

Avoid using debug module and other node builtins in client library #1188

Closed
@rmehta

Description

@rmehta

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions