Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Optimize lodash loading for production build.
Browse files Browse the repository at this point in the history
No need to load the entire lodash library.
  • Loading branch information
fudanchii committed Dec 1, 2017
1 parent 71490a0 commit 1864125
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/AvBaseInput.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component} from 'react';
import PropTypes from 'prop-types';
import {isUndefined, isEqual} from 'lodash';
import isUndefined from 'lodash/isUndefined';
import isEqual from 'lodash/isEqual';

const htmlValidationAttrs = ['min', 'max', 'minLength', 'maxLength', 'pattern', 'required', 'step'];
const htmlValidationTypes = [
Expand Down
4 changes: 3 additions & 1 deletion src/AvForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import InputContainer from './AvInputContainer';
import AvValidator from './AvValidator';
import { Form } from 'reactstrap';
import classNames from 'classnames';
import {get as _get, set as _set, isString} from 'lodash';
import _get from 'lodash/get';
import _set from 'lodash/set';
import isString from 'lodash/isString';

const getInputErrorMessage = (input, ruleName) => {
const errorMessage = input.props.errorMessage;
Expand Down
2 changes: 1 addition & 1 deletion src/AvRadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import InputContainer from './AvInputContainer';
import AvFeedback from './AvFeedback';
import { isEqual } from 'lodash';
import isEqual from 'lodash/isEqual';
import { FormGroup } from 'reactstrap';

const htmlValidationAttrs = ['required'];
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/max.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import { toNumber } from 'lodash';
import toNumber from 'lodash/toNumber';
import { isEmpty, isoDateFormat } from './utils';

export default function validate(value, context, constraint = {}, input = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/maxlength.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toNumber } from 'lodash';
import toNumber from 'lodash/toNumber';
import { isEmpty } from './utils';

export default function validate(value, context, constraint = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/min.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import { toNumber } from 'lodash';
import toNumber from 'lodash/toNumber';
import { isEmpty, isoDateFormat } from './utils';

export default function validate(value, context, constraint = {}, input = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/minlength.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toNumber } from 'lodash';
import toNumber from 'lodash/toNumber';
import { isEmpty } from './utils';

export default function validate(value, context, constraint = {}) {
Expand Down
3 changes: 2 additions & 1 deletion src/AvValidator/number.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isNumber, toNumber } from 'lodash';
import isNumber from 'lodash/isNumber';
import toNumber from 'lodash/toNumber';
import { isEmpty } from './utils';

export default function validate(value, context, {errorMessage = false} = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/pattern.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isRegExp} from 'lodash';
import isRegExp from 'lodash/isRegExp';
import { isEmpty } from './utils';

const REGEX = /^\/(.*)\/([gim]*)$/; // regular expression to test a regular expression
Expand Down
2 changes: 1 addition & 1 deletion src/AvValidator/step.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toNumber } from 'lodash';
import toNumber from 'lodash/toNumber';
import { isEmpty } from './utils';

// http://stackoverflow.com/a/31711034/1873485
Expand Down
3 changes: 2 additions & 1 deletion src/AvValidator/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isString, isUndefined } from 'lodash';
import isString from 'lodash/isString';
import isUndefined from 'lodash/isUndefined';
/* global document */
export const isoDateFormat = 'YYYY-MM-DD';

Expand Down

0 comments on commit 1864125

Please sign in to comment.