Skip to content

Commit ab42ced

Browse files
authored
Read version directly from package.json (#90)
1 parent 94d4eb2 commit ab42ced

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

package-lock.json

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@
7272
"react": "^16.8.6",
7373
"react-dom": "^16.8.6",
7474
"react-final-form": "^6.2.1",
75-
"rollup": "^1.15.4",
75+
"rollup": "^1.15.5",
7676
"rollup-plugin-babel": "^4.3.2",
7777
"rollup-plugin-commonjs": "^10.0.0",
78+
"rollup-plugin-json": "^4.0.0",
7879
"rollup-plugin-node-resolve": "^5.0.2",
7980
"rollup-plugin-replace": "^2.2.0",
8081
"rollup-plugin-uglify": "^6.0.2",

rollup.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import resolve from 'rollup-plugin-node-resolve'
22
import babel from 'rollup-plugin-babel'
33
import commonjs from 'rollup-plugin-commonjs'
4+
import json from 'rollup-plugin-json'
45
import { uglify } from 'rollup-plugin-uglify'
56
import replace from 'rollup-plugin-replace'
67

@@ -56,6 +57,7 @@ export default {
5657
},
5758
plugins: [
5859
resolve({ jsnext: true, main: true }),
60+
json(),
5961
commonjs({ include: 'node_modules/**' }),
6062
babel({
6163
exclude: 'node_modules/**',

src/FieldArray.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { version as rffVersion } from 'react-final-form'
44
import type { FieldArrayProps } from './types'
55
import renderComponent from './renderComponent'
66
import useFieldArray from './useFieldArray'
7-
export const version = '3.1.0'
7+
import { version } from '../package.json'
8+
9+
export { version }
810

911
const versions = {
1012
'final-form': ffVersion,

src/FieldArray.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import 'jest-dom/extend-expect'
44
import arrayMutators from 'final-form-arrays'
55
import { ErrorBoundary, Toggle } from './testUtils'
66
import { Form, Field } from 'react-final-form'
7-
import FieldArray from './FieldArray'
7+
import { FieldArray, version } from '.'
88

99
const onSubmitMock = values => {}
1010
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
1111

1212
describe('FieldArray', () => {
1313
afterEach(cleanup)
1414

15+
it('should export version', () => {
16+
expect(version).toBeDefined()
17+
})
18+
1519
it('should warn if not used inside a form', () => {
1620
jest.spyOn(console, 'error').mockImplementation(() => {})
1721
const errorSpy = jest.fn()

0 commit comments

Comments
 (0)