Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oreqizer/babel-plugin-id
A tiny babel plugin that evaluates a given function to its argument. 🔧
https://github.com/oreqizer/babel-plugin-id
Last synced: 21 days ago
JSON representation
A tiny babel plugin that evaluates a given function to its argument. 🔧
- Host: GitHub
- URL: https://github.com/oreqizer/babel-plugin-id
- Owner: oreqizer
- Created: 2018-07-12T14:35:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-04T10:07:34.000Z (about 4 years ago)
- Last Synced: 2024-09-14T00:13:37.650Z (about 2 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# babel-plugin-id
[![Build Status](https://travis-ci.org/oreqizer/babel-plugin-id.svg?branch=master)](https://travis-ci.org/oreqizer/babel-plugin-id)
[![codecov](https://codecov.io/gh/oreqizer/babel-plugin-id/branch/master/graph/badge.svg)](https://codecov.io/gh/oreqizer/babel-plugin-id)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![npm (scoped)](https://img.shields.io/npm/v/babel-plugin-id.svg)](https://www.npmjs.com/package/babel-plugin-id)Literally all it does is it evaluates a function to its argument. Useful for **translation collection**, for example.
Function name defaults to `__`.
## Setup
Just add `id` to the list of babel plugins, e.g. to `.babelrc`:
```json
{
"plugins": ["id"]
}
```### Example
```js
// Input:
const text = __("Translate me");// Output:
const text = "Translate me";
```## Config
To change the function name, add an object with the `fn` property to your config:
```json
{
"plugins": [["id", { "fn": "t" }]]
}
```This will evaluate functions named `t`.
### Example
```js
// Input:
const text = t("Translate me");// Output:
const text = "Translate me";
```## License
MIT