Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit b5ebfbc

Browse files
committed
Optimizations: adding webpack externals for React, React-Redux, Redux; adding lodash babel plugin, removing partial and capitalize lodash deps
1 parent d88dcc9 commit b5ebfbc

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

.babelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2+
"plugins": [
3+
"lodash"
4+
],
25
"presets": ["es2015", "react", "stage-2"]
3-
}
6+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"build:watch": "babel -w src --out-dir lib",
1414
"build:umd": "webpack -p src/index.js dist/index.js --config webpack.config.prod.js",
1515
"build:lib": "babel src --out-dir lib",
16+
"analyze": "webpack src/index.js dist/index.js --config webpack.config.base.js --json | webpack-bundle-size-analyzer",
1617
"preversion": "npm run test && npm run lint",
1718
"prepublish": "npm test && npm run lint && npm run build",
1819
"postversion": "git push && git push --tags",
@@ -41,6 +42,7 @@
4142
"babel-core": "^6.5.2",
4243
"babel-eslint": "^6.0.0",
4344
"babel-loader": "^6.2.4",
45+
"babel-plugin-lodash": "^3.1.4",
4446
"babel-preset-es2015": "^6.5.0",
4547
"babel-preset-react": "^6.5.0",
4648
"babel-preset-stage-2": "^6.5.0",

src/utils/capitalize.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function capitalize(string) {
2+
if (typeof string !== 'string') {
3+
return '';
4+
}
5+
6+
return string.charAt(0).toUpperCase() + string.slice(1);
7+
}

src/utils/sequence.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import identity from 'lodash/identity';
2-
import capitalize from 'lodash/capitalize';
3-
import partial from 'lodash/partial';
2+
import capitalize from '../utils/capitalize';
43
import mapValues from '../utils/map-values';
54
import compose from 'lodash/fp/compose';
65
import isEqual from 'lodash/isEqual';
@@ -97,7 +96,7 @@ function sequenceEventActions(props) {
9796
onSubmit: [], // pseudo-event
9897
};
9998

100-
const controlChangeMethod = partial(changeAction, model);
99+
const controlChangeMethod = (...args) => changeAction(model, ...args);
101100
const modelValueUpdater = modelValueUpdaterMap[controlProps.type]
102101
|| modelValueUpdaterMap.default;
103102

@@ -182,7 +181,7 @@ function sequenceEventActions(props) {
182181
eventActions[updateOnEventHandler].push(
183182
compose(
184183
updaterFn(dispatchChange),
185-
partial(modelValueUpdater, props),
184+
(...args) => modelValueUpdater(props, ...args),
186185
parser,
187186
getValue,
188187
controlOnChange));

webpack.config.base.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
'use strict';
33

44
module.exports = {
5+
externals: {
6+
react: {
7+
root: 'React',
8+
commonjs2: 'react',
9+
commonjs: 'react',
10+
amd: 'react',
11+
},
12+
redux: {
13+
root: 'Redux',
14+
commonjs2: 'redux',
15+
commonjs: 'redux',
16+
amd: 'redux',
17+
},
18+
'react-redux': {
19+
root: 'ReactRedux',
20+
commonjs2: 'react-redux',
21+
commonjs: 'react-redux',
22+
amd: 'react-redux',
23+
},
24+
},
525
module: {
626
loaders: [
727
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },

0 commit comments

Comments
 (0)