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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove dependency parent module identifier #3024

Merged
merged 1 commit into from
May 6, 2023

Conversation

underfin
Copy link
Collaborator

@underfin underfin commented May 5, 2023

Related issue (if exists)

Summary

  • remove the dependency parent module identifier, because already has the dependency id and can search for it
  • add make_failed_module to avoid dependencies passing through & refactor some logic of rebuild to implement the first work.

馃 Generated by Copilot at c13d60d

This pull request refactors the dependency system in the rspack_core package to simplify the dependency representation and the compilation logic. It removes the parent_module_identifier field and methods from various dependency structs, and uses the module graph to store and track the parent modules of dependencies. It also introduces a new type BuildDependency, which is a tuple of (DependencyId, Option<ModuleIdentifier>), and uses it to handle dependencies that need to be rebuilt. It updates the compile method of the Compilation struct and the related methods of the Compiler and Hmr structs to accept and process BuildDependency values. It also adds a .changeset file to document the changes for the changesets tool.

Walkthrough

馃 Generated by Copilot at c13d60d

  • Refactor the dependency system in the rspack_core package to store the parent module identifier of each dependency in the module graph, instead of in the dependency itself (link)
  • Change the SetupMakeParam::ForceBuildDeps variant to take a HashSet<BuildDependency> instead of a HashSet<DependencyId>, where BuildDependency is a new type alias for a tuple of (DependencyId, Option<ModuleIdentifier>) (link)
  • Add two new fields to the Compilation struct: make_failed_module and make_failed_dependencies, which are HashSets of ModuleIdentifier and BuildDependency, respectively, and are used to store the modules and dependencies that failed to build during the compilation (link, link)
  • Modify the compile method of the Compilation struct to use the new fields and parameters, and to handle the module creation and error handling for each dependency that needs to be rebuilt (link, link, link, link, link, link, link, link, link)
  • Modify the handle_hmr method of the Hmr struct to convert the deps variable into a HashSet<BuildDependency> and pass it to the compile method of the Compilation struct (link)
  • Modify the build method of the Compiler struct to convert the deps variable into a HashSet<BuildDependency> and pass it to the compile method of the Compilation struct (link)
  • Remove the dependencies field from the AddTaskResult, FactorizeTask, BuildTask, and BuildTaskResult structs, and the ModuleReused and ModuleAdded variants, in the queue.rs file, since they are no longer needed (link, link, link, link, link, link)
  • Remove the parent_module_identifier field and methods from the CommonJsRequireContextDependency, EsmDynamicImportDependency, and ImportContextDependency structs, and the parent_module_identifier method from the ConstDependency, ContextElementDependency, and EntryDependency structs, in the dependency module, since they are no longer needed (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Remove the DynEq and DynHash imports from the mod.rs file in the dependency module, since they are no longer required by the Dependency and ModuleDependency traits (link)

@changeset-bot
Copy link

changeset-bot bot commented May 5, 2023

馃 Changeset detected

Latest commit: 87386b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@rspack/core Patch
@rspack/cli Patch
@rspack/dev-middleware Patch
@rspack/dev-server Patch
@rspack/plugin-html Patch
webpack-test Patch
benchmarkcase-rspack-react-refresh Patch
@rspack/postcss-loader Patch
@rspack/dev-client Patch
@rspack/plugin-minify Patch
@rspack/plugin-node-polyfill Patch
@rspack/binding-darwin-arm64 Patch
@rspack/binding-darwin-x64 Patch
@rspack/binding-linux-x64-gnu Patch
@rspack/binding-win32-x64-msvc Patch
@rspack/binding Patch
@rspack/fs Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label May 5, 2023
@underfin underfin enabled auto-merge May 5, 2023 12:03
jerrykingxyz
jerrykingxyz previously approved these changes May 6, 2023
@underfin underfin force-pushed the remove-dependency-parent-module-identfiler branch from c13d60d to 87386b8 Compare May 6, 2023 03:15
@underfin underfin added this pull request to the merge queue May 6, 2023
Merged via the queue into main with commit 1d76fec May 6, 2023
8 checks passed
@underfin underfin deleted the remove-dependency-parent-module-identfiler branch May 6, 2023 03:19
This was referenced May 9, 2023
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.

None yet

2 participants