cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
649 stars 333 forks source link

CosmJS cannot be used with CRA/react-scripts version 5 (Webpack 5) #1389

Open webmaster128 opened 1 year ago

webmaster128 commented 1 year ago

When upgrading react-scripts from v4 to v5, you also get a webpack v4 to v5 upgrade. In Webpack 5 a bunch of modules need to be configures manually. CosmJS lists the required condiguration here: https://github.com/cosmos/cosmjs#webpack-configs.

However, since Create React App/react-scripts don't allow you to easily create your own webpack 5 config, this does not work together.

mrakus-sofomo commented 1 year ago

Did you find any option to not use crypto-browserify, stream-browserify and make cosmjs run?

webmaster128 commented 1 year ago

Given the responses in https://twitter.com/simon_warta/status/1634969846676078592 I assume CRA is pretty much dead and folks use different frameworks anyways.

mrakus-sofomo commented 1 year ago

@webmaster128 However, it seems to me that this does not solve the problem. Let's imagine a situation in which we have a package that is used by our customers. If I want to use @cosmjs, then I have to require each client to install polyfills.

webmaster128 commented 1 year ago

Nope, you just have to tell Webpack to not include those packages. This is how things are supposed to work. require("not-found") just throws at runtime and CosmJS is fine with that as there are different implementations.