# uid.macro

> babel macro that inputs unique ids in compilation phase

Latest version **0.1.0** (published 2021-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install uid.macro
pnpm add uid.macro
yarn add uid.macro
bun add uid.macro
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-02-08 |
| First published | 2021-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | ^12 |
| Dependencies | 2 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jedrzej Ginter |
| Maintainers | jedrzejginter |
| Keywords | babel, babel-macro, macro, macros, uid, uuid, uid.macro, uuid.macro, id.macro |

## Links

- npm: https://www.npmjs.com/package/uid.macro
- Repository: https://github.com/jedrzejginter/uid.macro
- Homepage: https://github.com/jedrzejginter/uid.macro#readme
- Issues: https://github.com/jedrzejginter/uid.macro/issues
- npm.io page: https://npm.io/package/uid.macro

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^8.0.0
- [randomstring](https://npm.io/package/randomstring.md) ^1.1.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-02-08
- 0.1.0-rc.1 — 2021-01-22

## README

# uid.macro

Insert [`uuid` v4](https://www.npmjs.com/package/uuid) or [`random string`](https://www.npmjs.com/package/randomstring) at build-time with [`babel macros`](https://github.com/kentcdodds/babel-plugin-macros).

## Installation

```
npm install --save-dev uid.macro
```

You'll also need to install and configure [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros) if you haven't already.

## Usage

- `uuid` version 4

  ```js
  import { uuid } from 'uid.macro';
  const value = uuid();

  ↓ ↓ ↓ ↓ ↓ ↓

  const value = '44a79dfb-6805-46c7-bd79-04420e7d6bcc';
  ```

- random string (optional length)

  ```js
  import { str } from 'uid.macro';
  const value = str();
  const other = str(7);

  ↓ ↓ ↓ ↓ ↓ ↓

  const value = 'XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT';
  const other = 'xqm5wXX';
  ```

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