# loader-of-loader

> A loader to load and run another loader asynchronously

Latest version **1.0.3** (published 2022-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install loader-of-loader
pnpm add loader-of-loader
yarn add loader-of-loader
bun add loader-of-loader
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-02-02 |
| First published | 2022-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | otakustay |
| Maintainers | otakustay |
| Keywords | webpack, loader |

## Links

- npm: https://www.npmjs.com/package/loader-of-loader
- npm.io page: https://npm.io/package/loader-of-loader

## Dependencies (1)

- [loader-runner](https://npm.io/package/loader-runner.md) ^4.2.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2022-02-02
- 1.0.2 — 2022-02-02
- 1.0.1 — 2022-02-01
- 1.0.0 — 2022-02-01

## README

# loader-of-loader

This is a webpack loader designed to load and run another loader but very limited implemented to satisfy author's need.

By loading and running another loader from this, you can unlock features like:

1. Resolve a loader's path asynchronously.
2. Load an ESM loader without webpack's current support of ESM loaders.
3. Prepare options aynchronously.

## Install

```
npm install -D loader-of-loader
```

## Usage

The only option is `resolveLoader`, which returns a `Promise` resolve to structure like this:

```ts
interface LoaderResolveResult {
    loader: string; // The path of loader
    type?: 'module' | 'commonjs' | undefined; // The module type
    options: any; // Options pass to actual loader
}
```

Configure this in webpack like:

```js
{
    module: {
        rules: [
            {
                test: /\.js$/,
                use: [
                    {
                        loader: 'loader-of-loader',
                        options: {
                            resolveLoader: async () => {
                                const config = await getBabelConfigFromRemote();
                                return {
                                    loader: 'babel-loader',
                                    options: config,
                                };
                            },
                        },
                    },
                ],
            },
        ],
    },
}
```

---
_Source: https://npm.io/package/loader-of-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
