-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Describe the bug
Packages that use WASM often contain lines like new URL('localfile.wasm', import.meta.url);
. The vite optimizer puts a version of de javascript code in the node_modules/.vite/deps
cache, but does not copy the wasm file or rewrite the path.
This is a common issue with vite (vitejs#8427), but in that issue it is suggested that this would be fixed in rolldown-vite since it has a reimplemented optimizer. The rolldown-vite optimizer seems broken in the exact same way.
Production builds work fine since the wasm file will be copied from the original directory to the output directory. Development builds that use optimized code from node_modules/.vite/deps
are broken.
The error that appears is the error below. In practice, the error is that the optimized javascript attemps to load http://localhost:5173/node_modules/.vite/deps/color_thief_wasm_bg.wasm
which does not exist.
Uncaught (in promise) CompileError: wasm validation error: at offset 4: failed to match magic number color-thief-wasm-web_color_thief_wasm__js.js:111:1
Reproduction
https://stackblitz.com/edit/vitejs-rolldown-vite-mcvqmvx6?file=package.json,src%2Fmain.js
Steps to reproduce
No response
System Info
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M1
Memory: 143.83 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.0 - /run/current-system/sw/bin/node
npm: 10.9.2 - /run/current-system/sw/bin/npm
bun: 1.2.19 - /run/current-system/sw/bin/bun
Watchman: 2025.04.21.00 - /run/current-system/sw/bin/watchman
Browsers:
Safari: 18.5
npmPackages:
rolldown-vite: 7.1.0
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs and the Rolldown-related guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.