Skip to content

Commit a08b8ad

Browse files
authored
Improve compatibility between CJS and ESM modules (#67)
* Improve compatibility between CJS and ESM modules Changes how we export the library to rely in named exports. * v5.0.0-0 * v5.0.0-1
1 parent e7310df commit a08b8ad

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install --save-dev git-revision-webpack-plugin
1717
Then, simply configure it as a plugin in the webpack config:
1818

1919
```javascript
20-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
20+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
2121

2222
module.exports = {
2323
plugins: [new GitRevisionPlugin()],
@@ -70,7 +70,7 @@ Example using the [DefinePlugin](https://webpack.js.org/plugins/define-plugin/#u
7070

7171
```javascript
7272
const webpack = require('webpack')
73-
const GitRevisionPlugin = require('git-revision-webpack-plugin')
73+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
7474
const gitRevisionPlugin = new GitRevisionPlugin()
7575

7676
module.exports = {
@@ -95,7 +95,7 @@ The plugin requires no configuration by default, but it is possible to configure
9595
If you need [lightweight tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_lightweight_tags) support, you may turn on `lightweightTags` option in this way:
9696

9797
```javascript
98-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
98+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
9999

100100
module.exports = {
101101
plugins: [
@@ -111,7 +111,7 @@ module.exports = {
111111
If you need branch name support, you may turn on `branch` option in this way:
112112

113113
```javascript
114-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
114+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
115115

116116
module.exports = {
117117
plugins: [
@@ -129,7 +129,7 @@ To change the default `git` command used to read the value of `COMMITHASH`.
129129
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
130130

131131
```javascript
132-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
132+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
133133

134134
module.exports = {
135135
plugins: [
@@ -147,7 +147,7 @@ To change the default `git` command used to read the value of `VERSION`.
147147
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
148148

149149
```javascript
150-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
150+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
151151

152152
module.exports = {
153153
plugins: [
@@ -165,7 +165,7 @@ To change the default `git` command used to read the value of `BRANCH`.
165165
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
166166

167167
```javascript
168-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
168+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
169169

170170
module.exports = {
171171
plugins: [
@@ -183,7 +183,7 @@ To change the default `git` command used to read the value of `LASTCOMMITDATETIM
183183
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
184184

185185
```javascript
186-
var GitRevisionPlugin = require('git-revision-webpack-plugin')
186+
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
187187

188188
module.exports = {
189189
plugins: [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "4.0.1",
2+
"version": "5.0.0-1",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface GitRevisionPluginOptions {
1717
lightweightTags?: boolean
1818
}
1919

20-
export default class GitRevisionPlugin {
20+
export class GitRevisionPlugin {
2121
gitWorkTree?: string
2222
commithashCommand: string
2323
versionCommand: string

test/integration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import webpack from 'webpack'
22
import fs from 'fs-extra'
33
import path from 'path'
4-
import GitRevisionPlugin from '../src'
4+
import { GitRevisionPlugin } from '../src'
55

66
const sourceProject = path.join(__dirname, '../fixtures/project')
77
const sourceGitRepository = path.join(__dirname, '../fixtures/git-repository')

test/unit.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Compiler } from 'webpack'
2-
import GitRevisionPlugin from '../src'
2+
import { GitRevisionPlugin } from '../src'
33

44
jest.mock('../src/build-file', () => jest.fn())
55
// eslint-disable-next-line import/first

0 commit comments

Comments
 (0)