vite-plugin-wasm-pack
vite-plugin-wasm-pack copied to clipboard
Fix bundler looking for index.<chunk_hash>.wasm
Seems like I missed something in my initial PR as that made it work for vite
but didn't work with vite build
and vite preview
.
It seems newer versions of wasm-pack or at least my version uses import.meta.url
for getting the current file, so the existing regex replace isn't capturing it so I get a 404 fetching the wasm as its looking for index.<chunk_hash>_bg.wasm
which doesnt exist.
This also uses the transform
hook to replace the input
in the modulePaths
entry file's because I was running into an issue with pnpm caching; I just removed the isNodeModule
logic from the buildStart
as the transform
handles that piece now. I left the cratePaths
variant in the buildStart
as it relies on the fs.copy
so I didn't want to break anything in that aspect.