blainekasten / babel-plugin-version-transform

A Babel plugin for injecting package version numbers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-version-transform

Replaces keyword VERSION with a stringified copy of the package.json version number.

Example

Given this package.json
{
  "version": "1.0.0"
}

In

function log(data) {
  xhr({...data, version: VERSION});
}

Out

function log(data) {
  xhr({...data, version: "1.0.0"});
}

Installation

$ npm install babel-plugin-version-transform

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [
    "version-transform"
  ]
}

Via CLI

$ babel --plugins version-transform script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["version-transform"],
});

About

A Babel plugin for injecting package version numbers.


Languages

Language:JavaScript 100.0%