From 10edf068980f11b99bf2b18dce72e27065fd5727 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Sun, 12 Nov 2023 12:21:43 +0100 Subject: [PATCH] Document syntax and use .ts --- src/audio/VoiceRecording.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/audio/VoiceRecording.ts b/src/audio/VoiceRecording.ts index 4bc1524e17..53656c1a34 100644 --- a/src/audio/VoiceRecording.ts +++ b/src/audio/VoiceRecording.ts @@ -133,8 +133,13 @@ export class VoiceRecording extends EventEmitter implements IDestroyable { if (this.recorderContext.audioWorklet) { // Set up our worklet. We use this for timing information and waveform analysis: the // web audio API prefers this be done async to avoid holding the main thread with math. + + // The audioWorklet.addModule syntax is required for Webpack 5 to correctly recognise + // this as a worklet rather than an asset. This also requires the parser.javascript.worker + // configuration described in https://github.com/webpack/webpack.js.org/issues/6869. const audioWorklet = this.recorderContext.audioWorklet; - await audioWorklet.addModule(new URL("./RecorderWorklet", import.meta.url)); + await audioWorklet.addModule(new URL("./RecorderWorklet.ts", import.meta.url)); + this.recorderWorklet = new AudioWorkletNode(this.recorderContext, WORKLET_NAME); this.recorderSource.connect(this.recorderWorklet); this.recorderWorklet.connect(this.recorderContext.destination);