Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huchenme/unique-name.macro
Babel Plugin Macro to generate unique name
https://github.com/huchenme/unique-name.macro
babel babel-plugin babel-plugin-macros
Last synced: 14 days ago
JSON representation
Babel Plugin Macro to generate unique name
- Host: GitHub
- URL: https://github.com/huchenme/unique-name.macro
- Owner: huchenme
- Created: 2018-10-09T09:38:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-21T06:24:43.000Z (almost 6 years ago)
- Last Synced: 2024-10-12T23:34:31.880Z (24 days ago)
- Topics: babel, babel-plugin, babel-plugin-macros
- Language: JavaScript
- Homepage:
- Size: 130 KB
- Stars: 24
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# unique-name.macro
[![NPM Version](https://img.shields.io/npm/v/unique-name.macro.svg?style=flat-square)](https://www.npmjs.com/package/unique-name.macro)
[![Travis (.org)](https://img.shields.io/travis/huchenme/unique-name.macro.svg?style=flat-square)](https://travis-ci.org/huchenme/unique-name.macro)
[![Babel Macro](https://img.shields.io/badge/babel--macro-%F0%9F%8E%A3-f5da55.svg?style=flat-square)](https://github.com/kentcdodds/babel-plugin-macros)This is a [babel-macros](https://github.com/kentcdodds/babel-macros) to generate unique name.
## Usage
With babel-macros and this package installed, you can use it like this.
```javascript
import uniqueName from 'unique-name.macro'const disabledClass = uniqueName() // or const disabledClass = uniqueName('disabledClass')
```The above snippet will be compiled in build time:
```javascript
import uniqueName from 'unique-classname.macro'const disabledClass = 'disabledClass-1u6x1nq'
```## Note
The unique name is based on file path and variable name, it will remain the same as long as you don't move the file or rename the variable.