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

refactor(new_split_chunks): remove unused code and add more comments #2947

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

hyf0
Copy link
Contributor

@hyf0 hyf0 commented Apr 26, 2023

Related issue (if exists)

Summary

  • No behaviors change
  • Add more comments
  • Remove unused code
  • Extract some code into separate functions.

🤖 Generated by Copilot at b4f70db

This pull request refactors the rspack_plugin_split_chunks_new crate, which implements a plugin for the rspack web bundler that splits modules into chunks based on cache groups. It introduces new structs Chunk and MatchedItem to simplify the logic and data structures of the plugin, and it improves the readability, error handling, and debugging of the code. It also removes some unused and redundant types and fields.

Walkthrough

🤖 Generated by Copilot at b4f70db

  • Refactor the logic of the split chunks plugin to use chunks and module groups instead of modules and cache groups (link, link, link, link, link, link, link)
  • Extract a new method get_corresponding_chunk to create or find a chunk for a module group (link)
  • Rename the name field of ModuleGroup to chunk_name and move the struct definition to common.rs (link, link)
  • Rename the prepare_module_and_chunks_info_map method to prepare_module_group_map and change the return type to DashMap<String, ModuleGroup> (link, link)
  • Introduce a new struct MatchedItem to represent a module that meets the requirements of a cache group (link, link)
  • Rename the used_chunks parameter and variable to original_chunks in the move_modules_to_new_chunk_and_remove_from_old_chunks method (link, link)
  • Improve the error handling and debugging of the plugin code (link)
    • Add a debug assertion that the new_chunk_ukey is not equal to the original_chunk in the split_from_original_chunks method (link)
  • Remove unused and unnecessary code from the plugin code (link, link, link)
    • Remove an unused type alias for CacheGroupNameGetter from common.rs (link)
    • Remove an unused struct definition for _OverallOptions and an unused field for overall from the SplitChunksPlugin struct (link, link)
  • Add type annotations and comments to improve the readability and type safety of the code (link, link)
    • Add a type annotation for the iter variable in the find_best_module_group method (link)
    • Add comments to explain the filtering logic and the fields of the MatchedItem struct (link)

@hyf0 hyf0 requested a review from h-a-n-a April 26, 2023 12:35
@changeset-bot
Copy link

changeset-bot bot commented Apr 26, 2023

⚠️ No Changeset found

Latest commit: b4f70db

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Apr 26, 2023
@hyf0 hyf0 enabled auto-merge April 26, 2023 12:49
@hyf0 hyf0 requested a review from ahabhgk April 26, 2023 12:49
@hyf0 hyf0 added this pull request to the merge queue Apr 27, 2023
Merged via the queue into main with commit 5e07ddd Apr 27, 2023
@hyf0 hyf0 deleted the hyf_18391208390129038 branch April 27, 2023 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants