Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reverts #68 and do not rollup
@cosmjs/stargate
in the bundler.Causes
There are a few things playing together that caused the problem:
next build
, NextJs will try to pre-render the page and that's what the "collect page data" is doing. The code will be excuted in NodeJs runtime instead of a proper browser during the pre-render phase.libsodium-sumo
which is a library dependency of@cosmjs/crypto
. As a result, thecrypto
library wasn't properly imported and could not be executed in NodeJs.How to narrow down the error?
Unfortunately, NextJs doesn't surface the error very well during pre-render. The actual error is
The
next dev
command does surface the error but doesn't give much information on where to look at. This is not the fault ofnext dev
though, it's thelibsodium-sumo
library actually throwing a string instead of a proper error likeThat caused some trouble to locate the actual error but with some
grep|ack
, it's not to hard to narrow down where it's thrown. TheTTT sumo 2
at the end is how I locate the message.Solution:
Exclude
@cosmjs/stargate
from rollup so that it doesn't get mangled by Vite.