Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
rollup-plugin-worker-factory
Advanced tools
Bundle web workers that work in nodejs and the browser, without a separate build target.
npm i -D rollup-plugin-worker-factory
--experimental-workers
include rollup-plugin-worker-factory in your rollup plugins array for a build:
const worker = require('rollup-plugin-worker-factory');
...
plugins: [
worker()
]
...
When you want to include a worker in your code prefix the file with worker!
:
import SomeWorker from "worker!./src/some-worker.js";
Your worker should run without exporting any code and use the global self
variable to interact with the worker API. worker_threads.parentPort
for node has been slightly modified so that their API more closely matches web workers in the browser and will also be available on the global self
.
const someDependency = require('../some-dep');
const whoKnows = require('who-knows');
self.addEventListener('message', function(e) {
const foo = someDependency(e);
self.postMessage(whoKnows(foo));
});
on
to addEventListener
on worker objectsoff
to removeEventListener
on worker objectspostMessage
so that the message sent is included as a value for a data
key on an object as this is how the browser works with postMessage.addEventListener
to on
on worker objectsremoveEventListener
to on
on worker objectsobjURL
propertyAn array of rollup plugins to bundle the web workers with, you will probably want:
Default: 'universal'
The type of factory to build, can be 'node', 'mock', 'browser', or 'universal'.
browser will only work in the browser
node will only work in node
mock will work everywhere but runs on the same thread
universal will work on the browser or node depending on available apis
FAQs
Bundle web workers that work in nodejs and the browser, without a separate build target.
The npm package rollup-plugin-worker-factory receives a total of 145 weekly downloads. As such, rollup-plugin-worker-factory popularity was classified as not popular.
We found that rollup-plugin-worker-factory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.