# audio-worklet-plugin

> Webpack plugin to bundle CSS Worklet automagically.

Latest version **0.0.5** (published 2020-03-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install audio-worklet-plugin
pnpm add audio-worklet-plugin
yarn add audio-worklet-plugin
bun add audio-worklet-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2020-03-26 |
| First published | 2020-03-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 41.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | The Chromium Authors |
| Maintainers | bennetthardwick |
| Keywords | css, plugin, thread, webpack, worklet |

## Links

- npm: https://www.npmjs.com/package/audio-worklet-plugin
- Repository: https://github.com/earnubs/css-worklet-plugin
- Homepage: https://github.com/earnubs/css-worklet-plugin#readme
- Issues: https://github.com/earnubs/css-worklet-plugin/issues
- npm.io page: https://npm.io/package/audio-worklet-plugin

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2020-03-26

## README

# A Webpack Plugin to automatically bundle & compile CSS Worklets.</p>


### Features

Automatically compiles modules loaded in Web Workers:

```js
CSS.paintWorklet.addModule('./foo.js');
                           ^^^^^^^^^^
                           gets bundled using webpack
```

The best part? That worklet constructor works just fine without bundling turned on too.

## Installation

```sh
npm install -D css-worklet-plugin
```

Then drop it into your **webpack.config.js:**

```diff
+ const CssWorkletPlugin = require('css-worklet-plugin');

module.exports = {
  <...>
  plugins: [
+    new CssWorkletPlugin()
  ]
  <...>
}
```

## Usage

**worklet.js**: _(our worklet module)_

```js
class PaintStuff {
 ...
}

registerPaint('paint-stuff', PaintStuff);
```

**main.js**: _(our demo, on the main thread)_

```js
CSS.paintWorklet.addModule('./worklet.js')
```

main.css:
```css
.foo {
  background-image: paint(paint-stuff);
}
```

## Options

In most cases, no options are necessary to use CssWorkletPlugin.

### `globalObject`

CssWorkletPlugin will warn you if your Webpack configuration has `output.globalObject` set to `window`, since doing so breaks Hot Module Replacement in web workers.

If you're not using HMR and want to disable this warning, pass `globalObject:false`:

```js
new CssWorkletPlugin({
  // disable warnings about "window" breaking HMR:
  globalObject: false
})
```

To configure the value of `output.globalObject` for CssWorkletPlugin's internal Webpack Compiler, set `globalObject` to any String:

```js
new CssWorkletPlugin({
  // use "self" as the global object when receiving hot updates.
  globalObject: 'self' // <-- this is the default value
})
```

### `plugins`

By default, `CssWorkletPlugin` doesn't run any of your configured Webpack plugins when bundling worker code - this avoids running things like `html-webpack-plugin` twice. For cases where it's necessary to apply a plugin to Worklet code, use the `plugins` option.

Here you can specify the names of plugins to "copy" from your existing Webpack configuration, or provide specific plugins to apply only to worklet code:

```js
module.exports = {
  <...>
  plugins: [
    // an example of a plugin already being used:
    new SomeExistingPlugin({ <...> }),

    new CssWorkletPlugin({
      plugins: [
        // A string here will copy the named plugin from your configuration:
        'SomeExistingPlugin',
        
        // Or you can specify a plugin directly, only applied to Worker code:
        new SomePluginToApplyOnlyToWorkers({ <...> })
      ]
    })
  ]
  <...>
}
```

## License

Apache-2.0

---
_Source: https://npm.io/package/audio-worklet-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
