`vite-plugin-imba` causes 'Module "crypto" has been externalized for browser compatibility warnings
Author: stopachkaCreated Jun 7, 2024Updated Jun 7, 2024
Labelsbug
Description
Hey team, an imba user reported an error in my project, and I ran across a peculiar situation.
In plain vite, If import object-hash, I see no warnings.
However, if I import the same package in an imba project, I see the following warning:
Cannot access "crypto.getHashes" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.Looking at the URL that vite points too, it seems to say that object-hash is requiring a nodejs module.
However, this doesn't seem to be the case, when importing object-hash in plain vite. I wonder if there's some environment error that is going on when used with imba.
All thoughts much appreciated!
I created a repro that you can try here:
https://github.com/stopachka/vite-imba-externalized-bug
cd vite-plain
bun install
bun run dev
# Open the browser and see no warnings.
cd vite-with-imba
bun install
bun run dev
# Open the browser and see the warning.Reproduction
https://github.com/stopachka/vite-imba-externalized-bug
System Environment
System:
OS: macOS 13.2
CPU: (12) arm64 Apple M2 Max
Memory: 20.17 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 20.7.0 - ~/Library/Caches/fnm_multishells/11913_1717727206664/bin/node
Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/11913_1717727206664/bin/yarn
npm: 10.1.0 - ~/Library/Caches/fnm_multishells/11913_1717727206664/bin/npm
pnpm: 8.14.0 - ~/Library/Caches/fnm_multishells/11913_1717727206664/bin/pnpm
bun: 1.1.12 - ~/.bun/bin/bun
Watchman: 2024.05.06.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 125.0.6422.142
Safari: 16.3
npmPackages:
imba: ^2.0.0-alpha.235 => 2.0.0-alpha.235Source: imba/imba