0.0.6 • Published 11 months ago

babel-plugin-attributes v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

babel-plugin-attributes

A Babel plugin that enhances JavaScript functions with custom attributes, providing additional metadata and annotations.

Node.js CI

Example

Input

$attr(middlewares(['auth']), can(['create']))
function routeHandler(req, res) {
    // some code
}

Output

function routeHandler(req, res) {
    // some code
}

(function () {
  const attributes = new Map();
  attributes.set(middlewares, middlewares(['auth']));
  attributes.set(can, can(['create']));
  routeHandler.__attributes__ = attributes;
})();

Installation

You can install babel-plugin-attributes using npm:

npm install babel-plugin-attributes --save-dev

Plugin Options

OptionDescriptionDefault Value
attrFunctionNameValid function name to be used to identify attribute calls$attr
attrPropertyNameValid object property name that is used to store attribute map__attributes__

Usage

{
  "plugins": [
    "babel-plugin-attributes",
    {
      "attrFunctionName": "$attr",
      "attrPropertyName": "__attributes__"
    }
  ]
}
0.0.6

11 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago