From 9c1c7da2ba6a46d190991f76eba804c9b3834f98 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 13 Dec 2024 09:57:04 +0100 Subject: [PATCH] deps: Consistently use deep lodash imports to allow proper tree-shaking 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. --- packages/angular-material/src/library/other/object.renderer.ts | 2 +- packages/angular/src/library/jsonforms.component.ts | 3 ++- packages/angular/src/library/jsonforms.service.ts | 2 +- packages/core/src/mappers/renderer.ts | 2 +- packages/core/src/reducers/core.ts | 2 +- packages/examples/src/examples/arraysI18n.ts | 2 +- packages/vue-vanilla/src/complex/ObjectRenderer.vue | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/angular-material/src/library/other/object.renderer.ts b/packages/angular-material/src/library/other/object.renderer.ts index 12cac5e17c..7f5e5e96d5 100644 --- a/packages/angular-material/src/library/other/object.renderer.ts +++ b/packages/angular-material/src/library/other/object.renderer.ts @@ -40,7 +40,7 @@ import { setReadonly, UISchemaElement, } from '@jsonforms/core'; -import { cloneDeep } from 'lodash'; +import cloneDeep from 'lodash/cloneDeep'; @Component({ selector: 'ObjectRenderer', diff --git a/packages/angular/src/library/jsonforms.component.ts b/packages/angular/src/library/jsonforms.component.ts index 9ce2f4c6da..a8720ab079 100644 --- a/packages/angular/src/library/jsonforms.component.ts +++ b/packages/angular/src/library/jsonforms.component.ts @@ -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, diff --git a/packages/angular/src/library/jsonforms.service.ts b/packages/angular/src/library/jsonforms.service.ts index 4b299c65ab..294772731d 100644 --- a/packages/angular/src/library/jsonforms.service.ts +++ b/packages/angular/src/library/jsonforms.service.ts @@ -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'; diff --git a/packages/core/src/mappers/renderer.ts b/packages/core/src/mappers/renderer.ts index 3753ab7861..f677303341 100644 --- a/packages/core/src/mappers/renderer.ts +++ b/packages/core/src/mappers/renderer.ts @@ -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; diff --git a/packages/core/src/reducers/core.ts b/packages/core/src/reducers/core.ts index efae30e9fa..82227475f0 100644 --- a/packages/core/src/reducers/core.ts +++ b/packages/core/src/reducers/core.ts @@ -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 = { diff --git a/packages/examples/src/examples/arraysI18n.ts b/packages/examples/src/examples/arraysI18n.ts index d92f2d34e3..8b17339304 100644 --- a/packages/examples/src/examples/arraysI18n.ts +++ b/packages/examples/src/examples/arraysI18n.ts @@ -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', diff --git a/packages/vue-vanilla/src/complex/ObjectRenderer.vue b/packages/vue-vanilla/src/complex/ObjectRenderer.vue index 7843f03fc0..462d067dca 100644 --- a/packages/vue-vanilla/src/complex/ObjectRenderer.vue +++ b/packages/vue-vanilla/src/complex/ObjectRenderer.vue @@ -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',