threads-plugin
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "threads-plugin", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Webpack plugin to bundle threads.js workers automagically.", | ||
@@ -5,0 +5,0 @@ "main": "dist/threads-plugin.js", |
@@ -103,2 +103,7 @@ <p align="center"> | ||
## Electron | ||
To use standard Node packages in Electron web workers, make sure Node integration in workers is [turned on](https://www.electronjs.org/docs/tutorial/multithreading) | ||
and the plugin option [target](#target) is set to `electron-node-worker`. | ||
## Options | ||
@@ -157,4 +162,21 @@ | ||
### `target` | ||
Due to the way webpack works, it may be necessary to change the target environment of the workers. | ||
Possible values: | ||
- `electron-node-worker` use this if you are using Electron and compiling web workers that have node integration enabled. See [Electron Multithreading](https://www.electronjs.org/docs/tutorial/multithreading). | ||
Default value: `undefined` | ||
Example with electron node workers: | ||
```js | ||
new ThreadsPlugin({ | ||
target: 'electron-node-worker' | ||
}) | ||
``` | ||
## License | ||
Apache-2.0 |
@@ -21,2 +21,3 @@ /** | ||
import FetchCompileWasmTemplatePlugin from 'webpack/lib/web/FetchCompileWasmTemplatePlugin'; | ||
import NodeTargetPlugin from 'webpack/lib/node/NodeTargetPlugin'; | ||
import WORKER_PLUGIN_SYMBOL from './symbol'; | ||
@@ -61,2 +62,5 @@ | ||
workerCompiler.context = this._compiler.context; | ||
if (pluginOptions.target === "electron-node-worker") { | ||
new NodeTargetPlugin().apply(workerCompiler); | ||
} | ||
(new WebWorkerTemplatePlugin(workerOptions)).apply(workerCompiler); | ||
@@ -63,0 +67,0 @@ (new FetchCompileWasmTemplatePlugin({ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
343409
4084
181