# neutrino-middleware-compile-loader

> Neutrino middleware for compiling JavaScript using Babel configuration

Latest version **7.4.0** (published 2017-12-04) · MPL-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install neutrino-middleware-compile-loader
pnpm add neutrino-middleware-compile-loader
yarn add neutrino-middleware-compile-loader
bun add neutrino-middleware-compile-loader
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 7.4.0 |
| Published | 2017-12-04 |
| First published | 2017-03-09 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3905 |
| Author | Eli Perelman |
| Maintainers | eliperelman |
| Keywords | neutrino, neutrino-middleware, compile, babel |

## Links

- npm: https://www.npmjs.com/package/neutrino-middleware-compile-loader
- Repository: https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-compile-loader
- Homepage: https://neutrino.js.org
- Issues: https://github.com/mozilla-neutrino/neutrino-dev/issues
- npm.io page: https://npm.io/package/neutrino-middleware-compile-loader

## Dependencies (4)

- [deepmerge](https://npm.io/package/deepmerge.md) ^1.5.2
- [babel-core](https://npm.io/package/babel-core.md) ^6.26.0
- [babel-merge](https://npm.io/package/babel-merge.md) ^1.1.0
- [babel-loader](https://npm.io/package/babel-loader.md) ^7.1.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 7.4.0 (latest) — 2017-12-04
- 7.3.3 — 2017-11-21
- 7.3.2 — 2017-11-13
- 7.3.1 — 2017-11-06
- 7.3.0 — 2017-10-31
- 7.2.3 — 2017-10-26
- 7.2.1 — 2017-10-21
- 7.1.10 — 2017-10-18
- 7.1.3 — 2017-10-17
- 7.1.2 — 2017-10-13
- 7.1.1 — 2017-10-10
- 7.1.0 — 2017-10-06
- 7.0.2 — 2017-10-03
- 7.0.1 — 2017-09-28
- 7.0.0 — 2017-09-28
- … 28 more at https://npm.io/package/neutrino-middleware-compile-loader/versions

## README

# Neutrino Compile Loader Middleware

`neutrino-middleware-compile-loader` is Neutrino middleware for compiling source code with Babel.

[![NPM version][npm-image]][npm-url]
[![NPM downloads][npm-downloads]][npm-url]
[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]

## Requirements

- Node.js v6.10+
- Yarn or npm client
- Neutrino v7

## Installation

`neutrino-middleware-compile-loader` can be installed via the Yarn or npm clients.

#### Yarn

```bash
❯ yarn add neutrino-middleware-compile-loader
```

#### npm

```bash
❯ npm install --save neutrino-middleware-compile-loader
```

## Usage

`neutrino-middleware-compile-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package
and plug it into Neutrino:

```js
// Using function middleware format

const compile = require('neutrino-middleware-compile-loader');

neutrino.use(compile, {
  include: [],
  exclude: [],
  babel: {}
});
```

```js
// Using object or array middleware format

module.exports = {
  use: [
    ['neutrino-middleware-compile-loader', {
      include: [],
      exclude: [],
      babel: {}
    }]
  ]
};
```

- `include` should be an array of paths to include in the compilation. Maps to Webpack's
[`Rule.include`](https://webpack.js.org/configuration/module/#rule-include)
- `exclude` should be an array of paths to exclude from the compilation. Maps to Webpack's
[`Rule.exclude`](https://webpack.js.org/configuration/module/#rule-exclude)
- `babel` is a [Babel configuration object](https://babeljs.io/docs/usage/api/#options), consumed by babel-loader. Use
this to set properties such as `presets`, `plugins`, and `env`.

## Merging Babel Configuration

This package also exposes a function for merging Babel configurations. This comes from
the [babel-merge](https://www.npmjs.com/package/babel-merge) package.

```js
const { merge } = require('neutrino-middleware-compile-loader');

const together = merge(
  {
    presets: [
      ['babel-preset-env', {
        targets: {
          browsers: ['latest 1 Chrome']
        }
      }]
    ]
  },
  {
    presets: [
      ['babel-preset-env', {
        targets: {
          browsers: ['latest 1 Firefox']
        }
      }]
    ]
  }
);

console.log(together);

// Logs:
{
  presets: [
    ['babel-preset-env', {
      targets: {
        browsers: [
          'latest 1 Chrome',
          'latest 1 Firefox'
        ]
      }
    }]
  ]
}
```

## Customization

`neutrino-middleware-compile-loader` creates some conventions to make overriding the configuration easier once you are
ready to make changes.

### Rules

The following is a list of rules and their identifiers which can be overridden:

| Name | Description | Environments and Commands |
| --- | --- | --- |
| `compile` | Compiles JS and JSX files from the `src` directory using Babel. Contains a single loader named `babel`. | all |

## Contributing

This middleware is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo
containing all resources for developing Neutrino and its core presets and middleware. Follow the
[contributing guide](https://neutrino.js/contributing) for details.

[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-compile-loader.svg
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-compile-loader.svg
[npm-url]: https://npmjs.org/package/neutrino-middleware-compile-loader
[spectrum-image]: https://withspectrum.github.io/badge/badge.svg
[spectrum-url]: https://spectrum.chat/neutrino

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