1. rollup-plugin-git-version
RollupJS plugin to include the git rev in the version of package.json
rollup-plugin-git-version
Package: rollup-plugin-git-version
Created by: IvanSanchez
Last modified: Sun, 26 Jun 2022 13:59:07 GMT
Version: 0.3.1
License: Beerware
Downloads: 1,390
Repository: git+https://gitlab.com/IvanSanchez/rollup-plugin-git-version.git

Install

npm install rollup-plugin-git-version
yarn add rollup-plugin-git-version

rollup-plugin-git-version

Rollup plugin to include the git rev in the version of package.json.

If you develop some software which is bundled with RollupJS, how many times have
you done something like...?

import { version } from '../package.json';

And how many times have you wished that the current git branch and revision would
be included in that version string?

If the answer is "more than zero", this RollupJS plugin is for you.

So if your package.json contains something like...

{
	version: "major.minor.patch"
	...

Then, by using this plugin, when doing an import { version } from '../package.json';,
version will have a value like "major.minor.patch+branchname.revision". This
is in compliance with the semantic versioning standard about
build metadata.

For example, if your package.json contains version: "1.2.3", then the value
for the version value inside your rolled-up code will not be "1.2.3", but
instead "1.2.3+master.890abc".

Installation

 yarnpkg add --dev rollup-plugin-git-version

or

 npm install --save-dev rollup-plugin-git-version

Usage

As with any other Rollup plugin, just add it to the plugins option in your RollupJS config:

 // In rollup.config.js
import rollupGitVersion from 'rollup-plugin-git-version'

export default {
	entry: 'src/index.js',
	dest: 'dist/my-lib.js',
	plugins: [
		rollupGitVersion()
	]
};

This plugin accepts the same options as @rollup/plugin-json.

If you use this plugin together with @rollup/plugin-json,
please be aware that both plugins might try to fight for the file. You can use the exclude option of @rollup/plugin-json, e.g.:

 // In rollup.config.js
import rollupGitVersion from 'rollup-plugin-git-version'

export default {
	entry: 'src/index.js',
	dest: 'dist/my-lib.js',
	plugins: [
		rollupGitVersion(),
		json({ exclude: 'package.json' })
	]
};

License

"THE BEER-WARE LICENSE":
[email protected] wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code