perf: get resolve in external plugin#11111
Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
❌ Size increased by 15.38KB from 48.91MB to 48.92MB (⬆️0.03%) |
424cc2d to
eb61964
Compare
CodSpeed Performance ReportMerging #11111 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes performance in the external plugin by replacing the Resolver-based approach with a more efficient resolve mechanism. The change aims to improve resolution performance when handling external dependencies.
- Replaces
Resolverclass usage withgetRawResolveadapter function - Implements direct resolution using
ctx.getResolve()instead of creating new Resolver instances - Moves resolution logic from TypeScript to Rust for better performance
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/rspack/src/builtin-plugin/ExternalsPlugin.ts | Refactors getResolve method to use new adapter-based resolution approach |
| crates/rspack_binding_api/src/raw_options/raw_external.rs | Adds native Rust implementation of get_resolve method with improved performance |
Comments suppressed due to low confidence (3)
packages/rspack/src/builtin-plugin/ExternalsPlugin.ts:83
- [nitpick] Variable names 'res' and 'rej' are abbreviated. Consider using 'resolve' and 'reject' for better readability.
return new Promise((res, rej) => {
crates/rspack_binding_api/src/raw_options/raw_external.rs:122
- [nitpick] Variable name 'first' is ambiguous. Consider a more descriptive name like 'base_resolve_options' or 'default_resolve_options'.
let first = Arc::new(self.resolve_options_with_dependency_type.clone());
crates/rspack_binding_api/src/raw_options/raw_external.rs:123
- [nitpick] Variable name 'second' is ambiguous. Consider a more descriptive name like 'merged_resolve_options' or 'override_resolve_options'.
let second = Arc::new(
Summary
Directly implement the getResolve method through NAPI to avoid the overhead of constructing
JsResolvermultiple times.In this Next.js benchmark case https://github.com/SyMind/shadcn-ui/tree/next-rspack, build performance improved from 17s to 16s.
Before
After
Related links
Checklist