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/b

Usage no npm install needed!

<script type="module">
  import babelPluginId from 'https://cdn.skypack.dev/babel-plugin-id';
</script>

README

babel-plugin-id

Build Status codecov styled with prettier npm (scoped)

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:

{
  "plugins": ["id"]
}

Example

// 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:

{
  "plugins": [["id", { "fn": "t" }]]
}

This will evaluate functions named t.

Example

// Input:
const text = t("Translate me");

// Output:
const text = "Translate me";

License

MIT