Replies: 2 comments 5 replies
-
I found a workaround for anyone interested, but it is convoluted:
const processorUrl = () => {
// The only way to get a transformed chunked URL is to abuse of the worker
// support. The supported syntax can be found here: https://github.com/vitejs/vite/blob/b9ee620108819e06023e4303af75a61d3e4e4d76/packages/vite/src/node/plugins/workerImportMetaUrl.ts#L140.
//
// This class shadows the actual Worker class in the local scope, so we can
// collect the chunk URL without running the code in an actual worker (which
// would error).
class Worker {
path;
constructor(path: URL) {
this.path = path;
}
}
return new Worker(new URL("./processor.ts", import.meta.url)).path;
}; I still think Vite should natively support AudioWorklet. I know Parcel does, and there is rollup plugin that does too. |
Beta Was this translation helpful? Give feedback.
-
I think the injection of So, I think workaround for preact plugin could be to explicitly choose only export default defineConfig({
// or use "exclude" option to exclude only audioworklet related files?
plugins: [preact({ include: /\.tsx$/ })]
}) I'm not sure which plugin you're using but if its react plugin, then it could be same: Coincidentally, I also had vite project using audioworklet, so I was curious about this issue and also went back to mine. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to migrate a project using AudioWorklet written in typescript from Webpack. As noted before: #9606 (comment) the injection of Vite's client module is not compatible with the AudioWorkletGlobalScope that lacks
URL
, and as noted here: #13985 the workaround consisting in treating the worklet code as a static resource is not ideal (in my case I need both dependencies and transpilation from Typescript).Another approach would be to disable the injection of client.ts since HMR doesn't mean anything in a worklet anyway. Is there a way to selectively disable the injection of
client.ts
. Ideally, I would want to keep it for other parts of the app to leverage HMR in the UI code, for example.Beta Was this translation helpful? Give feedback.
All reactions