agent-js icon indicating copy to clipboard operation
agent-js copied to clipboard

Fix module import problem with js-sha256

Open TrentBrown opened this issue 3 years ago • 2 comments

Describe the bug

When serving a web app with web-dev-server, attempting to import a backend description file results in a runtime syntax error at the point where the @dfinity/agent tries to load the js-sha256 code.

To Reproduce

I created the most minimal example of what I'm seeing and pushed the project up to my GitHub account here. The ReadMe there has the steps to reproduce:

CleanShot_2023-01-04_at_15 48 39

For reference, this is the Discord conversation I had with Kyle in the #ask-questions Discord channel.

TrentBrown avatar Jan 05 '23 00:01 TrentBrown

I see that Rollup is also not happy. Emits the same complaint when I try to build a distribution:

CleanShot 2023-01-04 at 17 08 09

TrentBrown avatar Jan 05 '23 01:01 TrentBrown

It's an odd issue, because it definitely is exported by the module. I've looked into it, and it's not trivially easy to modify the source code of js-sha256, because of some strange choices they made in designing their package modularization system

krpeacock avatar Jan 30 '23 22:01 krpeacock