# @justia/babel-preset

> A Babel preset for transforming your JavaScript for Justia

Latest version **4.0.3** (published 2025-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @justia/babel-preset
pnpm add @justia/babel-preset
yarn add @justia/babel-preset
bun add @justia/babel-preset
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2025-07-23 |
| First published | 2019-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Diego Miguel <digznav@gmail.com> |
| Maintainers | justiauser, mayrop, digznav |
| Keywords | babel, es2015, es6, javascript, justia |

## Links

- npm: https://www.npmjs.com/package/@justia/babel-preset
- Repository: https://github.com/justia/front-end-projects
- Homepage: https://github.com/justia/front-end-projects/tree/master/packages/babel-preset#readme
- Issues: https://github.com/justia/front-end-projects/issues
- npm.io page: https://npm.io/package/@justia/babel-preset

## Dependencies (6)

- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.9.0
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.9.4
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.12.1
- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.8.3
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.12.1
- [@babel/plugin-transform-numeric-separator](https://npm.io/package/@babel/plugin-transform-numeric-separator.md) ^7.23.3

## 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

- 4.0.3 (latest) — 2025-07-23
- 4.0.2 — 2025-07-08
- 4.0.1 — 2024-07-17
- 4.0.0 — 2024-05-21
- 3.0.4 — 2023-11-13
- 3.0.3 — 2023-02-15
- 3.0.2 — 2023-02-09
- 3.0.1 — 2023-01-16
- 3.0.0 — 2022-11-28
- 2.0.1 — 2022-11-04
- 2.0.0 — 2022-05-31
- 1.1.0 — 2020-11-04
- 1.0.0 — 2020-10-29
- 0.5.0 — 2020-10-29
- 0.4.1 — 2020-09-17
- … 6 more at https://npm.io/package/@justia/babel-preset/versions

## README

<!-- UPDATE-PACKAGES:START - Do not remove or modify this section -->

# `@justia/babel-preset` ![version 4.0.3](https://img.shields.io/badge/version-4.0.3-blue?style=flat-square) <!-- omit from toc -->

> A Babel preset for transforming your JavaScript for Justia

<!-- UPDATE-PACKAGES:END -->

- [Install](#install)
- [Usage](#usage)
    - [Via `.babelrc` or `package.json` (Recommended)](#via-babelrc-or-packagejson-recommended)
    - [Via CLI](#via-cli)
    - [Via Node API](#via-node-api)
- [Configure `@babel/preset-env`](#configure-babelpreset-env)
    - [`targets`](#targets)
    - [`debug`](#debug)
    - [`useBuiltIns`](#usebuiltins)
    - [`corejs`](#corejs)
    - [`include`](#include)
    - [`exclude`](#exclude)
- [React Development Mode](#react-development-mode)
- [Specifying module transforms](#specifying-module-transforms)
- [Usage with TypeScript](#usage-with-typescript)

---

## Install

```shell
npm install --save-dev @justia/babel-preset
```

## Usage

### Via `.babelrc` or `package.json` (Recommended)

**`.babelrc`**

```json
{
  "presets": [
    "@justia/babel-preset"
  ]
}
```

### Via CLI

```shell
babel script.js --presets @justia/babel-preset
```

### Via Node API

```javascript
require('@babel/core').transform('code', {
    presets: ['@justia/babel-preset']
});
```

## Configure [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env)

This module uses [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) to target specific environments.

### `targets`

Please refer to [`@babel/preset-env#targets`](https://babeljs.io/docs/en/babel-preset-env#targets) for a list of available options.

For a list of browsers please see [browserslist](https://github.com/browserslist/browserslist).

You may override our default list of targets by providing your own `targets` key.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "targets": {
          "chrome": 100,
          "ios": 15.6
        }
      }
    ]
  ]
}
```

The following transpiles only for Node v8.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "targets": {
          "node": 8
        }
      }
    ]
  ]
}
```

### `debug`

You may override our default debug option by providing your own `debug` key.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "debug": true
      }
    ]
  ]
}
```

Outputs to `console.log` the polyfills and transform plugins enabled by [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) and, if applicable, which one of your targets that needed it.

### `useBuiltIns`

Use the `useBuiltIns` key to configure how [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) handles polyfills. This defaults to `"entry"` to allow importing [`core-js`](https://github.com/zloirock/core-js) in entrypoint and use [`browserslist`](https://github.com/browserslist/browserslist) to select polyfills.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "useBuiltIns": "usage"
      }
    ]
  ]
}
```

When either the `"usage"` or `"entry"` options are used, [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) will add direct references to [`core-js`](https://github.com/zloirock/core-js) modules as bare imports (or requires). This means [`core-js`](https://github.com/zloirock/core-js) will be resolved relative to the file itself and needs to be accessible.

Since [`@babel/polyfill`](https://babeljs.io/docs/en/babel-polyfill) was deprecated in `7.4.0`, we recommend directly adding [`core-js`](https://github.com/zloirock/core-js) and setting the version via the [`corejs`](#corejs) option.

```shell
npm install core-js@3 --save
```

Read more info about the specific details of each option in the [`@babel/preset-env` official page](https://babeljs.io/docs/en/babel-preset-env#usebuiltins).

### `corejs`

This option only has an effect when used alongside `"useBuiltIns": "usage"` or `"useBuiltIns": "entry"`, and ensures [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) injects the correct imports for your [`core-js`](https://github.com/zloirock/core-js) version. The valid values for this are `2`, `3` or `{ version: 2 | 3, proposals: boolean }`, defaults to `3`.

By default, only polyfills for stable ECMAScript features are injected: if you want to polyfill them, you have three different options:

- when using `useBuiltIns: "entry"`, you can directly import a [proposal polyfill](https://github.com/zloirock/core-js/tree/master/packages/core-js/proposals): `import "core-js/proposals/string-replace-all"`.
- when using `useBuiltIns: "usage"` you have two different alternatives:
    - Set the [`shippedProposals`](https://babeljs.io/docs/en/babel-preset-env#shippedproposals) option to `true`. This will enable polyfills and transforms for proposal which have already been shipped in browsers for a while.
    - use `"corejs": { "version": 3, "proposals": true }`. This will enable polyfill-ing of every proposal supported by [`core-js`](https://github.com/zloirock/core-js).

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "corejs": 3
      }
    ]
  ]
}
```

### `include`

Please refer to [`@babel/preset-env#include`](https://babeljs.io/docs/en/babel-preset-env#include) for a list of available options.

You may define an array of plugins to always include using the `include` key.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "include": [
          "plugin-transform-spread",
          "es.map",
          "es.set",
          "or es.object.assign"
        ]
      }
    ]
  ]
}
```

### `exclude`

Please refer to [`@babel/preset-env#exclude`](https://babeljs.io/docs/en/babel-preset-env#exclude) for a list of available options.

You may define an array of plugins to always exclude/remove using the `exclude` key.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "exclude": [
          "transform-async-to-generator",
          "transform-template-literals",
          "transform-regenerator"
        ]
      }
    ]
  ]
}
```

## React Development Mode

When `process.env.NODE_ENV` is `'development'`, [the `development` mode will be set for `@babel/preset-react`](https://babeljs.io/docs/en/babel-preset-react#development).

You may override our default development option by providing your own boolean `development` key.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "development": false
      }
    ]
  ]
}
```

## Specifying module transforms

You can use the `modules` option to enable transformation of modules given to this preset:

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "modules": "auto"
      }
    ]
  ]
}
```

Both `true` and the option default `auto` will not transform modules if ES6 module syntax is already supported by the environment, or `"commonjs"` otherwise. `false` will not transform modules.

## Usage with TypeScript

You can enable this option with the `typescript` key. Make sure you have a `tsconfig.json` file at the root directory.

```json
{
  "presets": [
    [
      "@justia/babel-preset",
      {
        "typescript": true
      }
    ]
  ]
}
```

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