Skip to content

Conversation

jerrykingxyz
Copy link
Contributor

Summary

Related links

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings September 28, 2025 11:56
@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Sep 28, 2025
Copy link

netlify bot commented Sep 28, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 2287809
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68d922630750cb00087b4a30
😎 Deploy Preview https://deploy-preview-11780--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the codebase to remove the normalModule.loaders field from the NormalModule structure and move loader handling to a more appropriate location. The primary purpose is to decouple loader information from individual modules and centralize it in the build context.

Key changes:

  • Remove loaders field from NormalModule and related loader access methods
  • Move loaders to BuildContext and ModuleFactoryResult structures
  • Remove rspack_cacheable annotations and dependencies from loader-related code
  • Update module creation patterns to use the new ModuleFactoryResult::new_with_module method

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rspack_core/src/normal_module.rs Removes loaders field and methods from NormalModule, updates build process to use build_context.loaders
crates/rspack_core/src/module_factory.rs Adds loaders field to ModuleFactoryResult and updates factory trait
crates/rspack_core/src/normal_module_factory.rs Updates module creation to populate loaders in ModuleFactoryResult
crates/rspack_core/src/module.rs Adds loaders field to BuildContext structure
crates/rspack_loader_*/src/lib.rs Removes cacheable annotations from loader implementations
crates/rspack_plugin_/src/.rs Updates module creation to use new factory result pattern
crates/rspack_binding_api/src/modules/normal_module.rs Removes loaders exposure from JavaScript bindings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


#[async_trait::async_trait]
pub trait ModuleFactory: Debug + Sync + Send {
pub trait ModuleFactory: std::fmt::Debug + Sync + Send {
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The trait bound should use the standard Debug import instead of the fully qualified path std::fmt::Debug. Since derive_more::Debug is imported at the top, consider using just Debug for consistency with the rest of the codebase.

Suggested change
pub trait ModuleFactory: std::fmt::Debug + Sync + Send {
pub trait ModuleFactory: Debug + Sync + Send {

Copilot uses AI. Check for mistakes.

Comment on lines +589 to +592
Ok(Some(ModuleFactoryResult {
module: Some(module),
loaders,
}))
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This manual struct construction could be replaced with a more explicit constructor method. Consider adding a new_with_module_and_loaders method to ModuleFactoryResult for better API consistency.

Suggested change
Ok(Some(ModuleFactoryResult {
module: Some(module),
loaders,
}))
Ok(Some(ModuleFactoryResult::new_with_module_and_loaders(Some(module), loaders)))

Copilot uses AI. Check for mistakes.

Copy link
Contributor

📦 Binary Size-limit

Comparing 2287809 to perf: avoid unnecessary source map creation (#11773) by CPunisher

🎉 Size decreased by 25.00KB from 47.89MB to 47.86MB (⬇️0.05%)

Copy link

codspeed-hq bot commented Sep 28, 2025

CodSpeed Performance Report

Merging #11780 will improve performances by 21.38%

Comparing jerry/loader (2287809) with main (f72a069)1

Summary

⚡ 1 improvement
✅ 16 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
js@is css mod 87.4 µs 72 µs +21.38%

Footnotes

  1. No successful run was found on main (e88f22d) during the generation of this report, so f72a069 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: refactor team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant