littlefoxcompany / usemods

Zippy little utils for your JavaScript projects.

Home Page:https://usemods.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module "crypto" has been externalized for browser compatibility

ajnsn opened this issue · comments

fyi: Since v1.51 using a Vite build

vite v5.3.1 building for production...
[plugin:vite:resolve] [plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/node_modules/usemods/dist/index.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

Huly®: MODS-103

Hi @ajnsn!

Thanks for pointing this one out.

I've made a fix in v1.5.2 that uses globalThis for Node 19+, which removes the need to import the Crypto library. There's also a graceful fallback for older Node versions when performing random functions in SSR environments.

Client-side remains the same!

https://github.com/littlefoxcompany/usemods/releases/tag/v1.5.2

Thank you so much @jrmymbtlr - I can confirm that 1.52 resolves this 👍