-
Notifications
You must be signed in to change notification settings - Fork 57
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
Optimize lodash use for tree-shaking #1828
Optimize lodash use for tree-shaking #1828
Conversation
Signed-off-by: Miki <[email protected]>
856db36
to
90c2777
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, left a question
@@ -19,7 +19,8 @@ import { | |||
EuiToolTip, | |||
} from '@elastic/eui'; | |||
import { i18n } from '@osd/i18n'; | |||
import { isEmpty, isEqual } from 'lodash'; | |||
import isEmpty from 'lodash/isEmpty'; | |||
import isEqual from 'lodash/isEqual'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can https://webpack.js.org/configuration/optimization/#optimizationusedexports help to tree shake the
import { isEmpty, isEqual } from 'lodash';
or maybe lodash-es
since it's required by core
https://github.com/opensearch-project/OpenSearch-Dashboards/blob/f728b5ae92de732bcf0f491ecf4f90f987291593/yarn.lock#L12596
import { isEmpty, isEqual } from 'lodash-es';
I'm asking because seems devs need to manually type import isEmpty from 'lodash/isEmpty';
as tsserver doesn't suggest default exports. someone using lodash could again introduce import { xxx } from 'lodash';
and bring in the whole library
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-observability/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/dashboards-observability/backport-2.x
# Create a new branch
git switch --create backport/backport-1828-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7a517c9fb93418ac1502fd437a58e6294370125c
# Push it to GitHub
git push --set-upstream origin backport/backport-1828-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-observability/backport-2.x Then, create a pull request where the |
Signed-off-by: Simeon Widdis <[email protected]>
Description
Optimize lodash use for tree-shaking: Not a huge impact but a necessary step. There are nearly 550 linting problems which are unrelated to the changes.
Additionally, the incorrect version of
@types/react
(18) was included in the deps which was corrected in this change.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.