Skip to content

Missing "./build/esm-debug" specifier in "socket.io-client" package  #4635

Closed

Description

@wvhulle

Describe the bug

The documentation is unable to help me to set up debugging in the client when installed through npm.
It only refers to cdn, but i cannot find anywhere on the Socket IO website or google how to import the esm-debug version.

Importing socket.io-client/build/esm-debug in Vite results in

Internal server error: Missing "./build/esm-debug" specifier in "socket.io-client" package

To Reproduce

localStorage.debug = "*"
No logs shown.

Server

socket.io 4.6.1

Client

socket.io-client 4.6.1

Expected behavior

Show debug statements in browser

Not possible

Platform:
Edge and Firefox
Vite

Additional context

Activity

  1. added
    to triage
    on Feb 21, 2023
  2. darrachequesne commented on Feb 23, 2023

    @darrachequesne
    Member

    Hi! We could indeed export the debug build, which is currently only available for the Node.js platform (here).

    That being said, I am not sure whether Vite supports the exports field, something like:

    {
      // ...
      "exports": {
        "/debug": {
          "import": "./build/esm-debug/index.js",
          "require": "./build/cjs/index.js",
          "types": "./build/esm/index.d.ts"
        }
      },
    }

    And then: import { io } from "socket.io-client/debug"

    Reference: https://nodejs.org/api/packages.html#package-entry-points

    What do you think?

  3. added
    question
    and removed
    to triage
    on Feb 23, 2023
  4. wvhulle commented on Feb 23, 2023

    @wvhulle
    Author

    I would have to check if vite supports that specifically for the client but I have found another way. In vite it is also possible to declare the path to the debug version as resolve alias. Then you can import it with a relative path in the client code, at least on the dev server. There is also some other issue with XMLrequest that can be resolved like this.

    Besides that, in the server I also found out that it is possible to toggle debugging on and off by importing debug from debug and calling debug.enable. I prefer this to yet another environment variable.

    Maybe this could be documented?

  5. added this to the 4.7.0 milestone on Jun 20, 2023
  6. darrachequesne commented on Jun 23, 2023

    @darrachequesne
    Member

    This should be fixed by socketio/socket.io-client@781d753, included in version 4.7.0.

    Please reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions