Registry / web-framework / apply-loader

apply-loader

JSON →
library2.0.0jsnpmunverified

Webpack loader that executes an exported JavaScript function (default or module.exports) with optional arguments and returns the exported value. Current stable version 2.0.0, maintained as of last release. Unlike conventional loaders that transform source code, it invokes the target module as a factory function. Supports both webpack 1 and 2 configuration syntax.

npm install apply-loader
INSTALL
IMPORT
SIG · APPLY-LOADER
A
apply-loader
web-frameworkjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

apply-loader
const apply = require('apply-loader');
import apply from 'apply-loader';
This is a webpack loader, not a JS module. It is used in webpack config, not imported in application code.
Use in webpack config (webpack 1)
{ test: /\.js$/, loader: 'apply-loader?args[]=1' }
{ test: /\.js$/, use: 'apply-loader?args[]=1' }
In webpack 1, use 'loader'; in webpack 2+, use 'use' with options object.
Use in webpack config (webpack 2+)
{ test: /\.js$/, use: { loader: 'apply-loader', options: { args: [1] } } }
{ test: /\.js$/, loader: 'apply-loader?args[]=1' }
Webpack 2+ prefers options object over query string.

Configures apply-loader to invoke greet.js with arguments and export the return value.

// webpack.config.js module.exports = { entry: './app.js', output: { filename: 'bundle.js' }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'apply-loader', options: { args: ['hello', { foo: 'bar' }] } } } ] } }; // greet.js (target module) function greet(greeting, options) { return `${greeting} ${options.foo}`; } module.exports = greet; // Result: bundle exports 'hello bar'
Debug
Known issues
breakingv2.0.0 stops triggering loader-utils deprecation warning
fix
Upgrade to v2.0.0
affects: <2.0.0
deprecatedQuery string syntax (e.g., ?args[]=1) is deprecated in webpack 2+
fix
Use options object in webpack config
affects: >=2.0.0
gotchaIf the target module exports both default and named, apply-loader calls the default export first
fix
Ensure your module exports a function as default or module.exports
affects: >=1.0.0
Errors
Common errors & fixes
Error: apply-loader?args[]=1: The provided value "args[]" is not a valid request parameter.
Using query string syntax with webpack 2+ without proper encoding or using 'use' array incorrectly.
fix
Use options object: { loader: 'apply-loader', options: { args: [1] } }
Module build failed: TypeError: apply is not a function
Target module does not export a function (exports an object, string, etc.).
fix
Ensure the target module exports a function: module.exports = function(...) {...}
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
apply-loader — npm install apply-loader · libregistry