@@ -28,11 +28,7 @@ import { UPDATE_EVENT } from "../stores/AsyncStore";
28
28
import { createAudioContext } from "./compat" ;
29
29
import { FixedRollingArray } from "../utils/FixedRollingArray" ;
30
30
import { clamp } from "../utils/numbers" ;
31
- // This import is needed for dead code analysis but not actually used because the
32
- // built-in worker / worklet handling in Webpack 5 only supports static paths
33
- // @ts -ignore no-unused-locals
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- import mxRecorderWorkletPath from "./RecorderWorklet" ;
31
+ import recorderWorkletFactory from "./recorderWorkletFactory" ;
36
32
37
33
const CHANNELS = 1 ; // stereo isn't important
38
34
export const SAMPLE_RATE = 48000 ; // 48khz is what WebRTC uses. 12khz is where we lose quality.
@@ -133,12 +129,7 @@ export class VoiceRecording extends EventEmitter implements IDestroyable {
133
129
if ( this . recorderContext . audioWorklet ) {
134
130
// Set up our worklet. We use this for timing information and waveform analysis: the
135
131
// web audio API prefers this be done async to avoid holding the main thread with math.
136
-
137
- // The audioWorklet.addModule syntax is required for Webpack 5 to correctly recognise
138
- // this as a worklet rather than an asset. This also requires the parser.javascript.worker
139
- // configuration described in https://github.com/webpack/webpack.js.org/issues/6869.
140
- const audioWorklet = this . recorderContext . audioWorklet ;
141
- await audioWorklet . addModule ( new URL ( "./RecorderWorklet.ts" , import . meta. url ) ) ;
132
+ await recorderWorkletFactory ( this . recorderContext ) ;
142
133
143
134
this . recorderWorklet = new AudioWorkletNode ( this . recorderContext , WORKLET_NAME ) ;
144
135
this . recorderSource . connect ( this . recorderWorklet ) ;
0 commit comments