Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loader-runner

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loader-runner

Runs (webpack) loaders

  • 4.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is loader-runner?

The loader-runner npm package is designed to run webpack loaders in a node.js environment without requiring the webpack itself. It allows developers to test and run individual loaders, simulating the webpack compilation process. This can be particularly useful for loader development, testing, and debugging.

What are loader-runner's main functionalities?

Running a single loader

This feature allows running a single loader on a specified file. In the code sample, `runLoaders` is used to apply a CSS loader to a CSS file, demonstrating how to process a resource with specific loader configurations.

const runLoaders = require('loader-runner').runLoaders;

runLoaders({
  resource: 'path/to/file.css',
  loaders: [{ loader: 'path/to/css-loader' }],
  context: { minimize: true },
  readResource: fs.readFile.bind(fs)
}, (err, result) => {
  if(err) {
    return console.error(err);
  }
  console.log(result);
});

Running multiple loaders

This feature demonstrates how to chain multiple loaders, in this case, an ESLint loader followed by a Babel loader, to process a JavaScript file. It showcases the ability to use loader-runner for complex processing involving multiple steps.

const runLoaders = require('loader-runner').runLoaders;

runLoaders({
  resource: 'path/to/file.js',
  loaders: [
    { loader: 'path/to/babel-loader', options: { presets: ['@babel/preset-env'] } },
    { loader: 'path/to/eslint-loader' }
  ],
  context: {},
  readResource: fs.readFile.bind(fs)
}, (err, result) => {
  if(err) {
    return console.error(err);
  }
  console.log(result);
});

Other packages similar to loader-runner

Keywords

FAQs

Package last updated on 12 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc