Registry / devops / simple-functional-loader

simple-functional-loader

JSON →
library1.2.1jsnpmunverified

Allows using a JavaScript function as a Webpack loader configuration option. Version 1.2.1 simplifies custom inline loaders by wrapping a function into a loader path and options. The package is stable but has seen infrequent updates, with v1.1.2 fixing a security issue. Most development happens in the webpack ecosystem itself.

npm install simple-functional-loader
INSTALL
IMPORT
SIG · SIMPLE-FUNCTIONAL-
S
simple-functional-loader
devopsjavascriptv1.2.1
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.

createLoader
import { createLoader } from 'simple-functional-loader'
import createLoader from 'simple-functional-loader'
The package exports createLoader as a named export, not default.
createLoader (CJS)
const { createLoader } = require('simple-functional-loader')
const createLoader = require('simple-functional-loader')
CJS destructured import is required; direct assignment gives an object.
inline loader usage
import source from '!simple-functional-loader!./file.txt'
When used as an inline loader, prepend with '!' to avoid other loaders.

Demonstrates wrapping a custom function as a webpack loader using createLoader.

// webpack.config.js const { createLoader } = require('simple-functional-loader'); module.exports = { module: { rules: [ { test: /\.txt$/, use: createLoader(function(source) { // This function runs as a webpack loader. // 'this' is the loader context. return source.toUpperCase(); }) } ] } };
Debug
Known issues
gotchaThe function passed to createLoader must be an 'ES5' function (not arrow) to access the loader context via 'this'.
fix
Use function() { ... } instead of () => { ... }.
affects: >=1.0.0
deprecatedThe package has not been updated since 2019; webpack 5 compatibility is not guaranteed.
fix
Test with webpack 5; consider using webpack's built-in loader.
affects: >=1.1.2
breakingv1.1.2 fixed a security issue; upgrade from earlier versions.
fix
Update to version >=1.1.2.
affects: <1.1.2
Errors
Common errors & fixes
TypeError: loader is not a function
Using arrow function which doesn't have 'this' binding.
fix
Replace arrow function with a regular function expression.
Module not found: Error: Can't resolve 'simple-functional-loader'
Package not installed or missing from devDependencies.
fix
npm install simple-functional-loader --save-dev
Error: Cannot find module './path/to/loader'
Using createLoader without a function argument or invalid path.
fix
Ensure createLoader receives a function as the only argument.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
webpackrequiredpeer dependency: designed to be used with webpack
Agent activity
2 hits · last 30 days
node
2
Resources
simple-functional-loader — npm install simple-functional-loader · libregistry