Description
What problem does this feature solve?
RFC: Detecting Similar Dependencies in the Rspack or Webpack Build Analysis Tool
Summary
Introduce a new feature in the Rspack or webpack build analysis tool to detect the usage of similar dependencies, such as using both lodash
and lodash-es
, as well as mixing dayjs
and moment
. This feature will also consider the use of AI technology to provide more automated and comprehensive detection of similar dependencies.
Motivation
In modern frontend development, developers often inadvertently introduce similar or alternative dependencies, leading to redundant code and increased bundle size. For example, using both lodash
and lodash-es
may inflate the build size, while the mixing of dayjs
and moment
can lead to unnecessary dependencies. Identifying these similar dependencies can optimize the build output, reduce the final bundle size, and improve application performance.
Detailed Design
Feature Implementation:
-
Similar Dependency Detection:
The build analysis tool scans the project's dependencies during the compilation process to discover similar libraries (such aslodash
andlodash-es
,dayjs
andmoment
in the examples above). -
Rule Configuration:
Allows users to customize the rules for identifying similar dependencies and supports setting similarity thresholds.
AI Integration:
-
Intelligent Suggestions:
Utilize machine learning models to analyze project dependencies and provide intelligent recommendations for replacing or eliminating similar dependencies. -
Context Understanding:
Use context analysis to identify which similar dependencies can be replaced in actual usage, potentially providing example code.
What does the proposed API look like?
inner Similar-detected-plugin