Skip to content

Commit

Permalink
Update docs and cut release 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Smona committed Jul 22, 2023
1 parent 1ee86bf commit 717d22c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 },
},
],
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
},
};
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 717d22c

Please sign in to comment.