Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker .data and .wasm files aren't found in production / built version #11694

Closed
7 tasks done
ayroblu opened this issue Jan 14, 2023 · 1 comment
Closed
7 tasks done
Labels
has workaround wontfix This will not be worked on

Comments

@ayroblu
Copy link

ayroblu commented Jan 14, 2023

Describe the bug

My project essentially does:

import vimWorkletUrl from "vim-wasm/vim.js?url";
...

This works great in development mode, but in production I get 404, these assets aren't found

Dev:
image

Prod:
image

I can't find any trace of them in the dist directory

Reproduction

https://github.com/ayroblu/wasm-import-bug

Steps to reproduce

yarn
yarn dev
# Verify it works
yarn build && yarn preview
# verify it doesn't work

System Info

System:
    OS: macOS 13.1
    CPU: (8) x64 Apple M1 Pro
    Memory: 24.88 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.2.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.19.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 109.0.5414.87
    Safari: 16.2
  npmPackages:
    @vitejs/plugin-react: ^3.0.0 => 3.0.0
    vite: ^4.0.0 => 4.0.4

Used Package Manager

yarn

Logs

No response

Validations

@sapphi-red
Copy link
Member

This is not a bug in Vite. Because vim.wasm (emscripten output) uses a dynamic url to fetch the .wasm/.data file, Vite cannot detect that and cannot bundle those files. It works in dev just because the files happens to be served where vim.wasm expects.

One workaround is to use Module.locateFile. But vim.wasm doesn't expose that function and we cannot use this function.

Another workaround is to use vite-plugin-static-copy and copy the .wasm/.data files to where vim.wasm expects.

@sapphi-red sapphi-red added wontfix This will not be worked on has workaround and removed pending triage labels Jan 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has workaround wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants