`vite dev` doesn't copy assets to `node_modules/.vite/deps` via `new URL()` support in worker scripts
See original GitHub issueDescribe the bug
vite dev
doesn’t copy assets to node_modules/.vite/deps
via new URL()
support in worker scripts
Manually copying the missing assets to node_modules/.vite/deps
seems to fix the problem as a workaround.
Reproduction
https://github.com/schickling-test/2022-nov-vite-worker-dev-repro
Steps to reproduce
Unfortunately due to some Stackblitz WASM limitations, it doesn’t work on Stackblitz yet.
Setup
git clone git@github.com:schickling-test/2022-nov-vite-worker-dev-repro.git
2022-nov-vite-worker-dev-repro
npm install
Repro bug: dev not working
npm run dev
# dev console should now show WASM errors and the network monitor should show 404s
Repro workaround: dev working
npm run dev
npm run fix-dev # run in another terminal
# things should work now
Repro prod build working
npm run build
npm run preview # uses netlify cli to use the needed HTTP headers
# things should work now
System Info
System:
OS: macOS 13.0
CPU: (10) arm64 Apple M1 Max
Memory: 47.81 MB / 32.00 GB
Shell: 3.4.1 - /Users/schickling/.nix-profile/bin/fish
Binaries:
Node: 16.16.0 - ~/.nix-profile/bin/node
Yarn: 1.22.18 - ~/.nix-profile/bin/yarn
npm: 8.11.0 - ~/.nix-profile/bin/npm
Browsers:
Chrome: 107.0.5304.87
Chrome Canary: 109.0.5396.0
Firefox: 100.0
Safari: 16.1
npmPackages:
vite: ^3.2.2 => 3.2.2
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- 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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
new URL(foo, import.meta.url) doesn't work when dependency ...
In Vite, after esbuild optimize third party, import.meta.url cannot be optimize succeed. Ref Vite Docs, even if set build.target to es2020 ...
Read more >Features | Vite
Rewrite the imports to valid URLs like /node_modules/.vite/deps/my-dep.js?v=f3sf2ebd so that the browser can import them properly. Dependencies are Strongly ...
Read more >Vue3 + Vite + Vuestic: Running in Dev Server but Blank White ...
I found on stack overflow that this may be because of the static paths in production by vite . But, this problem I...
Read more >vite exports is not defined | The AI Search Engine You Control
error: exports is not defined when using ViteDevServer. ... vite:config 'vite:worker', vite:config 'vite:worker-import-meta-url', vite:config 'vite:asset', ...
Read more >How to Install and Use Vite in Your Web Projects
Vite uses native browser ES imports to enable support for modern browsers without a build process. Vite consists of two major parts: The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I guess replacing
const wasmUrl = new URL('sqlite3.wasm', import.meta.url).href
withimport wasmUrl from 'sqlite3.wasm?url'
would work for Vite. But that will break other bundlers and nodejs.Using
exclude: ['sqlite-wasm-esm']
seems to indeed work now as a workaround. Closing as duplicate of https://github.com/vitejs/vite/issues/8427.Thanks for your help @sapphi-red