Skip to content
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

[Feature] Use lodash-es instead of lodash. #1587

Open
ni00 opened this issue Feb 21, 2024 · 1 comment
Open

[Feature] Use lodash-es instead of lodash. #1587

ni00 opened this issue Feb 21, 2024 · 1 comment
Assignees
Labels
CLI MQTTX CLI dependencies Pull requests that update a dependency file desktop MQTTX Desktop enhancement New feature or request feature This pr is a feature web MQTTX Web

Comments

@ni00
Copy link
Contributor

ni00 commented Feb 21, 2024

Motivation

我注意到MQTTX在使用lodash库时,并未选择lodash-es,而且在很多地方是全局引入而非按需引入。在构建过程中,优先选择ES模块格式的依赖包,能更好地支持tree-shaking,从而优化打包结果。同时,由于MQTTX是基于electron的应用,我们无需担心对es5的兼容问题。如果我们采用lodash-es并进行按需引入,那么构建出来的产物将会更小,性能也会得到提升。

I noticed that MQTTX is using the lodash library, but did not choose lodash-es, and in many places it is globally imported instead of being imported on demand. During the build process, prioritizing dependencies in the ES module format can better support tree-shaking, thereby optimizing the packaging results. At the same time, since MQTTX is an application based on electron, we don't need to worry about compatibility with es5. If we use lodash-es and import it on demand, the resulting build will be smaller and performance will be improved.

图片
图片

Detailed design

  1. 使用lodash-es库替代lodash库
  2. 按需引入lodash-es库中的函数

  1. Use the lodash-es library instead of the lodash library.
  2. Import functions from the lodash-es library as needed.

Alternatives

保持现状,因为这个性能提升是有限的,预计也只能减少100KB的产物。

Maintain the status quo, because this performance improvement is limited, and it is expected to only reduce the product by 100KB.

More detail (optional)

https://vuejs.org/guide/best-practices/performance.html

图片

@ni00 ni00 added the feature This pr is a feature label Feb 21, 2024
@github-project-automation github-project-automation bot moved this to Backlog in MQTTX Feb 21, 2024
@ysfscream ysfscream added enhancement New feature or request desktop MQTTX Desktop CLI MQTTX CLI web MQTTX Web labels Feb 21, 2024
@ysfscream ysfscream added this to the v2.0.0-alpha.1 milestone Feb 21, 2024
@ysfscream
Copy link
Member

Hi @ni00,

Thanks for your suggestion! We recognize the optimization potential in using lodash-es over lodash. Our usage of lodash through indirect dependencies has its drawbacks. For MQTTX 1.9, the urgency for such changes is not significant, but for version 2.0, we plan to make improvements by adopting pnpm.

A critical advantage of pnpm is its dependency isolation feature, which prevents version conflicts between packages with a unique symlinking strategy, ensuring accuracy and stability in project dependencies. This will enhance our dependency management, especially for standardizing libraries like lodash.

We look forward to these improvements in version 2.0. Thanks for your contribution and support!

@ysfscream ysfscream added the dependencies Pull requests that update a dependency file label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI MQTTX CLI dependencies Pull requests that update a dependency file desktop MQTTX Desktop enhancement New feature or request feature This pr is a feature web MQTTX Web
Projects
Status: Backlog
Development

No branches or pull requests

2 participants