fix: ensure resource data always have resource path#11632
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that resource data always has a resource path to fix issue #11513. The change refactors the ResourceData construction to always include path information, replacing the builder pattern with dedicated constructors.
- Introduces
new_with_resourceandnew_with_pathconstructors for ResourceData - Updates all ResourceData creation sites to use the new constructors
- Adds test coverage for resolveForScheme hook to verify resource path is properly set
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_loader_runner/src/content.rs | Adds new constructors new_with_resource and new_with_path to ResourceData |
| crates/rspack_core/src/resolver/mod.rs | Updates Resource to ResourceData conversion to use new constructor |
| crates/rspack_core/src/normal_module_factory.rs | Replaces ResourceData::new calls with new constructors throughout |
| crates/rspack_plugin_schemes/src/file_uri.rs | Simplifies file URI handling using new_with_path constructor |
| crates/rspack_binding_api/src/modules/normal_module.rs | Updates match resource creation to use new_with_path |
| tests/rspack-test/configCases/hooks/resolve-for-scheme/ | Adds test to verify resource path is correctly set in resolveForScheme hook |
| crates/rspack_loader_swc/src/lib.rs | Removes unnecessary blank line |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
📦 Binary Size-limit
🎉 Size decreased by 128bytes from 47.23MB to 47.23MB (⬇️0.00%) |
CodSpeed Performance ReportMerging #11632 will not alter performanceComparing Summary
Footnotes |
|
@codex review |
|
Codex Review: Here are some suggestions. rspack/crates/rspack_loader_runner/src/content.rs Lines 212 to 219 in 8d5812f [P1] Allow set_path to populate empty resource_path The new Reply with About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback". |
|
This may be the cause of this bug we now have starting 1.5.4: #11717 |
Summary
Ensure resource data always have resource path
ResourceData::newtoResourceData::new_with_pathandResourceData::new_with_resource, you should usenew_with_pathwhen you already have the path, query, and fragment, otherwise you should usenew_with_resource, which will calculate path, query, and fragment automaticallyResourceData, make fields onResourceDataprivatefix #11513
Related links
Checklist