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: 2 months 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 (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-21T06:24:43.000Z (over 6 years ago)
- Last Synced: 2025-04-20T09:49:05.075Z (3 months ago)
- Topics: babel, babel-plugin, babel-plugin-macros
- Language: JavaScript
- Homepage:
- Size: 130 KB
- Stars: 24
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# unique-name.macro
[](https://www.npmjs.com/package/unique-name.macro)
[](https://travis-ci.org/huchenme/unique-name.macro)
[](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.