Skip to content

Commit

Permalink
Chore: Reduce bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
codenaz committed Jan 21, 2020
1 parent e18acd3 commit c3347e3
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ yarn-error.log*
#all src files except lib
src/*
!src/lib
!src/__tests__
!src/__tests__

stats.json
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

46 changes: 45 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-hooks-paginator",
"description": "A package for adding paginator functionality to react apps",
"version": "0.3.0",
"version": "0.4.1",
"main": "dist/index.js",
"files": [
"dist",
Expand Down Expand Up @@ -29,7 +29,8 @@
"build": "webpack",
"test": "react-scripts test",
"eject": "react-scripts eject",
"prepublish": "npm run build"
"prepublish": "npm run build",
"bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"eslintConfig": {
"extends": "react-app"
Expand Down Expand Up @@ -64,6 +65,7 @@
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "4.28.3",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.1.14"
}
Expand Down
32 changes: 16 additions & 16 deletions src/lib/paginator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useCallback, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { number, string, func, oneOfType, node } from 'prop-types';
import './style/main.scss';

const LEFT_PAGE = 'LEFT';
Expand Down Expand Up @@ -164,7 +164,7 @@ function Paginator(props) {
<li
className={`${props.pageItemClass} ${
currentPage === page ? props.pageActiveClass : null
}`}
}`}
key={index}
>
<button
Expand Down Expand Up @@ -192,20 +192,20 @@ Paginator.defaultProps = {
};

Paginator.propTypes = {
currentPage: PropTypes.number,
pageActiveClass: PropTypes.string,
pageNextText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
pagePrevText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
pagePrevClass: PropTypes.string,
pageNextClass: PropTypes.string,
pageContainerClass: PropTypes.string,
pageItemClass: PropTypes.string,
pageLimit: PropTypes.number,
pageLinkClass: PropTypes.string,
pageNeighbours: PropTypes.number,
setCurrentPage: PropTypes.func,
setOffset: PropTypes.func,
totalRecords: PropTypes.number.isRequired
currentPage: number,
pageActiveClass: string,
pageNextText: oneOfType([string, node]),
pagePrevText: oneOfType([string, node]),
pagePrevClass: string,
pageNextClass: string,
pageContainerClass: string,
pageItemClass: string,
pageLimit: number,
pageLinkClass: string,
pageNeighbours: number,
setCurrentPage: func,
setOffset: func,
totalRecords: number.isRequired
};

export default Paginator;
11 changes: 9 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;

module.exports = {
entry: './src/lib/index.js',
Expand Down Expand Up @@ -47,5 +48,11 @@ module.exports = {
amd: 'ReactDOM',
root: 'ReactDOM'
}
}
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true
})
]
};

0 comments on commit c3347e3

Please sign in to comment.