{"id":20552,"library":"simple-functional-loader","title":"simple-functional-loader","description":"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.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/lovetingyuan/simple-functional-loader","tags":["javascript","webpack","loader","function","inline","functional"],"install":[{"cmd":"npm install simple-functional-loader","lang":"bash","label":"npm"},{"cmd":"yarn add simple-functional-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add simple-functional-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: designed to be used with webpack","package":"webpack","optional":false}],"imports":[{"note":"The package exports createLoader as a named export, not default.","wrong":"import createLoader from 'simple-functional-loader'","symbol":"createLoader","correct":"import { createLoader } from 'simple-functional-loader'"},{"note":"CJS destructured import is required; direct assignment gives an object.","wrong":"const createLoader = require('simple-functional-loader')","symbol":"createLoader (CJS)","correct":"const { createLoader } = require('simple-functional-loader')"},{"note":"When used as an inline loader, prepend with '!' to avoid other loaders.","wrong":null,"symbol":"inline loader usage","correct":"import source from '!simple-functional-loader!./file.txt'"}],"quickstart":{"code":"// webpack.config.js\nconst { createLoader } = require('simple-functional-loader');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.txt$/,\n        use: createLoader(function(source) {\n          // This function runs as a webpack loader.\n          // 'this' is the loader context.\n          return source.toUpperCase();\n        })\n      }\n    ]\n  }\n};","lang":"javascript","description":"Demonstrates wrapping a custom function as a webpack loader using createLoader."},"warnings":[{"fix":"Use function() { ... } instead of () => { ... }.","message":"The function passed to createLoader must be an 'ES5' function (not arrow) to access the loader context via 'this'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test with webpack 5; consider using webpack's built-in loader.","message":"The package has not been updated since 2019; webpack 5 compatibility is not guaranteed.","severity":"deprecated","affected_versions":">=1.1.2"},{"fix":"Update to version >=1.1.2.","message":"v1.1.2 fixed a security issue; upgrade from earlier versions.","severity":"breaking","affected_versions":"<1.1.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Replace arrow function with a regular function expression.","cause":"Using arrow function which doesn't have 'this' binding.","error":"TypeError: loader is not a function"},{"fix":"npm install simple-functional-loader --save-dev","cause":"Package not installed or missing from devDependencies.","error":"Module not found: Error: Can't resolve 'simple-functional-loader'"},{"fix":"Ensure createLoader receives a function as the only argument.","cause":"Using createLoader without a function argument or invalid path.","error":"Error: Cannot find module './path/to/loader'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}