semantic-release-bundle
v1.2.0
Published
A package designed to replace package versions in JavaScript bundles
Downloads
1
Maintainers
Readme
semantic-release-bundle
A package designed to replace package versions in JavaScript bundles.
Table of Contents
Motivation
Sometimes, using a universal semantic-release plugin like @google/semantic-release-replace-plugin
or @semantic-release/exec
suffices to update versions in arbitrary files. However, for UI bundles, this task becomes challenging. This package provides strategies for comfortable version management, specifically tailored to JS bundles.
Requirements
To use library you need to have node and npm installed in your machine:
- node
>=10
- npm
>=6
Package is continuously tested on darwin, linux and win32 platforms. All active and maintenance LTS node releases are supported.
Installation
To install the library run the following command
npm i --save-dev semantic-release-bundle
Usage
Configure the plugin in the semantic-release configuration file:
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"semantic-release-bundle",
{
"type": "q-manifest"
}
]
]
}
Configuration
Customizable options include:
type
: required, Strategy to use, 'q-manifest' or 'vite-define'packageJSONPath
: Specify the path to the package.json file (default is 'package.json')directory
: list of bundle directories (default is ['dist'])updatePackageJSON
: Update version in package.json file
Strategy-related options:
buildDirectory
: For 'q-manifest', specifies the build directory ('build' by default).versionKey
: For 'vite-define', specifies the key in define config ('VERSION' by default).
Preconditions
Before using the package, ensure the following assumptions work for your project:
- package.json stores the old (unchanged) version during the verifyconditions step.
- Bundle (with the unchanged version) is already generated at the moment of the verifyconditions step.
- Version change should occur during the prepare step.
How it works
The package scans the bundle for the previous version, which is obtained from package.json. It then replaces all occurrences of the matched pattern with the new version. q-manifest
q-manifest is a strategy suitable for bundles generated by the qwik framework. Look for a sample in tests/bundles/tastoria folder. semantic-release-bundle only modifies parts that import the package.json file because it observes the q-manifest file.
If you use Vite/Rollup for bundle generation but not the qwik framework, you can generate a similar q-manifest.json file and utilize this strategy.
Contribute
Make the changes to the code and tests. Then commit to your branch. Be sure to follow the commit message conventions. Read Contributing Guidelines for details.