Registry / testing / loader-runner

loader-runner

JSON →
library4.3.2jsnpmunverified

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.

npm install loader-runner
INSTALL
IMPORT
SIG · LOADER-RUNNER
L
loader-runner
testingjavascriptv4.3.2
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.

runLoaders
import { runLoaders } from 'loader-runner'
const runLoaders = require('loader-runner')
Default import is not available; use named import. CommonJS works with require('loader-runner').runLoaders, but named import is preferred for ESM.
runLoaders
const { runLoaders } = require('loader-runner')
const runLoaders = require('loader-runner').default
Destructuring from require is correct. There is no default export.
type LoaderDefinition
import type { LoaderDefinition } from 'loader-runner'
LoaderDefinition is a TypeScript type exported for loader implementations. Use with 'import type' for type-only usage.

Demonstrates basic usage of runLoaders with a resource, loader configuration, and a callback.

import { runLoaders } from 'loader-runner'; import { readFile } from 'fs'; runLoaders({ resource: '/path/to/file.txt?query', loaders: [ { loader: '/path/to/loader.js', options: { minimize: true } } ], context: {}, readResource: readFile }, (err, result) => { if (err) { console.error(err); return; } console.log(result.result[0].toString()); console.log(result.fileDependencies); });
Debug
Known issues
breakingSince v3, the minimum Node.js version is 6.
fix
Upgrade Node.js to >=6 or stick to v2 if using older Node.
affects: >=3.0.0
breakingSince v3, callback can accept undefined as 'no result' in pitching phase, and errors are reported via callback instead of throwing.
fix
Update loader code to handle callback(err, undefined) and avoid throwing.
affects: >=3.0.0
deprecatedThe old approach of using System.import for loader loading was removed in v3.
fix
Use normal require/import for loaders.
affects: >=3.0.0
gotchaThe callback may be called twice with a rejected promise if the loader returns a promise that rejects after the callback is already invoked.
fix
Ensure loaders do not call both callback and reject a promise; favor one error handling mechanism.
affects: >=2.4.0
gotchaAlways set resourcePath, resourceQuery and resourceHash to empty string when request is empty (since v4.3.1).
fix
If relying on these properties, check that they are empty strings instead of undefined.
affects: >=4.3.1
gotchaResource string with '#' must be escaped to avoid misinterpretation (since v4.1.0).
fix
Use escape sequences for '#' in resource and loader requests.
affects: >=4.1.0
Errors
Common errors & fixes
Cannot find module 'loader-runner'
Package not installed or incorrect import path.
fix
Run 'npm install loader-runner' and use correct import: 'import { runLoaders } from "loader-runner"'.
runLoaders is not a function
Wrong import style — default import used instead of named import.
fix
Change import to: 'import { runLoaders } from "loader-runner"' or use CommonJS destructuring: 'const { runLoaders } = require("loader-runner")'.
Callback called twice with rejected promise
Loader returns a promise that rejects after calling callback.
fix
Remove callback call when using promise; use only promise resolve/reject.
TypeError: Cannot read property 'result' of undefined
Error occurred but err is null in callback if result is undefined.
fix
Check both err and result in callback; result may be undefined on error.
Upgrade
Version history
4.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
loader-runner — npm install loader-runner · libregistry