Skip to content

Commit

Permalink
chore(deps): switch from lodash-es to es-toolkit (#3142)
Browse files Browse the repository at this point in the history
> es-toolkit is a state-of-the-art, high-performance JavaScript utility
library with a small bundle size and strong type annotations.

Advantages for `bpmn-visualization`:
  - receive more updates
  - optimize for ESM
  - better tree-shaking
- provide types out of the box (for lodash-es, we needed to use a
package provided by DefinitevlyTyped)
- provide CommonJS files as well, so we are no longer forced to use a
trick as we did for lodash-es in the jest configuration of the
integration test (which doesn't provide CommonJS file)

The performance tests were run on Ubuntu 22. 
They include results for master a5886d1 and for switching to
es-toolkit.
  • Loading branch information
tbouffard authored Aug 26, 2024
1 parent a1c7c26 commit 3c4c4ea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 51 deletions.
55 changes: 16 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
},
"dependencies": {
"@typed-mxgraph/typed-mxgraph": "~1.0.8",
"es-toolkit": "~1.16.0",
"fast-xml-parser": "4.4.1",
"lodash-es": "~4.17.21",
"mxgraph": "4.2.2",
"strnum": "1.0.5"
},
Expand All @@ -118,7 +118,6 @@
"@rollup/plugin-terser": "~0.4.4",
"@types/debug": "~4.1.12",
"@types/jest-image-snapshot": "~6.4.0",
"@types/lodash-es": "~4.17.12",
"@types/minimist": "~1.2.5",
"@typescript-eslint/eslint-plugin": "~7.18.0",
"@typescript-eslint/parser": "~7.18.0",
Expand Down
2 changes: 1 addition & 1 deletion src/component/mxgraph/BpmnGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import type { FitOptions, ZoomConfiguration } from '../options';
import type { mxCellRenderer, mxCellState, mxGraphView, mxPoint } from 'mxgraph';

import { debounce, throttle } from 'lodash-es';
import { debounce, throttle } from 'es-toolkit';

import { ensurePositiveValue, ensureValidZoomConfiguration } from '../helpers/validators';
import { FitType } from '../options';
Expand Down
9 changes: 1 addition & 8 deletions test/integration/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ module.exports = {
},
],
},
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',
},
moduleNameMapper,
collectCoverageFrom: ['src/**/*.{ts,js}'],
coveragePathIgnorePatterns: ['/src/model/'],
coverageReporters: ['lcov', 'text-summary'],
Expand Down
Loading

0 comments on commit 3c4c4ea

Please # to comment.