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

apply-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apply-loader - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

29

index.js

@@ -5,3 +5,3 @@ var loaderUtils = require("loader-utils");

module.exports.pitch = function applyLoader(remainingRequest) {
var query = loaderUtils.parseQuery(this.query);
var opts = loaderUtils.getOptions(this) || {};
var args = [];

@@ -11,19 +11,16 @@

// apply?config=key => sourceFn(require('webpack.config').key)
if (typeof query.config === "string") {
if (!(query.config in this.options))
throw new Error("apply-loader: '"+query.config+"' property not present in webpack config");
args.push(this.options[query.config]);
if (typeof opts.config === "string") {
// apply?config=key => sourceFn(require('webpack.config').key)
if (!(opts.config in this.options)) {
throw new Error("apply-loader: '"+opts.config+"' property not present in webpack config");
}
args.push(this.options[opts.config]);
} else if (Array.isArray(opts.args)) {
// apply?args[]=1&args[]=2 => sourceFn(1, 2)
args.push.apply(args, opts.args);
} else if (opts.obj) {
// apply?{obj: {a: 1, b: 2}} => sourceFn({a: 1, b:2})
args.push(opts.obj);
}
// apply?{obj: {a: 1, b: 2}} => sourceFn({a: 1, b:2})
if (query.obj) {
args.push(query.obj);
}
// apply?args[]=1&args[]=2 => sourceFn(1, 2)
if (Array.isArray(query.args)) {
args.push.apply(args, query.args);
}
return [

@@ -30,0 +27,0 @@ "var req = require(",

{
"name": "apply-loader",
"version": "1.0.0",
"version": "2.0.0",
"description": "Apply loader for webpack",

@@ -11,2 +11,9 @@ "main": "index.js",

},
"maintainers": [
{
"name": "mogelbrod",
"email": "victor@hallberg.cc"
}
],
"homepage": "https://github.com/mogelbrod/apply-loader#readme",
"repository": {

@@ -16,5 +23,8 @@ "type": "git",

},
"bugs": {
"url": "https://github.com/mogelbrod/apply-loader/issues"
},
"license": "MIT",
"dependencies": {
"loader-utils": "~0.2.6"
"loader-utils": "^1.1.0"
},

@@ -21,0 +31,0 @@ "keywords": [

@@ -7,4 +7,6 @@ # apply loader for webpack

The `apply` loader can be used to execute a JavaScript function exported, optionally with arguments, and export the returned value.
The `apply` loader can be used to execute an exported JavaScript function (optionally with arguments) and export the returned value.
It will attempt to call the `default` export if defined, falling back to the basic export (i.e. `module.exports`).
``` javascript

@@ -24,4 +26,20 @@ // Call with multiple arguments

## Webpack 2 configuration
``` javascript
use: [{
loader: 'apply-loader',
options: {
// => sourceFn({a: 1}, true)
args: [ {a: 1}, true ]
// => sourceFn({a: 1})
obj: {a: 1}
// => sourceFn(require('webpack.config').customConfig)
config: 'customConfig'
}
}
```
## License
MIT (http://www.opensource.org/licenses/mit-license.php)
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