Skip to content

Prevent socket.io-client duplication by force user to provide an instance of it #19

Closed
@probil

Description

@probil

I've made investigation today using vue cli, and that's what I got:

vue                                                    : 61.77 kb
vue + vue-socket.io-extended                           : 132.10 kb
vue + vue-socket.io-extended + custom socket.io-client : 190.87 kb

There is a duplication of socket.io-client library when you pass socket.io-client instance to the plugin.
So if you use it this way, you probably have extra ~70kb of useless data in your build.

The only way to fix it is to force library user to pass socket.io-client instance always.

Advantages:

  • less build size with custom socket.io-client (e.g. ~70Kb)
  • no force version of socket.io-client for user
  • no need to support socket.io-client inside the library (update library just because socket.io-client updated)
  • user can pass any library compatible with socket.io-client, for example, socket.io-client/dist/socket.io.slim.js which is ~8kb smaller than socket.io-client but drops IE6-8

Disadvantages:

  • little harder to setup

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions