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

Make socket.io including dependencies esm compatible #1536

Closed
Artur- opened this issue Apr 4, 2022 · 4 comments
Closed

Make socket.io including dependencies esm compatible #1536

Artur- opened this issue Apr 4, 2022 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@Artur-
Copy link

Artur- commented Apr 4, 2022

Is your feature request related to a problem? Please describe.
@web/test-runner only supports ESM imports: modernweb-dev/web#1439. It is currently not possible to use socket.io with that.

Describe the solution you'd like
All dependencies of socket.io-client should be ESM modules. Right now there are problems with at least

  • @socket.io/component-emitter
  • parseuri
  • parseqs
  • yeast
  • ws (shouldn't be loaded at all as far as I understand)
@Artur- Artur- added the enhancement New feature or request label Apr 4, 2022
@Artur-
Copy link
Author

Artur- commented Apr 4, 2022

In practice you likely need to mock socket.io in most tests which makes this a not that major issue for this use case

@darrachequesne
Copy link
Member

darrachequesne commented Apr 5, 2022

That sounds reasonable 👍

Here is the list of the dependencies for the Socket.IO client:

Dependency Repository ESM?
@socket.io/component-emitter https://github.com/socketio/emitter/ ✔️ (@socket.io/[email protected])
backo2 https://github.com/mokesmokes/backo
debug https://github.com/debug-js/debug
ms https://github.com/vercel/ms
engine.io-client https://github.com/socketio/engine.io-client/ ✔️
engine.io-parser https://github.com/socketio/engine.io-parser ✔️
@socket.io/base64-arraybuffer https://github.com/socketio/base64-arraybuffer ✔️
has-cors https://github.com/component/has-cors ✔️ ([email protected])
parseqs https://github.com/galkn/querystring ✔️ ([email protected])
parseuri https://github.com/galkn/parseuri ✔️ ([email protected])
yeast https://github.com/unshiftio/yeast ✔️ ([email protected])
socket.io-parser https://github.com/socketio/socket.io-parser ✔️

Both ws and xmlhttprequest-ssl are only needed for Node.js, so I think they can be ignored in that case.

From: https://socket.io/docs/v4/client-installation/#dependency-tree

darrachequesne added a commit to socketio/engine.io-client that referenced this issue Apr 13, 2022
This commit allows to:

- provide an ESM version of those modules ([1])
- reduce the attack surface in case of supply chain attacks
- reduce the size of the bundle with tree-shaking

As a downside, we won't receive security updates for those modules
anymore.

[1]: socketio/socket.io-client#1536
@Waxolunist
Copy link

Actually it would make it simpler for example in conjunction with esbuild or build less execution if they would be esm compatible.

darrachequesne added a commit to socketio/emitter that referenced this issue Apr 17, 2022
darrachequesne added a commit to socketio/socket.io-parser that referenced this issue Apr 17, 2022
darrachequesne added a commit that referenced this issue Apr 23, 2022
This commit allows to:

- provide an ESM version of those modules ([1])
- reduce the attack surface in case of supply chain attacks
- reduce the size of the bundle with tree-shaking

As a downside, we won't receive security updates for those modules
anymore.

[1]: #1536

Related: socketio/engine.io-client@df32277
@darrachequesne
Copy link
Member

OK, so starting from [email protected] we only include ESM compatible dependencies!

@darrachequesne darrachequesne added this to the 4.5.0 milestone Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants