rollup-plugin-worker-factory
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -0,1 +1,8 @@ | ||
<a name="0.5.4"></a> | ||
## [0.5.4](https://github.com/brandonocasey/rollup-plugin-worker-factory/compare/v0.5.3...v0.5.4) (2021-03-11) | ||
### Bug Fixes | ||
* do not break uglify ([d282fcc](https://github.com/brandonocasey/rollup-plugin-worker-factory/commit/d282fcc)) | ||
<a name="0.5.3"></a> | ||
@@ -2,0 +9,0 @@ ## [0.5.3](https://github.com/brandonocasey/rollup-plugin-worker-factory/compare/v0.5.2...v0.5.3) (2021-03-11) |
{ | ||
"name": "rollup-plugin-worker-factory", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Bundle web workers that work in nodejs and the browser, without a separate build target.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -44,7 +44,7 @@ /* global Blob, BlobBuilder, Worker */ | ||
export const transform = function(getWorkerString, fn) { | ||
export const transform = function(code) { | ||
return `var browserWorkerPolyFill = ${browserWorkerPolyFill.toString()};\n` + | ||
'browserWorkerPolyFill(self);\n' + | ||
getWorkerString(fn); | ||
code; | ||
}; | ||
@@ -70,3 +70,13 @@ const rollup = require('rollup'); | ||
const code = output[0].code; | ||
let workerCode; | ||
// mock worker does not use a string, it uses a | ||
// real function | ||
if (factoryPath !== mock) { | ||
workerCode = `getWorkerString(function() {\n${code}\n})`; | ||
} else { | ||
workerCode = `function(self) {\n${code}\n}`; | ||
} | ||
const newCode = '' + | ||
@@ -76,3 +86,3 @@ `/* rollup-plugin-worker-factory start for ${id} */\n` + | ||
'import getWorkerString from "rollup-plugin-worker-factory/src/get-worker-string";\n' + | ||
`const workerCode = transform(getWorkerString, function(self) {\n${code}\n});\n` + | ||
`const workerCode = transform(${workerCode});\n` + | ||
'export default factory(workerCode);\n' + | ||
@@ -79,0 +89,0 @@ `/* rollup-plugin-worker-factory end for ${id} */\n`; |
@@ -72,3 +72,3 @@ class FakeWorker { | ||
export const transform = function(getWorkerString, fn) { | ||
export const transform = function(fn) { | ||
// eslint-disable-next-line | ||
@@ -75,0 +75,0 @@ return fn; |
@@ -34,7 +34,7 @@ // used to make nodejs workers behave like the browser | ||
export const transform = function(getWorkerString, fn) { | ||
export const transform = function(code) { | ||
return `const nodeWorkerPolyfill = ${nodeWorkerPolyfill.toString()};\n` + | ||
'global.self = nodeWorkerPolyfill(require("worker_threads").parentPort);\n' + | ||
getWorkerString(fn); | ||
code; | ||
}; | ||
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
25181
247