Gathering detailed insights and metrics for @surma/rollup-plugin-off-main-thread
Gathering detailed insights and metrics for @surma/rollup-plugin-off-main-thread
Gathering detailed insights and metrics for @surma/rollup-plugin-off-main-thread
Gathering detailed insights and metrics for @surma/rollup-plugin-off-main-thread
Use Rollup with workers and ES6 modules today.
npm install @surma/rollup-plugin-off-main-thread
Typescript
Module System
Node Version
NPM Version
JavaScript (91.73%)
EJS (6.81%)
Dockerfile (1.47%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
313 Stars
292 Commits
32 Forks
4 Watchers
9 Branches
15 Contributors
Updated on Apr 20, 2025
Latest Version
2.2.3
Package Id
@surma/rollup-plugin-off-main-thread@2.2.3
Size
16.58 kB
NPM Version
7.18.1
Node Version
16.4.0
Published on
Nov 02, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Use Rollup with workers and ES6 modules today.
$ npm install --save @surma/rollup-plugin-off-main-thread
Workers are JavaScript’s version of threads. Workers are important to use as the main thread is already overloaded, especially on slower or older devices.
This plugin takes care of shimming module support in workers and allows you to use new Worker()
.
OMT is the result of merging loadz0r and workz0r.
I set up a gist to show a full setup with OMT.
1// rollup.config.js 2import OMT from "@surma/rollup-plugin-off-main-thread"; 3 4export default { 5 input: ["src/main.js"], 6 output: { 7 dir: "dist", 8 // You _must_ use either “amd” or “esm” as your format. 9 // But note that only very few browsers have native support for 10 // modules in workers. 11 format: "amd" 12 }, 13 plugins: [OMT()] 14};
In your project's code use a module-relative path via new URL
to include a Worker:
1const worker = new Worker(new URL("worker.js", import.meta.url), {
2 type: "module"
3});
This will just work.
If required, the plugin also supports plain literal paths:
1const worker = new Worker("./worker.js", { type: "module" });
However, those are less portable: in Rollup they would result in module-relative path, but if used directly in the browser, they'll be relative to the document URL instead.
Hence, they're deprecated and new URL
pattern is encouraged instead for portability.
If your worker constructor doesn't match workerRegexp
(see options below), you might find it easier to import the worker as a URL. In your project's code:
1import workerURL from "omt:./worker.js";
2import paintWorkletURL from "omt:./paint-worklet.js";
3
4const worker = new Worker(workerURL, { name: "main-worker" });
5CSS.paintWorklet.addModule(paintWorkletURL);
./worker.js
and ./paint-worklet.js
will be added to the output as chunks.
1{ 2 // ... 3 plugins: [OMT(options)]; 4}
loader
: A string containing the EJS template for the amd loader. If undefined
, OMT will use loader.ejs
.useEval
: Use fetch()
+ eval()
to load dependencies instead of <script>
tags and importScripts()
. This is not CSP compliant, but is required if you want to use dynamic imports in ServiceWorker.workerRegexp
: A RegExp to find new Workers()
calls. The second capture group must capture the provided file name without the quotes.amdFunctionName
: Function name to use instead of AMD’s define
.prependLoader
: A function that determines whether the loader code should be prepended to a certain chunk. Should return true if the load is suppsoed to be prepended.urlLoaderScheme
: Scheme to use when importing workers as URLs. If undefined
, OMT will use "omt"
.License Apache-2.0
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 6/15 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More