Skip to content

Commit

Permalink
deps: Consistently use deep lodash imports to allow proper tree-shaking
Browse files Browse the repository at this point in the history
Instead of importing top-level module, consistently use deep-imports for lodash.
This allows projects to properly tree-shake lodash in their build which substantially reduces
the size of the resulting bundle.
  • Loading branch information
FlorianSW authored Dec 13, 2024
1 parent 21400a8 commit 9c1c7da
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
setReadonly,
UISchemaElement,
} from '@jsonforms/core';
import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';

@Component({
selector: 'ObjectRenderer',
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/src/library/jsonforms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ import { JsonFormsBaseRenderer } from './base.renderer';
import { JsonFormsControl } from './control';
import { JsonFormsAngularService } from './jsonforms.service';

import { get, isEqual } from 'lodash';
import isEqual from 'lodash/isEqual';
import get from 'lodash/get';

const areEqual = (
prevProps: StatePropsOfJsonFormsRenderer,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/library/jsonforms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
import { BehaviorSubject, Observable } from 'rxjs';
import type { JsonFormsBaseRenderer } from './base.renderer';

import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import type Ajv from 'ajv';
import type { ErrorObject } from 'ajv';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/mappers/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import {
} from '../store';
import { isInherentlyEnabled } from './util';
import { CombinatorKeyword } from './combinators';
import { isEqual } from 'lodash';
import isEqual from 'lodash/isEqual';

const move = (array: any[], index: number, delta: number) => {
const newIndex: number = index + delta;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/reducers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
} from '../actions';
import { JsonFormsCore, Reducer, ValidationMode } from '../store';
import Ajv, { ErrorObject } from 'ajv';
import { isFunction } from 'lodash';
import isFunction from 'lodash/isFunction';
import { createAjv, validate } from '../util';

export const initState: JsonFormsCore = {
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/examples/arraysI18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import { registerExamples } from '../register';
import { ArrayTranslationEnum, Translator } from '@jsonforms/core';
import { get } from 'lodash';
import get from 'lodash/get';

export const schema = {
type: 'object',
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-vanilla/src/complex/ObjectRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
useJsonFormsControlWithDetail,
} from '../../config/jsonforms';
import { useVanillaControl } from '../util';
import { isEmpty } from 'lodash';
import isEmpty from 'lodash/isEmpty';
const controlRenderer = defineComponent({
name: 'ObjectRenderer',
Expand Down

0 comments on commit 9c1c7da

Please sign in to comment.