# @node-loader/core

> The base loader for configuring NodeJS loaders

Latest version **2.0.0** (published 2021-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @node-loader/core
pnpm add @node-loader/core
yarn add @node-loader/core
bun add @node-loader/core
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-11-09 |
| First published | 2020-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=13 |
| Dependencies | 0 |
| Unpacked size | 63.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Maintainers | joeldenning |

## Links

- npm: https://www.npmjs.com/package/@node-loader/core
- Repository: https://github.com/node-loader/node-loader-core
- Homepage: https://github.com/node-loader/node-loader-core#readme
- Issues: https://github.com/node-loader/node-loader-core/issues
- npm.io page: https://npm.io/package/@node-loader/core

## Recent versions

- 2.0.0 (latest) — 2021-11-09
- 1.0.5 — 2021-05-03
- 1.0.4 — 2021-02-15
- 1.0.3 — 2020-10-06
- 1.0.2 — 2020-09-05
- 1.0.1 — 2020-09-04
- 1.0.0 — 2020-07-22

## README

# @node-loader/core

A configurable NodeJS loader that combines multiple other loaders into one.

## Motivation

[NodeJS Loaders](https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_experimental_loaders) are a new feature that allow you to configure the behavior of modules loaded with `import` or `import()`. NodeJS currently only allows you to specify a single loader when starting up Node. However, the `@node-loader/core` project allows you to combine multiple into a single loader through a configuration file.

## Installation

```sh
npm install --save @node-loader/core
```

For NodeJS@<16.12, use `@node-loader/core@1`. For NodeJS@>=16.12, use `@node-loader/core@latest`.

## Usage

Create a file `node-loader.config.js` in your current working directory:

```js
import * as importMapLoader from "@node-loader/import-maps";
import * as httpLoader from "@node-loader/http";

export default {
  loaders: [importMapLoader, httpLoader],
};
```

Then run node with the `--experimental-loader` flag:

```sh
node --experimental-loader @node-loader/core file.js
```

Your code will now run with all loaders specified in the configuration file, merged into a single loader. When multiple loaders specify the same loader hook (such as `resolve`), they will be called sequentially until one of them returns a non-default value. The order in which they are called is the same order specified in the configuration file.

## Configuration

By default, node-loader core looks for a configuration file called `node-loader.config.js` in the current working directory. To specify the file path to the configuration file, provide the `NODE_LOADER_CONFIG` environment variable:

```sh
NODE_LOADER_CONFIG=/Users/name/some/dir/node-loader.config.js --experimental-loader @node-loader/core file.js
```

Within the file, only the `loaders` property is currently respected. In the future, additional configuration options may be defined.

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