From 717d22c6582b9500df4ac55ae4bbc4a802ef256c Mon Sep 17 00:00:00 2001 From: Mel Bourgeois Date: Fri, 21 Jul 2023 22:10:31 -0500 Subject: [PATCH] Update docs and cut release 1.3.0 --- README.md | 52 +++++++++++++++++++++++++--------------------------- package.json | 4 ++-- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 71c8e37..dede230 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # faust-loader -Import [Faust](https://faust.grame.fr/) .dsp files, and get back an AudioWorklet or ScriptProcessor node. +Webpack loader for the [Faust language](https://faust.grame.fr/). Import `.dsp` files, and get back an AudioWorklet or ScriptProcessor node. This loader is confirmed working with Faust v2.30.5, but may break on lower versions. [Help is wanted](https://github.com/Smona/faust-loader/issues/1) on @@ -24,16 +24,13 @@ yarn add faust-loader standardized-audio-context ```ts module: { rules: [ - // ... + // ... { test: /\.dsp$/, use: [ { loader: "faust-loader", - options: { - outputPath: "processors", // Where the generated files will be placed relative to the output directory - publicPath: "/build/processors" // Where the generated files will be served from - } + options: { inline: true }, }, ], }, @@ -62,6 +59,28 @@ browsers that don't support AudioWorklets, as well as interoperate seamlessly wi Because of this, you have to use an AudioContext from `standardized-audio-context` when creating Faust nodes. If you want to use this loader with a vanilla AudioContext, please submit an issue or PR! +## Loader Options + +### `inline = false` + +Switch between inline and split file modes. + +Inline mode embeds the AudioWorkletProcessor and WASM code in the Javascript bundle as base64 data URLs . This allows for single-file builds, and supports code splitting via dynamic imports (`await import()`). + +Split file mode (the default) emits separate files for the AudioWorkletProcessor and WASM in a specified `outputPath`, fetching them over the network from `publicPath`. + +Inline mode is recommended, since it's more flexible and easier to configure, and will likely become the default in a future release. However, emitting and fetching separate files may make sense if you are already serving webpack static assets and want to keep your main bundle size as small as possible. + +### `outputPath = ""` + +Where the generated files should be placed relative to the output directory in split file mode. Ignored when `inline: true`. + +### `publicPath = "/"` + +What base path the generated files will be served from in split file mode. Ignored when `inline: true`. + +## Examples + ### With Typescript Typescript definitions are available for the imported modules. To automatically get the correct types when you @@ -96,24 +115,3 @@ async function connectSynth() { connect(node, context.destination); } ``` - -### With Next.js - -```js -// next.config.js - -module.exports = { - webpack: (config, { isServer }) => { - config.module.rules.push({ - test: [/\.dsp$/], - loader: "faust-loader", - options: { - outputPath: `${isServer ? "../" : ""}static/processors/`, - publicPath: "/_next/static/processors", - }, - }); - - return config; - }, -}; -``` diff --git a/package.json b/package.json index 26e6c02..c700e70 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "faust-loader", - "version": "1.2.3", + "version": "1.3.0", "main": "dist/faustLoader.js", "types": "dist/faustLoader.d.ts", "scripts": { "prepare": "install-peers", - "build": "tsc --project tsconfig.build.json", + "build": "tsc --project tsconfig.build.json || true", "serve": "webpack serve -c test/webpack.config.js", "test": "webpack build -c test/webpack.config.js", "prepublishOnly": "yarn build && yarn test"