Skip to content

feat: allow ModuleFactoryCreateData modify dependencies#7895

Merged
jerrykingxyz merged 1 commit intomainfrom
jerry/resolve
Sep 14, 2024
Merged

feat: allow ModuleFactoryCreateData modify dependencies#7895
jerrykingxyz merged 1 commit intomainfrom
jerry/resolve

Conversation

@jerrykingxyz
Copy link
Copy Markdown
Contributor

Summary

Currently when factorize module we can only get first of dependencies and can not update them.

#[plugin_hook(NormalModuleFactoryFactorize for SomePlugin)]
async fn factorize(&self, data: &mut ModuleFactoryCreateData) -> Result<Option<BoxModule>> {
  // 1. data.dependency is the first of dependencies, and there is no way to access all dependencies
  let dependency = data
    .dependency
    .as_module_dependency_mut().unwrap();
  // 2. the dependency is a cloned data from module_graph, and it will not rewrite to module_graph
  // so call the update method is useless
  dependency.set_xxx();
}

This PR will

  1. change the ModuleFactoryCreateData.dependency to ModuleFactoryCreateData.dependencies to make factorize hooks can access all dependencies.
  2. rewrite dependencies to module_graph at add task so that updates to all dependencies are saved.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Sep 13, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Sep 13, 2024

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 97ce0b3
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66e3fbe3029148000804f1c2

@jerrykingxyz jerrykingxyz requested a review from SyMind September 13, 2024 08:35
@jerrykingxyz jerrykingxyz merged commit 9dff544 into main Sep 14, 2024
@jerrykingxyz jerrykingxyz deleted the jerry/resolve branch September 14, 2024 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants