Hashpack / hashconnect

Hashconnect library, readme in progress
BSD Zero Clause License
45 stars 38 forks source link

Can't build the project because of nodejs dependencies #197

Closed fantgeass closed 6 months ago

fantgeass commented 6 months ago

I'm trying to build a project for a browser with "hashconnect" package. When I'm trying to bundle it with esbuild, I'm getting resolve errors related to nodejs. I don't understand why the browser package has dependencies on the node.

Should I setup something on my side(like polyfills) or it is the package?

✘ [ERROR] Could not resolve "fs"

    node_modules/@hashgraph/sdk/src/client/NodeClient.js:21:15:
      21 │ import fs from "fs";
         ╵                ~~~~

  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "util"

    node_modules/@hashgraph/sdk/src/client/NodeClient.js:22:17:
      22 │ import util from "util";...
fantgeass commented 6 months ago

The problem was in "exports" field of "hedera-sdk-js" package.json. Esbuild used it(as it probably should) instead of "browser" field.