-
-
Notifications
You must be signed in to change notification settings - Fork 781
Labels
pending triageThe issue/PR is currently untouched.The issue/PR is currently untouched.
Description
System Info
macOS
Details
I have a build that compiled a few thousand modules in 9 seconds. About 5% of the build time is wasted in creating the loaderContext's resolve function (which is never called in my case). The slow code is the first line of:
rspack/packages/rspack/src/loader-runner/index.ts
Lines 633 to 636 in b271e1b
| const resolver = compiler._lastCompilation!.resolverFactory.get("normal"); | |
| loaderContext.resolve = function resolve(context, request, callback) { | |
| resolver.resolve({}, context, request, getResolveContext(), callback); | |
| }; |
To confirm the issue, I tried hacking my installed index.js file (version 1.2.5) so that resolver was only created if called:
let resolver;
loaderContext.resolve = function resolve2(context3, request, callback) {
if (!resolver)
resolver = compiler._lastCompilation.resolverFactory.get("normal");
resolver.resolve({}, context3, request, getResolveContext(), callback);
};With the above change, the overall time for the runLoaders function decreased by roughly the 438ms shown above.
Reproduce link
No response
Reproduce Steps
Run a build with RSPACK_PROFILE=JSCPU, and then look in the timing information for the runLoaders function.
Currently:
With the "fix" above:

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
pending triageThe issue/PR is currently untouched.The issue/PR is currently untouched.