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

async-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-loader

async webpack loader

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

async-loader

A webpack loader for async source modification. Supports only Promises for now.

Usage

npm i async-loader

Documentation: Using loaders

var content = require('async?key=reportToServer!./file.txt');
// => returns what `config.reportToServer()` call resolves to

Options

key (required)

The config key whose value is an async function with signature,

function (source: string, loaderContext: Object): Promise

Example

// webpack.config.js
module.exports = {
    uploadImage: function(imageJson) {
        var image = JSON.parse(imageJson);
        return new Promise(function(resolve, reject) {
            request.get(
                'www.example.com/api' + image.src,
                function(err, response, data) {
                    if (err) reject(err);
                    else resolve(data);
                }
            );
        });
    }
};

// js
var image = require('json!async?key=updloadImage!imagesize?json!./file.png');

Why did I write this loader instead ?

We have something like makeWebpackConfig which takes in some params and returns a webpack config with plugins and loaders applied to projects of the same type which share most of the configuration. So this loader comes in handy where all you have to worry about is modifying source asynchronously and returning a Promise.

Keywords

FAQs

Package last updated on 08 May 2015

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