Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [RollupError]: "default" is not exported by "node_modules/ws/lib/websocket.js", imported by "node_modules/ws/wrapper.mjs". #5193

Open
prljav opened this issue Sep 21, 2024 · 2 comments
Labels
question Further information is requested

Comments

@prljav
Copy link

prljav commented Sep 21, 2024

Describe the bug
A clear and concise description of what the bug is.
Cannot import io from socket.io-client
To Reproduce
Use @kellnerd/userscript-bundler to try to bundle import { io } from "socket.io-client"
Please fill the following code example:

Socket.IO server version: x.y.z none

Server

import { Server } from "socket.io";

const io = new Server(3000, {});

io.on("connection", (socket) => {
  console.log(`connect ${socket.id}`);

  socket.on("disconnect", () => {
    console.log(`disconnect ${socket.id}`);
  });
});

Socket.IO client version: x.y.z

Client

import { io } from "socket.io-client";

const socket = io("ws://localhost:3000/", {});

socket.on("connect", () => {
  console.log(`connect ${socket.id}`);
});

socket.on("disconnect", () => {
  console.log("disconnect");
});

Expected behavior
have the IO object

Platform:

  • Device: [e.g. Samsung S8] desktop/127.0.6533.88 (Official Build) built on Debian 12.6, running on Debian 12.6 (64-bit)
  • OS: [e.g. Android 9.2] debian 12.6

Additional context
Add any other context about the problem here.
no

@prljav prljav added the to triage Waiting to be triaged by a member of the team label Sep 21, 2024
@prljav
Copy link
Author

prljav commented Sep 21, 2024

NOTE: could be issue with the bundler, if it is someone please help :P

@darrachequesne
Copy link
Member

Hi! rollup must be configured to use the browser-specific version of the package:

export default {
  // ...
  plugins: [
    resolve({
      browser: true,
    }),
  ],
};

Is that your case?

Reference: https://socket.io/docs/v4/client-with-bundlers/#rollupjs

@darrachequesne darrachequesne added question Further information is requested and removed to triage Waiting to be triaged by a member of the team labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants