Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
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:
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 273 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.