The React app runs locally without issues, once deployed I get the following runtime error.
Uncaught (in promise) AbortError: Unable to load a worklet's module.
here is the vite config
export default defineConfig({
plugins: [react(),
//copy WASM files to destination folder
viteStaticCopy({
targets: [
{
src: ["**/*.onnx"],
dest: 'dist',//' onnx web files',
},
{
src: ["node_modules/onnxruntime-web/dist/ort-wasm-*"],
dest: 'dist',// './',//'wasm-files',
},
],
}),
],
assetsInclude: ["**/*.onnx"],
optimizeDeps: {
exclude: ["onnxruntime-web"],
esbuildOptions: {
supported: {
"top-level-await": true,
},
},
},
server: {
headers: {
// "Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
},
});
and the audioworklet code
import workletUrl from "./audio-processor.ts?url";
...
await audioContext.audioWorklet.addModule(
new URL(workletUrl, import.meta.url)
); // vite requires the meta format and ?url suffix to import a TypeScript file to use it in an AudioWorklet.
the audio-processor.ts file is located in /dist and in /public