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

worker-plugin

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

worker-plugin - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

dist/symbol.js

17

dist/loader.js

@@ -6,2 +6,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var WebWorkerTemplatePlugin = _interopDefault(require('webpack/lib/webworker/WebWorkerTemplatePlugin'));
var WORKER_PLUGIN_SYMBOL = _interopDefault(require('./symbol.js'));

@@ -42,5 +43,19 @@ /**

};
var pluginOptions = compilerOptions.plugins.find(function (p) { return p[WORKER_PLUGIN_SYMBOL]; }).options;
var plugins = (pluginOptions.plugins || []).map(function (plugin) {
if (typeof plugin !== 'string') {
return plugin;
}
var workerCompiler = this._compilation.createChildCompiler(NAME, workerOptions, compilerOptions.plugins);
var found = compilerOptions.plugins.find(function (p) { return p.constructor.name === plugin; });
if (!found) {
console.warn(("Warning (workerize-loader): Plugin \"" + plugin + "\" is not found."));
}
return found;
});
var workerCompiler = this._compilation.createChildCompiler(NAME, workerOptions, plugins);
new WebWorkerTemplatePlugin(workerOptions).apply(workerCompiler);

@@ -47,0 +62,0 @@ new SingleEntryPlugin(this.context, request, options.name).apply(workerCompiler);

@@ -5,2 +5,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var ParserHelpers = _interopDefault(require('webpack/lib/ParserHelpers'));
var WORKER_PLUGIN_SYMBOL = _interopDefault(require('./symbol.js'));

@@ -27,2 +28,3 @@ /**

this.options = options || {};
this[WORKER_PLUGIN_SYMBOL] = true;
};

@@ -29,0 +31,0 @@

2

package.json
{
"name": "worker-plugin",
"version": "2.0.1",
"version": "3.0.0",
"description": "Webpack plugin to bundle Workers automagically.",

@@ -5,0 +5,0 @@ "main": "dist/worker-plugin.js",

@@ -65,4 +65,31 @@ <p align="center">

## Options & Plugins
By default, `WorkerPlugin` doesn't run any of your configured Webpack plugins when bundling worker code - this avoids running things like `html-webpack-plugin` twice. For cases where it's necessary to apply a plugin to Worker code, use the `plugins` option.
Here you can specify the names of plugins to "copy" from your existing Webpack configuration, or provide specific plugins to apply only to worker code:
```js
module.exports = {
<...>
plugins: [
// an example of a plugin already being used:
new SomeExistingPlugin({ <...> }),
new WorkerPlugin({
plugins: [
// A string here will copy the named plugin from your configuration:
'SomeExistingPlugin',
// Or you can specify a plugin directly, only applied to Worker code:
new SomePluginToApplyOnlyToWorkers({ <...> })
]
})
]
<...>
}
```
## License
Apache-2.0

@@ -19,2 +19,3 @@ /**

import ParserHelpers from 'webpack/lib/ParserHelpers';
import WORKER_PLUGIN_SYMBOL from './symbol';

@@ -28,2 +29,3 @@ const NAME = 'WorkerPlugin';

this.options = options || {};
this[WORKER_PLUGIN_SYMBOL] = true;
}

@@ -30,0 +32,0 @@

@@ -20,2 +20,3 @@ /**

import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
import WORKER_PLUGIN_SYMBOL from './symbol';

@@ -43,3 +44,15 @@ const NAME = 'WorkerPluginLoader';

const workerCompiler = this._compilation.createChildCompiler(NAME, workerOptions, compilerOptions.plugins);
const pluginOptions = compilerOptions.plugins.find(p => p[WORKER_PLUGIN_SYMBOL]).options;
const plugins = (pluginOptions.plugins || []).map(plugin => {
if (typeof plugin !== 'string') {
return plugin;
}
const found = compilerOptions.plugins.find(p => p.constructor.name === plugin);
if (!found) {
console.warn(`Warning (workerize-loader): Plugin "${plugin}" is not found.`);
}
return found;
});
const workerCompiler = this._compilation.createChildCompiler(NAME, workerOptions, plugins);
(new WebWorkerTemplatePlugin(workerOptions)).apply(workerCompiler);

@@ -46,0 +59,0 @@ (new SingleEntryPlugin(this.context, request, options.name)).apply(workerCompiler);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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