Skip to content

Commit fcb0846

Browse files
committed
Switch to using rollup
1 parent 8468e65 commit fcb0846

25 files changed

+234
-30
lines changed

.babelrc

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
{
2-
"plugins": ["remove-comments"]
2+
"presets": [
3+
[
4+
"es2015",
5+
{
6+
"modules": false
7+
}
8+
],
9+
"stage-0",
10+
"react"
11+
],
12+
13+
"plugins": [
14+
"external-helpers"
15+
],
16+
17+
"env": {
18+
"development": {
19+
"plugins": [
20+
21+
]
22+
},
23+
24+
"test": {
25+
"sourceMaps": "inline"
26+
},
27+
28+
"production": {
29+
"plugins": [
30+
"remove-comments"
31+
]
32+
}
33+
}
334
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ build/Release
2828
# Dependency directory
2929
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
3030
node_modules
31-
lib
31+
cjs
3232

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-joi-validation.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/react-joi-validation.development.js');
7+
}

package.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"name": "react-joi-validation",
33
"version": "1.6.2",
44
"description": "Extremely flexible validation using Joi and React",
5-
"main": "lib/index.js",
5+
"main": "index.js",
66
"scripts": {
7-
"prepublish": "rm -rf lib && babel --presets=es2015,stage-0,react src -d lib",
8-
"build-for-tests": "babel --presets=es2015,stage-0,react src -d lib --source-maps",
9-
"build-tests": "rm -rf lib/spec && babel --presets=es2015,stage-0,react spec -d lib/spec --source-maps",
7+
"prepublish": "rm -rf cjs && npm run build-development && npm run build-production",
8+
"build-development": "BABEL_ENV=development NODE_ENV=development rollup -c",
9+
"build-production": "BABEL_ENV=production NODE_ENV=production rollup -c",
10+
"build-for-tests": "BABEL_ENV=test NODE_ENV=development rollup -c",
11+
"build-tests": "rm -rf cjs/spec && babel spec -d cjs/spec",
1012
"tests": "npm run build-for-tests && npm run build-tests && jasmine",
1113
"watch-tests": "nodemon --exec 'npm run tests || true'"
1214
},
@@ -21,11 +23,12 @@
2123
"forms"
2224
],
2325
"files": [
24-
"lib",
26+
"cjs",
2527
"package.json",
2628
"README.md",
2729
"LICENSE",
28-
"index.d.ts"
30+
"index.d.ts",
31+
"index.js"
2932
],
3033
"typings": "./index.d.ts",
3134
"author": "Aleck Greenham",
@@ -57,6 +60,7 @@
5760
"@types/joi": "^13.0.5",
5861
"@types/react": "^16.0.36",
5962
"babel-cli": "^6.24.1",
63+
"babel-plugin-external-helpers": "^6.22.0",
6064
"babel-plugin-remove-comments": "^2.0.0",
6165
"babel-preset-es2015": "^6.24.1",
6266
"babel-preset-react": "^6.24.1",
@@ -74,6 +78,11 @@
7478
"react-core": "^0.0.0",
7579
"react-dom": "^16.2.0",
7680
"react-test-renderer": "^16.2.0",
81+
"rollup": "^0.55.5",
82+
"rollup-plugin-babel": "^3.0.3",
83+
"rollup-plugin-license": "^0.5.0",
84+
"rollup-plugin-replace": "^2.0.0",
85+
"rollup-plugin-uglify": "^3.0.0",
7786
"source-map-support": "^0.4.15"
7887
},
7988
"peerDependencies": {

rollup.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import babel from 'rollup-plugin-babel';
2+
import replace from 'rollup-plugin-replace';
3+
import uglify from 'rollup-plugin-uglify';
4+
import license from 'rollup-plugin-license';
5+
import path from 'path';
6+
7+
export default {
8+
input: 'src/index.js',
9+
10+
output: {
11+
format: 'cjs',
12+
file: process.env.NODE_ENV === 'production' ? 'cjs/react-joi-validation.production.min.js' : 'cjs/react-joi-validation.development.js',
13+
exports: 'named'
14+
},
15+
external: [
16+
'react',
17+
'lodash.set',
18+
'lodash.unset',
19+
'lodash.get',
20+
'lodash.drop',
21+
'lodash.has',
22+
'lodash.isstring',
23+
'lodash.isplainobject',
24+
'lodash.reduce',
25+
'lodash.defaultsdeep',
26+
'lodash.clonedeep',
27+
'lodash.foreach',
28+
'lodash.map',
29+
'invariant',
30+
'lodash.topath',
31+
'lodash.isundefined',
32+
'lodash.uniq',
33+
'lodash.keys'
34+
],
35+
plugins: [
36+
babel({
37+
exclude: 'node_modules/**'
38+
}),
39+
40+
replace({
41+
exclude: 'node_modules/**',
42+
ENV: JSON.stringify(process.env.NODE_ENV || 'development')
43+
}),
44+
45+
(process.env.NODE_ENV === 'production' && uglify()),
46+
47+
license({
48+
banner: {
49+
file: path.join(__dirname, 'LICENSE'),
50+
}
51+
})
52+
]
53+
};

spec/.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0",
5+
"react"
6+
],
7+
8+
"sourceMaps": "inline"
9+
}

spec/higher-order-function/changeHandlerTransformSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import Joi from 'joi-browser';
33
import ShallowRenderer from 'react-test-renderer/shallow';
44

5-
import validate, { useFirstArgument, useSecondArgument, useThirdArgument, guessCorrectValue } from '../../index';
5+
import validate, { useFirstArgument, useSecondArgument, useThirdArgument, guessCorrectValue } from '../../react-joi-validation.development';
66
import WrappedComponent from '../WrappedComponent';
77
import refreshComponentState from '../support/refreshComponentState';
88

spec/higher-order-function/onlySpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ShallowRenderer from 'react-test-renderer/shallow';
3-
import validate from '../../index'
3+
import validate from '../../react-joi-validation.development'
44
import Joi from 'joi-browser';
55

66
import expectComponentToHaveErrors from '../support/expectComponentToHaveErrors';

spec/higher-order-function/pseudoValuesSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ShallowRenderer from 'react-test-renderer/shallow';
3-
import validate from '../../index'
3+
import validate from '../../react-joi-validation.development'
44
import Joi from 'joi-browser';
55

66
import refreshComponentState from '../support/refreshComponentState';

spec/higher-order-function/validatorSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ShallowRenderer from 'react-test-renderer/shallow';
3-
import validate from '../../index'
3+
import validate from '../../react-joi-validation.development'
44
import Joi from 'joi-browser';
55
import each from 'lodash.foreach';
66
import map from 'lodash.map';

0 commit comments

Comments
 (0)