Skip to content

Commit 536a303

Browse files
authored
refactor(lodash): remove (#323)
* refactor(lodash): remove * chore(mson): v2.12.1 * fix(bundle-size): bump
1 parent 61168f3 commit 536a303

File tree

7 files changed

+18
-24
lines changed

7 files changed

+18
-24
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"@material-ui/pickers": "^3.2.10",
1717
"classnames": "^2.2.6",
1818
"date-fns": "^2.15.0",
19-
"lodash": "^4.17.20",
20-
"mson": "^2.12.0",
19+
"mson": "^2.12.1",
2120
"react-beautiful-dnd": "^13.0.0",
2221
"react-google-recaptcha": "^2.1.0",
2322
"react-markdown": "^5.0.3",

scripts/bundle-size.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#!/usr/bin/env bash
22

3-
mainMaxBytes=410000
4-
chunkMaxBytes=1390000
3+
maxBytes=1270000
54

6-
if [ $(wc -c < build/static/js/main.*.js) -gt ${mainMaxBytes} ]; then
7-
echo 'Error: main bundle too large!'
5+
if [ $(wc -c < dist/msonreact.js) -gt ${maxBytes} ]; then
6+
echo 'Error: bundle too large!'
87
exit 1
9-
fi
10-
11-
if [ $(wc -c < build/static/js/2.*.chunk.js) -gt ${chunkMaxBytes} ]; then
12-
echo 'Error: chunk bundle too large!'
13-
exit 1
14-
fi
8+
fi

src/attach.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import difference from 'lodash/difference';
2+
import utils from 'mson/lib/utils/utils';
33

44
// Usage: attach(['prop1', 'prop2', ...], componentOrName)(Component)
55

@@ -34,7 +34,10 @@ const attach = (_watchProps, componentOrName) => {
3434

3535
// The field props that we want to expose in the state. Remove any names that are in
3636
// this.props so that we can override those values.
37-
this.watchProps = difference(_watchProps, Object.keys(this.props));
37+
this.watchProps = utils.difference(
38+
_watchProps,
39+
Object.keys(this.props)
40+
);
3841

3942
// These values need to be in the state so that the component is rerendered when they change.
4043
if (this.hasComponent()) {

src/field-editor-form.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Form from './form';
66
import withStyles from '@material-ui/core/styles/withStyles';
77
import Field from './fields/field';
88
import compiler from 'mson/lib/compiler';
9-
import each from 'lodash/each';
109
import attach from './attach';
1110
import ComponentField from 'mson/lib/fields/component-field';
1211

@@ -68,7 +67,7 @@ class FieldEditorForm extends React.PureComponent {
6867
field.getClassName() === 'ComponentField'
6968
? field.get('content')
7069
: field;
71-
each(values, (value, name) => {
70+
Object.entries(values).forEach(([name, value]) => {
7271
if (component.has(name)) {
7372
component.set({ [name]: value });
7473
}

src/submenu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import ListItemText from '@material-ui/core/ListItemText';
66
import Collapse from '@material-ui/core/Collapse';
77
import Typography from '@material-ui/core/Typography';
88
import Icon from './icon';
9-
import each from 'lodash/each';
109
import registrar from 'mson/lib/compiler/registrar';
10+
import utils from 'mson/lib/utils/utils';
1111

1212
const styles = (theme) => ({
1313
nested: {
@@ -38,7 +38,7 @@ class Submenu extends React.PureComponent {
3838

3939
let childSelected = false;
4040

41-
each(item.items, (item) => {
41+
utils.each(item.items, (item) => {
4242
if (path === item.path) {
4343
childSelected = true;
4444
return false; // exit loop

src/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import each from 'lodash/each';
21
class Utils {
32
getIfDefined(props) {
43
const definedProps = {};
5-
each(props, (value, name) => {
4+
Object.keys(props).forEach(([name, value]) => {
65
if (value !== undefined) {
76
definedProps[name] = value;
87
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9191,10 +9191,10 @@ ms@2.1.3, ms@^2.0.0, ms@^2.1.1, ms@^2.1.2:
91919191
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
91929192
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
91939193

9194-
mson@^2.12.0:
9195-
version "2.12.0"
9196-
resolved "https://registry.yarnpkg.com/mson/-/mson-2.12.0.tgz#86ab1ccf8123e0ea77bc3dc57c78858077168b3d"
9197-
integrity sha512-2ZpiScfgiqG/PiNgsgjHteDmXRZv0jead0gnE98gvpx7P55jZuJDPy7o2sa5V1Hp0veMx+cbEnqek+/KbkUgdQ==
9194+
mson@^2.12.1:
9195+
version "2.12.1"
9196+
resolved "https://registry.yarnpkg.com/mson/-/mson-2.12.1.tgz#a62d027bfb558870e9fc53ae414b917578051c5d"
9197+
integrity sha512-EFt7SHuvlAiaWf0WOajQhi9btfYxGSi1A2beqaQOkoAhBNrq0qW+ghFG07lxlveXA0ZU5gSH3lQr5rA9fJ9xDg==
91989198
dependencies:
91999199
country-telephone-data "^0.6.3"
92009200
date-fns "^2.15.0"

0 commit comments

Comments
 (0)