Skip to content

Commit f71df10

Browse files
authored
chore: maintain dependencies & add CJS build (#68)
1 parent 946143a commit f71df10

File tree

9 files changed

+9834
-941
lines changed

9 files changed

+9834
-941
lines changed

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
src/
1+
src/
2+
coverage/
3+
/yarn-error.log

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

hooks/pre-commit

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

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

package.json

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
{
22
"name": "react-router-breadcrumbs-hoc",
3-
"version": "3.1.2",
4-
"description": "Just a tiny, flexible, higher order component for rendering breadcrumbs with react-router 4.x",
3+
"version": "3.2.0",
4+
"description": "small, flexible, higher order component for rendering breadcrumbs with react-router 4.x",
55
"repository": "icd2k3/react-router-breadcrumbs-hoc",
6-
"keywords": [
7-
"react",
8-
"router",
9-
"breadcrumbs",
10-
"react-router",
11-
"react-router 4"
12-
],
13-
"main": "dist/umd/index.js",
6+
"main": "dist/cjs/index.js",
147
"module": "dist/es/index.js",
15-
"author": "Koan Inc.",
8+
"umd": "dist/umd/index.js",
9+
"types": "types/react-router-breadcrumbs-hoc/index.d.ts",
10+
"scripts": {
11+
"prepublishOnly": "npm run build",
12+
"build": "rollup -c",
13+
"test": "jest",
14+
"test-build": "sh ./scripts/test-build.sh",
15+
"types": "tsc -p types/react-router-breadcrumbs-hoc",
16+
"travis": "sh ./scripts/travis.sh",
17+
"lint": "eslint ./src/**"
18+
},
19+
"husky": {
20+
"hooks": {
21+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
22+
"pre-commit": "yarn lint && yarn test",
23+
"pre-push": "yarn types && yarn lint && yarn test-build"
24+
}
25+
},
26+
"author": "Justin Schrader (me@justin.beer)",
1627
"license": "MIT",
1728
"peerDependencies": {
1829
"react": ">=16",
@@ -21,44 +32,45 @@
2132
},
2233
"dependencies": {},
2334
"devDependencies": {
24-
"@babel/cli": "^7.1.0",
25-
"@babel/core": "^7.4.0",
26-
"@babel/plugin-transform-modules-commonjs": "^7.4.0",
27-
"@babel/preset-env": "^7.4.2",
35+
"@babel/cli": "^7.4.4",
36+
"@babel/core": "^7.4.4",
37+
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
38+
"@babel/preset-env": "^7.4.4",
2839
"@babel/preset-react": "^7.0.0",
29-
"@types/react": "16.8.8",
30-
"@types/react-router-dom": "4.3.1",
40+
"@commitlint/cli": "^7.5.2",
41+
"@commitlint/config-conventional": "^7.5.0",
42+
"@types/react": "16.8.16",
43+
"@types/react-router-dom": "4.3.2",
3144
"babel-core": "^7.0.0-0",
3245
"babel-eslint": "^10.0.1",
33-
"babel-jest": "^24.5.0",
46+
"babel-jest": "^24.7.1",
3447
"coveralls": "^3.0.3",
3548
"enzyme": "^3.9.0",
36-
"enzyme-adapter-react-16": "^1.11.2",
37-
"eslint": "^5.15.3",
49+
"enzyme-adapter-react-16": "^1.12.1",
50+
"eslint": "^5.16.0",
3851
"eslint-config-airbnb": "^17.0.0",
39-
"eslint-plugin-import": "^2.13.0",
52+
"eslint-plugin-import": "^2.17.2",
4053
"eslint-plugin-jsx-a11y": "^6.2.1",
41-
"eslint-plugin-react": "^7.10.0",
42-
"jest": "^24.5.0",
54+
"eslint-plugin-react": "^7.13.0",
55+
"husky": "^2.2.0",
56+
"jest": "^24.7.1",
4357
"prop-types": "^15.7.2",
4458
"react": "16.8.6",
4559
"react-dom": "16.8.6",
4660
"react-router": "^5.0.0",
4761
"react-router-dom": "^5.0.0",
48-
"rollup": "^1.7.0",
62+
"rollup": "^1.11.2",
4963
"rollup-plugin-babel": "^4.0.3",
50-
"rollup-plugin-commonjs": "^9.2.1",
51-
"rollup-plugin-node-resolve": "^4.0.1",
52-
"typescript": "^3.3.4000"
64+
"rollup-plugin-commonjs": "^9.3.4",
65+
"rollup-plugin-node-resolve": "^4.2.3",
66+
"rollup-plugin-uglify": "^6.0.2",
67+
"typescript": "^3.4.5"
5368
},
54-
"scripts": {
55-
"prepublishOnly": "npm run build",
56-
"build": "rollup -c",
57-
"test": "jest",
58-
"test-build": "sh ./scripts/test-build.sh",
59-
"types": "tsc -p types/react-router-breadcrumbs-hoc",
60-
"travis": "sh ./scripts/travis.sh",
61-
"lint": "eslint ./src/**"
62-
},
63-
"types": "types/react-router-breadcrumbs-hoc/index.d.ts"
69+
"keywords": [
70+
"react",
71+
"router",
72+
"breadcrumbs",
73+
"react-router",
74+
"react-router 4"
75+
]
6476
}

rollup.config.js

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
11
import babel from 'rollup-plugin-babel';
22
import commonjs from 'rollup-plugin-commonjs';
33
import resolve from 'rollup-plugin-node-resolve';
4+
import { uglify } from 'rollup-plugin-uglify';
45

56
const pkg = require('./package.json');
67

78
const external = Object.keys(pkg.peerDependencies);
89

10+
const plugins = [
11+
babel({
12+
exclude: 'node_modules/**',
13+
}),
14+
resolve({
15+
mainFields: ['module', 'main', 'umd'],
16+
}),
17+
];
18+
19+
const exports = [
20+
{ format: 'cjs', file: pkg.main, plugins: plugins.concat([commonjs(), uglify()]) },
21+
{ format: 'umd', file: pkg.umd, plugins: plugins.concat([commonjs(), uglify()]) },
22+
{ format: 'es', file: pkg.module, plugins },
23+
];
24+
925
const globals = {
1026
react: 'React',
1127
'react-router': 'ReactRouter',
1228
};
1329

14-
const config = {
30+
export default exports.map(item => ({
1531
input: 'src/index.js',
16-
plugins: [
17-
babel({
18-
exclude: 'node_modules/**',
19-
}),
20-
resolve({
21-
module: true,
22-
jsnext: true,
23-
main: true,
24-
}),
25-
commonjs(),
26-
],
32+
plugins: item.plugins,
2733
external,
28-
output: [
29-
{
30-
exports: 'named',
31-
file: pkg.main,
32-
format: 'umd',
33-
globals,
34-
name: 'react-router-breadcrumbs-hoc',
35-
sourcemap: true,
36-
},
37-
{
38-
exports: 'named',
39-
file: pkg.module,
40-
format: 'es',
41-
globals,
42-
sourcemap: true,
43-
},
44-
],
45-
};
46-
47-
export default config;
34+
output: {
35+
exports: 'named',
36+
file: item.file,
37+
format: item.format,
38+
name: 'react-router-breadcrumbs-hoc',
39+
globals,
40+
sourcemap: true,
41+
},
42+
}));

scripts/test-build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# runs the tests in ./src/index.test.js, but
44
# replaces the import to target the compiled builds
5-
# in ./dist/es/index.js and ./dist/umd/index.js
6-
7-
# NOTE: make sure to run `yarn build` prior to this script
5+
# in ./dist/es/index.js, ./dist/umd/index.js, and ./dist/cjs/index.js
86

97
set -e
108

9+
yarn build && \
10+
TEST_BUILD=cjs yarn test --coverage=0 && \
1111
TEST_BUILD=umd yarn test --coverage=0 && \
1212
TEST_BUILD=es yarn test --coverage=0

src/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import withBreadcrumbs, { getBreadcrumbs } from './index';
1010
// imports to test compiled builds
1111
import withBreadcrumbsCompiledES, { getBreadcrumbs as getBreadcrumbsCompiledES } from '../dist/es/index';
1212
import withBreadcrumbsCompiledUMD, { getBreadcrumbs as getBreadcrumbsCompiledUMD } from '../dist/umd/index';
13+
import withBreadcrumbsCompiledCJS, { getBreadcrumbs as getBreadcrumbsCompiledCJS } from '../dist/cjs/index';
1314

1415
const components = {
1516
Breadcrumbs: ({ breadcrumbs }) => (
@@ -39,6 +40,8 @@ const components = {
3940

4041
const getHOC = () => {
4142
switch (process.env.TEST_BUILD) {
43+
case 'cjs':
44+
return withBreadcrumbsCompiledCJS;
4245
case 'umd':
4346
return withBreadcrumbsCompiledUMD;
4447
case 'es':
@@ -50,6 +53,8 @@ const getHOC = () => {
5053

5154
const getMethod = () => {
5255
switch (process.env.TEST_BUILD) {
56+
case 'cjs':
57+
return getBreadcrumbsCompiledCJS;
5358
case 'umd':
5459
return getBreadcrumbsCompiledUMD;
5560
case 'es':

0 commit comments

Comments
 (0)