-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
-
When importing worklet code, I'm using the ?url query string to get the URL as recommended in the documentation. This creates two problems:
- If the worklet is sufficiently small, then it is inlined. This is undesirable. Even if I wanted to adjust my CSP rules to allow it, it incurs unnecessary security risks. A way of forcing a url would be desireable.
- Even if I lower the inline limits to force a url, I get an untranspiled result.
Is this a bug? Or am I missing the correct way to do this?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
I'm running into the same problem.
but as you stated, you are using ?url, which resolves static files and static files are not transpiled (because you don't need to transpile images for example)
I think vitejs is missing a proper way to handle worklets as of now
Beta Was this translation helpful? Give feedback.
All reactions
-
Use ?worker and ?url together:
import workletURL from "./audio-worklet?worker&url";
Vite will transpile your TypeScript file to a separate .js module and the workletURL will be a URL targeting that .js file.
Beta Was this translation helpful? Give feedback.