# threads-webpack-plugin

> ThreadsJS Webpack integration

Latest version **1.1.0** (published 2022-01-29) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install threads-webpack-plugin
pnpm add threads-webpack-plugin
yarn add threads-webpack-plugin
bun add threads-webpack-plugin
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-01-29 |
| First published | 2020-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Cloud-CNC |
| Maintainers | cloud-cnc-bot |
| Keywords | threads, threadjs, threads.js, webpack |

## Links

- npm: https://www.npmjs.com/package/threads-webpack-plugin
- Repository: https://github.com/Cloud-CNC/threads-webpack-plugin
- Homepage: https://github.com/Cloud-CNC/threads-webpack-plugin#readme
- Issues: https://github.com/Cloud-CNC/threads-webpack-plugin/issues
- npm.io page: https://npm.io/package/threads-webpack-plugin

## Dependencies (3)

- [tmp](https://npm.io/package/tmp.md) ^0.2.1
- [webpack](https://npm.io/package/webpack.md) ^4.46.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^2.0.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-01-29
- 1.0.8 — 2021-04-08
- 1.0.7 — 2020-11-25
- 1.0.5 — 2020-11-10
- 1.0.4 — 2020-10-13
- 1.0.3 — 2020-10-05
- 1.0.2 — 2020-10-05

## README

# ThreadsJS Webpack integration
[![npm](https://img.shields.io/npm/v/threads-webpack-plugin)](https://npmjs.com/package/threads-webpack-plugin)
[![tests](https://img.shields.io/github/workflow/status/Cloud-CNC/threads-webpack-plugin/CID?label=ci/cd)](https://github.com/Cloud-CNC/threads-webpack-plugin/actions)
[![last commit](https://img.shields.io/github/last-commit/Cloud-CNC/threads-webpack-plugin)](https://github.com/Cloud-CNC/threads-webpack-plugin/commits/master)

[ThreadsJS](https://threads.js.org) integration for [Webpack](https://webpack.js.org). If you're using Rollup, you may want to check out [rollup-plugin-threads](https://github.com/cloud-cnc/rollup-plugin-threads) (Basically does the same thing as this plugin but for Rollup).

# Features
* Written in modern TypeScript
* Uses Rollup for TS compilation
* Thoroughly commented

# Usage
## Entry
```Javascript
//Imports
import {BlobWorker, spawn, Thread} from 'threads';
import WorkerText from './worker'; //May have to @ts-ignore if using TypeScript

//Create a **BLOB WORKER**
const worker = await spawn(BlobWorker.fromText(WorkerText));

console.log(worker.echo('Hello World!')); //Worker received: Hello World!

//Destroy the worker
Thread.terminate(worker);
```

## Worker
```Javascript
//Imports
import {expose} from 'threads';

//Worker functions
const worker = {
  echo(input)
  {
    return `Worker received: ${input}`;
  }
};

//Expose worker
expose(worker);
```

## Webpack Config
```Javascript
//Export
module.exports = {
  //Point at your normal file (The plugin will take care of loading the worker)
  entry: 'src/index.js',
  module: {
    rules: [
      {
        test: /worker\.js$/,
        loader: 'threads-webpack-plugin',
        options: {
          //Webpack child bundler options
        }
      }
    ]
  }
};
```

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