Open Jerboas86 opened 1 year ago
Can't start your project
I managed to build your project and added Vitest and SSR support. Please test~
A question: what's the difference between Worker and Worklet. What extra steps will I need to make it work in Worklet?
With vite-plugin-wasm: v3.2.1
Svelte | Sveltekit | |
---|---|---|
Vitest | ✅ | ✅ |
Svelte | Sveltekit | |
---|---|---|
Window | ✅ | ✅ |
Worker | ✅ | ✅ |
Worklet | ❗ | ❗ |
Svelte | Sveltekit | |
---|---|---|
Window | ✅ | ✅ |
Worker | ❗ | ❗ |
Worklet | ❗ | ❗ |
Svelte | Sveltekit | |
---|---|---|
Window | ✅ | ✅ |
Worker | ✅ | ✅ |
Worklet | ❗ | ❗ |
A question: what's the difference between Worker and Worklet. What extra steps will I need to make it work in Worklet?
AFAIK, In AudioWorkletScope:
URL
is not available.fetch
is not available.import
is not available (yet) in Firefox's worklet (see)Other apis are not available (see)
I dont known if this is also true for others worklet: PainWorklet, LayoutWorklet, and AnimationWorklet.
Does it mean I could only base64 encode the WASM file to load it in Worklet context? Are there any other APIs used by wasm-bindgen that is missing in Worklet context?
Does it mean I could only base64 encode the WASM file to load it in Worklet context?
I dont known
Are there any other APIs used by wasm-bindgen that is missing in Worklet context?
wasm-bindgen uses TextEncoder
and TextDecoder
(see).
Firefox worker is supported now. Please test.
worker is still not working on FF, for both svelte and sveltekit (tested with with vite-plugin-wasm last commit)
this error message appears in the console.
SyntaxError: import declarations may only appear at top level of a module
How did you build?
You need to set worker to iife, not es.
How did you build?
I retrieved the commit and built from source, maybe there is a better way?
package.json
{
[...]
"devDependencies": {
[...]
"vite-plugin-wasm": "git@github.com:Menci/vite-plugin-wasm.git#7ab4a5e"
}
}
You need to set worker to iife, not es.
i used the default as specify in the README
vite.config.js
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte(), wasm(), topLevelAwait()],
test: {
environment: "jsdom",
},
worker: {
plugins: [wasm(), topLevelAwait()],
},
});
I push it on the repo, you can check it out, see if there is any mistake. (link)
No, you need to use my plugin vite-plugin-top-level-await to transform this.
On Tue, Feb 28, 2023 at 19:28 Jerboas86 @.***> wrote:
How did you build?
I retrieved the commit and built from source, maybe there is a better way?
package.json
{ [...] "devDependencies": { [...] "vite-plugin-wasm": @.***:Menci/vite-plugin-wasm.git#7ab4a5e" } }
You need to set worker to iife, not es.
i used the default as specify in the README
vite.config.js
import { defineConfig } from "vite"; import { svelte } from @.***/vite-plugin-svelte"; import wasm from "vite-plugin-wasm"; import topLevelAwait from "vite-plugin-top-level-await";
// https://vitejs.dev/config/ export default defineConfig({ plugins: [svelte(), wasm(), topLevelAwait()], test: { environment: "jsdom", }, worker: { plugins: [wasm(), topLevelAwait()], }, });
I push it on the repo, you can check it out, see if there is any mistake. (link) https://github.com/Jerboas86/vpw-test-env
— Reply to this email directly, view it on GitHub https://github.com/Menci/vite-plugin-wasm/issues/24#issuecomment-1448017533, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWRBA2D3PICUVVBBLZHCILWZXOOHANCNFSM6AAAAAATQTFISY . You are receiving this because you commented.Message ID: @.***>
I was trying to uderstand where vite-plugin-wasm is supported.
The testing environment is here: https://github.com/Jerboas86/vpw-test-env
I tried different frameworks:
In different scopes:
And with different web browers:
Results
Chrome
Firefox
Gnome web
opened issues:
and opened PR:
I would suggest to:
The testing can also be extended if it is valuable, let me known.