rollup-plugin-off-main-thread
Advanced tools
Comparing version 1.1.0 to 1.1.1-0
32
index.js
@@ -20,14 +20,18 @@ /** | ||
const defaultOpts = { | ||
// A string containing the EJS template for the amd loader. If `undefined`, | ||
// OMT will use `loader.ejs`. | ||
loader: readFileSync(join(__dirname, "/loader.ejs"), "utf8"), | ||
// 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_. | ||
useEval: false, | ||
// Unique marker that temporarily injected to mark Worker imports. Should be | ||
// unique enough to not appear in (minified) code accidentally. | ||
// marker: "_____TROLOLOLOL", | ||
// Regexp for detecting worker calls | ||
// A RegExp to find `new Workers()` calls. The second capture group _must_ | ||
// capture the provided file name without the quotes. | ||
workerRegexp: /new Worker\((["'])(.+?)\1\)/g, | ||
// Regexp that finds the new chunk filename in between the markers after | ||
// Rollup has done its thing. | ||
// filenameRegexp: /(["'])([./].+?(?:\.js)?)\1/, | ||
// Function name to use instead of AMD’s `define` | ||
amdFunctionName: "define" | ||
// Function name to use instead of AMD’s `define`. | ||
amdFunctionName: "define", | ||
// 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. | ||
prependLoader: (chunk, workerFiles) => | ||
chunk.isEntry || workerFiles.includes(chunk.facadeModuleId) | ||
}; | ||
@@ -85,4 +89,8 @@ | ||
const workerFileEndIndex = match.index + match[0].length - ")".length; | ||
ms.overwrite(workerFileStartIndex, workerFileEndIndex, `import.meta.ROLLUP_CHUNK_URL_${chunkRefId}`); | ||
ms.overwrite( | ||
workerFileStartIndex, | ||
workerFileEndIndex, | ||
`import.meta.ROLLUP_CHUNK_URL_${chunkRefId}` | ||
); | ||
} | ||
@@ -121,3 +129,3 @@ | ||
// Prepend loader if it’s an entry point or a worker file | ||
if (chunk.isEntry || workerFiles.includes(chunk.facadeModuleId)) { | ||
if (opts.prependLoader(chunk, workerFiles)) { | ||
ms.prepend(opts.loader); | ||
@@ -124,0 +132,0 @@ } |
{ | ||
"name": "rollup-plugin-off-main-thread", | ||
"version": "1.1.0", | ||
"version": "1.1.1-0", | ||
"description": "Use Rollup with workers and ES6 modules today.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,6 +45,5 @@ # rollup-plugin-off-main-thread | ||
- `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_. | ||
- `marker`: A string that is temporarily injected to mark `new Worker()` calls. It’s only purpose is to be unique enough that the string sequence can’t appear by coincidence in ohter places. The default should be fine 99% of the time. | ||
- `workerRegexp`: A RegExp to find `new Workers()` calls. The second capture group _must_ capture the provided file name without the quotes. | ||
- `filenameRegexp`: A RegExp that finds the file name after Rollup has transformed dynamic imports. | ||
- `amdFunctionName`: Function name to use instead of AMD’s `define` | ||
- `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. | ||
@@ -51,0 +50,0 @@ [when workers]: https://dassur.ma/things/when-workers |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
55728
799
0
2
55