# babel-plugin-date-fns

> > :warning: The current version (2.x) supports date-fns v2. If you are using v1, please use [1.x](https://github.com/date-fns/babel-plugin-date-fns/tree/v1).

Latest version **2.0.0** (published 2019-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-date-fns
pnpm add babel-plugin-date-fns
yarn add babel-plugin-date-fns
bun add babel-plugin-date-fns
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-10-25 |
| First published | 2016-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 93 |
| Author | Brian Ng |
| Maintainers | existentialism |
| Keywords | babel-plugin, cherry-pick, date-fns |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-date-fns
- Repository: https://github.com/date-fns/babel-plugin-date-fns
- Homepage: https://github.com/date-fns/babel-plugin-date-fns#readme
- Issues: https://github.com/date-fns/babel-plugin-date-fns/issues
- npm.io page: https://npm.io/package/babel-plugin-date-fns

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

- 2.0.0 (latest) — 2019-10-25
- 1.0.0 — 2019-10-25
- 0.2.1 — 2018-07-24
- 0.2.0 — 2018-05-25
- 0.1.0 — 2016-11-20

## README

# babel-plugin-date-fns

> :warning: The current version (2.x) supports date-fns v2. If you are using v1, please use [1.x](https://github.com/date-fns/babel-plugin-date-fns/tree/v1).

## Install

```shell
$ npm i --save date-fns
$ npm i --save-dev babel-plugin-date-fns
```

## Example

Transforms

```js
import { differenceInYears, format, formatDistance } from "date-fns";
```

roughly to

```js

import differenceInYears from 'date-fns/differenceInYears';
import format from "date-fns/format";
import formatDistance from "date-fns/formatDistance";
```

## Usage

### .babelrc

```json
{
  "plugins": ["date-fns"],
  "presets": ["@babel/preset-env"]
}
```

### Webpack

```js
module: {
  rules: [
    {
      test: /\.m?js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env'],
          plugins: ['date-fns']
        }
      }
    }
  ]
}
```

## Thanks

Heavily inspired by [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash)
and [babel-plugin-recharts](https://github.com/recharts/babel-plugin-recharts).

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