Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Importing an audio worklet #3804

Unanswered
NickClark asked this question in Q&A
Discussion options

When importing worklet code, I'm using the ?url query string to get the URL as recommended in the documentation. This creates two problems:

  1. 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.
  2. 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?

You must be logged in to vote

Replies: 2 comments

Comment options

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

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /