From 2c096d908f8cb2121a6614abfa2f690d1bb814ca Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Thu, 11 May 2023 12:01:36 +0200 Subject: [PATCH 1/6] START: deps lodash-es --- package-lock.json | 61 ++++++++++++++++++----------------------------- package.json | 6 ++--- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index 423fdd43ef..3fd66139b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,7 @@ "@typed-mxgraph/typed-mxgraph": "~1.0.7", "entities": "~4.3.1", "fast-xml-parser": "4.2.2", - "lodash.debounce": "~4.0.8", - "lodash.throttle": "~4.1.1", + "lodash-es": "~4.17.21", "mxgraph": "4.2.2", "strnum": "1.0.5" }, @@ -24,8 +23,7 @@ "@rollup/plugin-terser": "~0.4.1", "@types/debug": "~4.1.7", "@types/jest-image-snapshot": "~6.1.0", - "@types/lodash.debounce": "~4.0.7", - "@types/lodash.throttle": "~4.1.7", + "@types/lodash-es": "~4.17.7", "@types/minimist": "~1.2.2", "@typescript-eslint/eslint-plugin": "~5.59.1", "@typescript-eslint/parser": "~5.59.1", @@ -3340,19 +3338,10 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/lodash.debounce": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/@types/lodash.debounce/-/lodash.debounce-4.0.7.tgz", - "integrity": "sha512-X1T4wMZ+gT000M2/91SYj0d/7JfeNZ9PeeOldSNoE/lunLeQXKvkmIumI29IaKMotU/ln/McOIvgzZcQ/3TrSA==", - "dev": true, - "dependencies": { - "@types/lodash": "*" - } - }, - "node_modules/@types/lodash.throttle": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@types/lodash.throttle/-/lodash.throttle-4.1.7.tgz", - "integrity": "sha512-znwGDpjCHQ4FpLLx19w4OXDqq8+OvREa05H89obtSyXyOFKL3dDjCslsmfBz0T2FU8dmf5Wx1QvogbINiGIu9g==", + "node_modules/@types/lodash-es": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.7.tgz", + "integrity": "sha512-z0ptr6UI10VlU6l5MYhGwS4mC8DZyYer2mCoyysZtSF7p26zOX8UpbrV0YpNYLGS8K4PUFIyEr62IMFFjveSiQ==", "dev": true, "dependencies": { "@types/lodash": "*" @@ -8365,8 +8354,14 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "node_modules/lodash.debounce": { "version": "4.0.8", + "dev": true, "license": "MIT" }, "node_modules/lodash.difference": { @@ -8415,10 +8410,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.throttle": { - "version": "4.1.1", - "license": "MIT" - }, "node_modules/lodash.uniq": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", @@ -14613,19 +14604,10 @@ "version": "4.14.178", "dev": true }, - "@types/lodash.debounce": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/@types/lodash.debounce/-/lodash.debounce-4.0.7.tgz", - "integrity": "sha512-X1T4wMZ+gT000M2/91SYj0d/7JfeNZ9PeeOldSNoE/lunLeQXKvkmIumI29IaKMotU/ln/McOIvgzZcQ/3TrSA==", - "dev": true, - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.throttle": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@types/lodash.throttle/-/lodash.throttle-4.1.7.tgz", - "integrity": "sha512-znwGDpjCHQ4FpLLx19w4OXDqq8+OvREa05H89obtSyXyOFKL3dDjCslsmfBz0T2FU8dmf5Wx1QvogbINiGIu9g==", + "@types/lodash-es": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.7.tgz", + "integrity": "sha512-z0ptr6UI10VlU6l5MYhGwS4mC8DZyYer2mCoyysZtSF7p26zOX8UpbrV0YpNYLGS8K4PUFIyEr62IMFFjveSiQ==", "dev": true, "requires": { "@types/lodash": "*" @@ -18027,8 +18009,14 @@ "version": "4.17.21", "dev": true }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "lodash.debounce": { - "version": "4.0.8" + "version": "4.0.8", + "dev": true }, "lodash.difference": { "version": "4.5.0", @@ -18068,9 +18056,6 @@ "version": "4.7.0", "dev": true }, - "lodash.throttle": { - "version": "4.1.1" - }, "lodash.uniq": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", diff --git a/package.json b/package.json index 334715e3ca..2dcb05cb6c 100644 --- a/package.json +++ b/package.json @@ -96,8 +96,7 @@ "@typed-mxgraph/typed-mxgraph": "~1.0.7", "entities": "~4.3.1", "fast-xml-parser": "4.2.2", - "lodash.debounce": "~4.0.8", - "lodash.throttle": "~4.1.1", + "lodash-es": "~4.17.21", "mxgraph": "4.2.2", "strnum": "1.0.5" }, @@ -108,8 +107,7 @@ "@rollup/plugin-terser": "~0.4.1", "@types/debug": "~4.1.7", "@types/jest-image-snapshot": "~6.1.0", - "@types/lodash.debounce": "~4.0.7", - "@types/lodash.throttle": "~4.1.7", + "@types/lodash-es": "~4.17.7", "@types/minimist": "~1.2.2", "@typescript-eslint/eslint-plugin": "~5.59.1", "@typescript-eslint/parser": "~5.59.1", From e31d0e201254b9b63fed630e3df4ed746bd329dd Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Thu, 11 May 2023 12:05:20 +0200 Subject: [PATCH 2/6] Use in code --- src/component/mxgraph/BpmnGraph.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/component/mxgraph/BpmnGraph.ts b/src/component/mxgraph/BpmnGraph.ts index b1370bc4f0..9c95f9fdc8 100644 --- a/src/component/mxgraph/BpmnGraph.ts +++ b/src/component/mxgraph/BpmnGraph.ts @@ -17,8 +17,8 @@ limitations under the License. import type { FitOptions, ZoomConfiguration } from '../options'; import { FitType } from '../options'; import { ensurePositiveValue, ensureValidZoomConfiguration } from '../helpers/validators'; -import debounce from 'lodash.debounce'; -import throttle from 'lodash.throttle'; +import { debounce } from 'lodash-es'; +import { throttle } from 'lodash-es'; import { mxgraph } from './initializer'; import type { mxCellState, mxGraphView, mxPoint } from 'mxgraph'; From 68c96f002e08f5ef002477dfdf3883e31d16b3e8 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Sun, 21 May 2023 20:05:08 +0200 Subject: [PATCH 3/6] OverlayConverter.test.ts: simplify import to not rely on BpmnGraph (and lodash-es imports) --- test/unit/component/mxgraph/overlay/OverlayConverter.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/component/mxgraph/overlay/OverlayConverter.test.ts b/test/unit/component/mxgraph/overlay/OverlayConverter.test.ts index 1335ca45b8..0392e37413 100644 --- a/test/unit/component/mxgraph/overlay/OverlayConverter.test.ts +++ b/test/unit/component/mxgraph/overlay/OverlayConverter.test.ts @@ -19,8 +19,8 @@ limitations under the License. import { OverlayConverter } from '@lib/component/mxgraph/overlay/OverlayConverter'; import type { MxGraphCustomOverlayPosition } from '@lib/component/mxgraph/overlay/custom-overlay'; -import type { Overlay, OverlayPosition } from '@lib/bpmn-visualization'; -import { StyleDefault } from '@lib/bpmn-visualization'; +import { StyleDefault } from '@lib/component/mxgraph/style'; +import type { Overlay, OverlayPosition } from '@lib/component/registry/types'; describe('overlay converter', () => { const overlayConverter = new OverlayConverter(); From fc1feaaa0ac4e1c3e388afaf048b6f091c2138d6 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Sun, 21 May 2023 20:07:33 +0200 Subject: [PATCH 4/6] StyleComputer.test.ts: simplify import to not rely on BpmnGraph (and lodash-es imports) --- test/unit/component/mxgraph/renderer/StyleComputer.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/component/mxgraph/renderer/StyleComputer.test.ts b/test/unit/component/mxgraph/renderer/StyleComputer.test.ts index 24c81ab70c..f6ad5c60ab 100644 --- a/test/unit/component/mxgraph/renderer/StyleComputer.test.ts +++ b/test/unit/component/mxgraph/renderer/StyleComputer.test.ts @@ -28,7 +28,7 @@ import ShapeBpmnElement, { ShapeBpmnStartEvent, ShapeBpmnSubProcess, } from '@lib/model/bpmn/internal/shape/ShapeBpmnElement'; -import type { BpmnEventKind, GlobalTaskKind } from '@lib/bpmn-visualization'; +import type { BpmnEventKind, GlobalTaskKind } from '@lib/model/bpmn/internal'; import { AssociationDirectionKind, MessageVisibleKind, @@ -39,7 +39,7 @@ import { ShapeBpmnEventDefinitionKind, ShapeBpmnMarkerKind, ShapeBpmnSubProcessKind, -} from '@lib/bpmn-visualization'; +} from '@lib/model/bpmn/internal'; import Label, { Font } from '@lib/model/bpmn/internal/Label'; import { Edge } from '@lib/model/bpmn/internal/edge/edge'; import { AssociationFlow, MessageFlow, SequenceFlow } from '@lib/model/bpmn/internal/edge/flows'; From 1d27c00c850dd41efb907066faaf01c10e1cc6db Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Sun, 21 May 2023 20:08:04 +0200 Subject: [PATCH 5/6] BpmnGraph.ts simplify imports --- src/component/mxgraph/BpmnGraph.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/component/mxgraph/BpmnGraph.ts b/src/component/mxgraph/BpmnGraph.ts index 9c95f9fdc8..2227a6609e 100644 --- a/src/component/mxgraph/BpmnGraph.ts +++ b/src/component/mxgraph/BpmnGraph.ts @@ -17,8 +17,7 @@ limitations under the License. import type { FitOptions, ZoomConfiguration } from '../options'; import { FitType } from '../options'; import { ensurePositiveValue, ensureValidZoomConfiguration } from '../helpers/validators'; -import { debounce } from 'lodash-es'; -import { throttle } from 'lodash-es'; +import { debounce, throttle } from 'lodash-es'; import { mxgraph } from './initializer'; import type { mxCellState, mxGraphView, mxPoint } from 'mxgraph'; From 3729e7d81fe75e58dbd3cbd0ba7034fa479071a4 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Sun, 21 May 2023 20:49:58 +0200 Subject: [PATCH 6/6] Update the jest configuration of integration tests to make them run with lodash-es imports in the code --- test/integration/jest.config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/jest.config.js b/test/integration/jest.config.js index 2b907e9a2d..64c317ece8 100644 --- a/test/integration/jest.config.js +++ b/test/integration/jest.config.js @@ -30,7 +30,14 @@ module.exports = { }, ], }, - moduleNameMapper, + moduleNameMapper: { + ...moduleNameMapper, + // Hack to use lodash instead of lodash-es in integration tests. + // This is only to resolve the import, otherwise Jest fails to parse the lodash-es files. + // For more details, see https://github.com/process-analytics/bpmn-visualization-js/pull/2678 + // The lodash code is not called in integration tests, so changing the lodash implementation in used in not an issue. + '^lodash-es$': 'lodash', + }, collectCoverageFrom: ['src/**/*.{ts,js}'], coveragePathIgnorePatterns: ['/src/model/'], coverageReporters: ['lcov', 'text-summary'],