Sitelet https://github.com/socketio/engine.io-parser/issues/116
Skip to content

Unable to bundle socket.io client due to undeclared dependency on base64-arraybuffer #116

Description

@ozyman42

I'm attempting to bundle the socket.io client with webpack 5 and yarn 2. I believe these have more strict dependency checks which would explain why this issue hasn't been opened for webpack 4 and/or npm users.

Webpack is giving the error

ERROR in ../../../.yarn/cache/engine.io-parser-npm-4.0.1-6bdb879e8a-3b71ef8b5a.zip/node_modules/engine.io-parser/lib/decodePacket.browser.js 7:18-47
Module not found: Error: engine.io-parser tried to access base64-arraybuffer, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: base64-arraybuffer (via "base64-arraybuffer")
Required by: engine.io-parser@npm:4.0.1 (via /home/alex/GitProjects/tools/webpack-hot-module-replacement/.yarn/cache/engine.io-parser-npm-4.0.1-6bdb879e8a-3b71ef8b5a.zip/node_modules/engine.io-parser/lib/)
 @ ../../../.yarn/cache/engine.io-parser-npm-4.0.1-6bdb879e8a-3b71ef8b5a.zip/node_modules/engine.io-parser/lib/index.js 2:21-46
 @ ../../../.yarn/cache/engine.io-client-npm-4.0.2-9adb255344-af3880585b.zip/node_modules/engine.io-client/lib/index.js 14:24-51
 @ ../../../.yarn/cache/socket.io-client-npm-3.0.3-512b232ec1-8bb891554f.zip/node_modules/socket.io-client/build/manager.js 4:12-39
 @ ../../../.yarn/cache/socket.io-client-npm-3.0.3-512b232ec1-8bb891554f.zip/node_modules/socket.io-client/build/index.js 5:18-38 69:16-36
 @ ../../@skoville/webpack-hmr/client/universal/default-socket-io-accessor~/build/socket-io-accessor.js 13:27-54
 @ ../../@skoville/webpack-hmr/client/universal/default-socket-io-accessor~/build/package.js 13:13-44
 @ ../../@skoville/webpack-hmr/client/web/default~/build/entry.js 13:66-142

seems like this is accurate since it's being required here

base64decoder = require("base64-arraybuffer");

is there any reason why this isn't included in dependencies and is instead only in devDependencies?

"base64-arraybuffer": "0.1.5",

In case there's a native component to this library which causes it to fail compiling for some users, consider following the approach that was eventually taken here websockets/ws#1220, where we would move base64-arraybuffer from devDependencies to optionalDependencies.

I can open a PR if this approach (move to optional dependencies) works for you.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions