Skip to content

Commit 58fcd88

Browse files
committed
fix: middleware sort issues
1 parent 08fce4a commit 58fcd88

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/core/middleware/middleware-module.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,17 @@ export class MiddlewareModule<
150150
([moduleA], [moduleB]) => {
151151
const moduleARef = this.container.getModuleByKey(moduleA)!;
152152
const moduleBRef = this.container.getModuleByKey(moduleB)!;
153-
if (moduleARef.distance === Number.MAX_VALUE) {
153+
const isModuleAGlobal = moduleARef.distance === Number.MAX_VALUE;
154+
const isModuleBGlobal = moduleBRef.distance === Number.MAX_VALUE;
155+
if (isModuleAGlobal && isModuleBGlobal) {
156+
return 0;
157+
}
158+
if (isModuleAGlobal) {
154159
return -1;
155160
}
156-
if (moduleBRef.distance === Number.MAX_VALUE) {
161+
if (isModuleBGlobal) {
157162
return 1;
158163
}
159-
160164
return moduleARef.distance - moduleBRef.distance;
161165
},
162166
);

0 commit comments

Comments
 (0)