-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): use the lodash-es
dependency
#2678
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tbouffard
added
dependencies
Pull requests that update a dependency (dev or runtime)
javascript
Pull requests that update Javascript code
labels
May 11, 2023
♻️ PR Preview 70f1ebe has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
♻️ PR Preview 70f1ebe has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
1 task
…nd lodash-es imports)
…lodash-es imports)
…ith lodash-es imports in the code
csouchet
approved these changes
May 22, 2023
Kudos, SonarCloud Quality Gate passed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dependencies
Pull requests that update a dependency (dev or runtime)
javascript
Pull requests that update Javascript code
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, there were 2 CommonJS dependencies:
lodash-throttle
andlodash-debounce
.It is now replaced by a single ESM dependency:
lodash-es
.The change reduces the size of the minified IIFE bundle from 1.2kb.
With the CommonJS lodash dependencies, as the
throttle
implementation callsdebounce
,debounce
is present inlodash-throttle
. In this case, rollup (that generates the bundle) is unable to tree shaked the duplication.In the resulting bpmn-viusalization IIFE bundle, there are 2
debounce
implementation: debounce (fromlodash-debounce
)and debounce$1 (fromlodash-throttle
).Notice that the previous CommonJS dependencies only includes the necessary code to run. The new
lodash-es
dependency includes the whole lodash code which increases the size at installation on dev machine.The usage of a ESM dependency also provides a better interoperability for bundlers. For example, Angular 15 warns usage of CommonJS dependencies. In the past, application integrating bpmn-visualization had to add configuration to remove the warning emited because of lodash dependencies.
This also reduces the number of dependencies from 4 (2 libs and their related types) to 2.
Notes
bpmn-visualization.min.js
size decrease: 1211b / 1.2kbResources
Some alternatives to lodash for debounce/throttle:
Tasks
test/unit/component/mxgraph/renderer/StyleComputer.test.ts:32:1
andtest/unit/component/mxgraph/overlay/OverlayConverter.test.ts:23:1
. Fixed by using proposal described in SyntaxError: Unexpected token export when running tests for library that imports lodash-es nrwl/nx#6282 (comment) and SyntaxError: Unexpected token export when running tests for library that imports lodash-es nrwl/nx#6282 (comment) in integration tests and making unit tests not importing classes transitively depending of 'lodash-es' imports.`