cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

Module ctypto issue when vite build

Open chunyang-infstones opened this issue 1 year ago • 1 comments

I'm using @cosmjs/stargate package on my website, a react project. When I run vite build command, I will get a warning as bellow:

[plugin:vite:resolve] [plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/Users/gechunyang/Documents/infstones/codes/dev-fte/webservice/webservice/client/node_modules/@cosmjs/crypto/build/random.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

node_modules/@protobufjs/inquire/index.js (12:18): Use of eval in "node_modules/@protobufjs/inquire/index.js" is strongly discouraged as it poses security risks and may cause issues with minification.

This warning won't affect the functionality of my production, but I want to make sure that it won't cause any security issue or have other danger?

chunyang-infstones avatar May 14 '24 02:05 chunyang-infstones

That's a warning about a (dynamic) require() call to a native Node.js module, which would break if executed in a browser and there's no polyfill, but that call never even happens at runtime if running in a browser.

The compile time warning is gone now after the code changes in #1728 eliminated the call entirely.

dynst avatar Jul 30 '25 04:07 dynst