hedera-sdk-js icon indicating copy to clipboard operation
hedera-sdk-js copied to clipboard

Bundle issue in browser environment with esbuild

Open vadimvorotilov opened this issue 11 months ago • 0 comments

Description

I'm trying to use hashconnect package and it uses hedera-sdk-js as its main dependency. When I tried to bundle the project with esbuild, I got nodejs resolutions errors.

I found that if I remove exports field in hedera-sdk-js package.json it works fine after that.

Steps to reproduce

https://github.com/fantgeass/issue-example I've created a simple repo to reproduce an issue.

Additional context

Esbuild error log when I tried to build.

✘ [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";...

Hedera network

other

Version

2.41.0

Operating system

Linux

vadimvorotilov avatar Feb 29 '24 07:02 vadimvorotilov