Add custom loader for recorder worklet

This commit is contained in:
Johannes Marbach 2023-11-18 21:37:30 +01:00
parent 8dbefcc589
commit e2fdddaa1f
2 changed files with 61 additions and 13 deletions

View file

@ -272,19 +272,6 @@ module.exports = (env, argv) => {
// optimised, so there is little to gain by us uglifying it.
/olm[\\/](javascript[\\/])?olm\.js$/,
],
parser: {
javascript: {
worker: [
// Special syntax for loading audio worklets as documented in
// https://github.com/webpack/webpack.js.org/issues/6869. Note
// that this only works when using a URL as argument to the
// addModule call.
"*context.audioWorklet.addModule()",
"*audioWorklet.addModule()",
"...", // The defaults
],
},
},
rules: [
useHMR && {
test: /devcss\.ts$/,
@ -493,6 +480,22 @@ module.exports = (env, argv) => {
outputPath: ".",
},
},
{
// Ideally we should use the built-in worklet support in Webpack 5 with the syntax
// described in https://github.com/webpack/webpack.js.org/issues/6869. However, this
// doesn't currently appear to work with our public path setup. So we handle this
// with a custom loader instead.
test: /RecorderWorklet\.ts$/,
type: "javascript/auto",
use: [
{
loader: path.resolve("./recorder-worklet-loader.js"),
},
{
loader: "babel-loader",
},
],
},
{
// This is from the same place as the encoderWorker above, but only needed
// for Safari support.