{"id":20193,"library":"loader-runner","title":"loader-runner","description":"Runs (webpack) loaders as an independent module without webpack itself. Current stable version is 4.3.2, released in 2021 with performance improvements. Minimal release cadence: roughly one version per year. Key differentiator: it allows running loaders in isolation for testing or custom build pipelines. Supports Node.js >=6.11.5 and is ESM/CJS compatible. Lightweight, focuses solely on loader execution logic with hooks for resource processing.","status":"active","version":"4.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/webpack/loader-runner","tags":["javascript","webpack","loader"],"install":[{"cmd":"npm install loader-runner","lang":"bash","label":"npm"},{"cmd":"yarn add loader-runner","lang":"bash","label":"yarn"},{"cmd":"pnpm add loader-runner","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is not available; use named import. CommonJS works with require('loader-runner').runLoaders, but named import is preferred for ESM.","wrong":"const runLoaders = require('loader-runner')","symbol":"runLoaders","correct":"import { runLoaders } from 'loader-runner'"},{"note":"Destructuring from require is correct. There is no default export.","wrong":"const runLoaders = require('loader-runner').default","symbol":"runLoaders","correct":"const { runLoaders } = require('loader-runner')"},{"note":"LoaderDefinition is a TypeScript type exported for loader implementations. Use with 'import type' for type-only usage.","wrong":null,"symbol":"type LoaderDefinition","correct":"import type { LoaderDefinition } from 'loader-runner'"}],"quickstart":{"code":"import { runLoaders } from 'loader-runner';\nimport { readFile } from 'fs';\n\nrunLoaders({\n  resource: '/path/to/file.txt?query',\n  loaders: [\n    {\n      loader: '/path/to/loader.js',\n      options: { minimize: true }\n    }\n  ],\n  context: {},\n  readResource: readFile\n}, (err, result) => {\n  if (err) {\n    console.error(err);\n    return;\n  }\n  console.log(result.result[0].toString());\n  console.log(result.fileDependencies);\n});","lang":"typescript","description":"Demonstrates basic usage of runLoaders with a resource, loader configuration, and a callback."},"warnings":[{"fix":"Upgrade Node.js to >=6 or stick to v2 if using older Node.","message":"Since v3, the minimum Node.js version is 6.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update loader code to handle callback(err, undefined) and avoid throwing.","message":"Since v3, callback can accept undefined as 'no result' in pitching phase, and errors are reported via callback instead of throwing.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use normal require/import for loaders.","message":"The old approach of using System.import for loader loading was removed in v3.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Ensure loaders do not call both callback and reject a promise; favor one error handling mechanism.","message":"The callback may be called twice with a rejected promise if the loader returns a promise that rejects after the callback is already invoked.","severity":"gotcha","affected_versions":">=2.4.0"},{"fix":"If relying on these properties, check that they are empty strings instead of undefined.","message":"Always set resourcePath, resourceQuery and resourceHash to empty string when request is empty (since v4.3.1).","severity":"gotcha","affected_versions":">=4.3.1"},{"fix":"Use escape sequences for '#' in resource and loader requests.","message":"Resource string with '#' must be escaped to avoid misinterpretation (since v4.1.0).","severity":"gotcha","affected_versions":">=4.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install loader-runner' and use correct import: 'import { runLoaders } from \"loader-runner\"'.","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'loader-runner'"},{"fix":"Change import to: 'import { runLoaders } from \"loader-runner\"' or use CommonJS destructuring: 'const { runLoaders } = require(\"loader-runner\")'.","cause":"Wrong import style — default import used instead of named import.","error":"runLoaders is not a function"},{"fix":"Remove callback call when using promise; use only promise resolve/reject.","cause":"Loader returns a promise that rejects after calling callback.","error":"Callback called twice with rejected promise"},{"fix":"Check both err and result in callback; result may be undefined on error.","cause":"Error occurred but err is null in callback if result is undefined.","error":"TypeError: Cannot read property 'result' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}