rollup-plugin-web-worker-loader
Advanced tools
Comparing version 0.2.0 to 0.3.1
{ | ||
"name": "rollup-plugin-web-worker-loader", | ||
"version": "0.2.0", | ||
"version": "0.3.1", | ||
"description": "Rollup plugin to handle Web Workers", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -140,3 +140,3 @@ const path = require('path'); | ||
} | ||
}) | ||
}); | ||
}, | ||
@@ -143,0 +143,0 @@ |
@@ -7,2 +7,13 @@ export function createInlineWorkerFactory(fn, sourcemap = null) { | ||
const lines = body.split('\n').map(line => line.substring(4) + '\n'); | ||
if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') { | ||
/* node.js */ | ||
const Worker = require('worker_threads').Worker; // eslint-disable-line | ||
const concat = lines.join('\n'); | ||
return function WorkerFactory(options) { | ||
return new Worker(concat, Object.assign({}, options, { eval: true })); | ||
}; | ||
} | ||
/* browser */ | ||
const blob = new Blob(lines, { type: 'application/javascript' }); | ||
@@ -16,5 +27,13 @@ const url = URL.createObjectURL(blob); | ||
export function createURLWorkerFactory(url) { | ||
if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') { | ||
/* node.js */ | ||
const Worker = require('worker_threads').Worker; // eslint-disable-line | ||
return function WorkerFactory(options) { | ||
return new Worker(url, options); | ||
}; | ||
} | ||
/* browser */ | ||
return function WorkerFactory(options) { | ||
return new Worker(url, options); | ||
} | ||
}; | ||
} |
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
35121
287