New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-web-worker-loader

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-web-worker-loader - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

2

package.json
{
"name": "rollup-plugin-web-worker-loader",
"version": "1.1.2",
"version": "1.1.3",
"description": "Rollup plugin to handle Web Workers",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -13,3 +13,3 @@ function decodeBase64(base64, enableUnicode) {

export function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
function createURL(base64, sourcemapArg, enableUnicodeArg) {
var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;

@@ -21,6 +21,11 @@ var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg;

var blob = new Blob([body], { type: 'application/javascript' });
var url = URL.createObjectURL(blob);
return URL.createObjectURL(blob);
}
export function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
var url;
return function WorkerFactory(options) {
url = url || createURL(base64, sourcemapArg, enableUnicodeArg);
return new Worker(url, options);
};
}
import {funcToSource} from '\0rollup-plugin-web-worker-loader::helper::funcToSource';
export function createInlineWorkerFactory(fn, sourcemapArg) {
function createURL(fn, sourcemapArg) {
var lines = funcToSource(fn, sourcemapArg);
var blob = new Blob(lines, { type: 'application/javascript' });
var url = URL.createObjectURL(blob);
return URL.createObjectURL(blob);
}
export function createInlineWorkerFactory(fn, sourcemapArg) {
var url;
return function WorkerFactory(options) {
url = url || createURL(fn, sourcemapArg);
return new Worker(url, options);
};
}

@@ -8,4 +8,2 @@ const fs = require('fs');

const options = require('./plugin/options');
module.exports = function workerLoaderPlugin(config = null) {

@@ -35,17 +33,64 @@ const targetPlatform = config && config.hasOwnProperty('targetPlatform') ? config.targetPlatform : 'auto';

const pluginConfig = {
options: null,
basePath: null,
skipPlugins: new Set([
'liveServer',
'serve',
'livereload',
]),
}
return {
name: 'rollup-plugin-web-worker-loader',
options(optionsArg) {
options(optionsArg, pluginConfig);
options(options) {
if (!projectOptions) {
projectOptions = Object.assign({}, options);
if (options.plugins && options.plugins.length) {
const plugins = [];
options.plugins.forEach(plugin => {
if (skipPlugins.has(plugin.name)) return;
plugins.push(plugin);
});
projectOptions.plugins = plugins;
const cwd = process.cwd();
if (typeof options.input === 'string') {
try {
const entry = require.resolve(options.input, { paths: [cwd] });
basePath = path.dirname(entry);
} catch (e) { /* EMPTY */ }
} else if (Array.isArray(options.input)) {
let componentCount = Number.MAX_SAFE_INTEGER;
let shortestPath = null;
for (let i = 0, n = options.input.length; i < n; ++i) {
try {
const entry = require.resolve(options.input[i], { paths: [cwd] });
const entryPath = path.dirname(entry);
const components = entryPath.split(path.sep);
if (components.length < componentCount) {
componentCount = components.length;
shortestPath = entryPath;
}
} catch (e) { /* EMPTY */ }
}
basePath = shortestPath;
} else {
const keys = Object.keys(options.input);
let componentCount = Number.MAX_SAFE_INTEGER;
let shortestPath = null;
for (let i = 0, n = keys.length; i < n; ++i) {
const input = options.input[keys[i]];
try {
const entry = require.resolve(input, { paths: [cwd] });
const entryPath = path.dirname(entry);
const components = entryPath.split(path.sep);
if (components.length < componentCount) {
componentCount = components.length;
shortestPath = entryPath;
}
} catch (e) { /* EMPTY */ }
}
basePath = shortestPath;
}
if (!basePath) {
basePath = '.';
}
}
}
return null;
},

@@ -52,0 +97,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc