Repository: remix-run/react-router
File: packages/react-router/lib/router/router.ts (TypeScript)

Code before:
        return shouldLoad;
      }

      if (typeof defaultShouldRevalidate === "boolean") {
        return shouldRevalidateLoader(match, {
          ...unstable_shouldRevalidateArgs,
          defaultShouldRevalidate,
        });
      }
      return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
    },
    resolve(handlerOverride) {
      let { lazy, loader, action, middleware } = match.route;

      let callHandler =
        isUsingNewApi ||
        shouldLoad ||
        (handlerOverride &&
          !isMutationMethod(request.method) &&
          (lazy || loader));

      // If this match was marked `shouldLoad` due to a middleware and it
      // doesn't have a `loader` or `action` to run and no `lazy` to add one, then we can
      // just return undefined from the "loader" here
      let isMiddlewareOnlyRoute =
        middleware && middleware.length > 0 && !loader && !action && !lazy;

      if (callHandler && !isMiddlewareOnlyRoute) {
        return callLoaderOrAction({
          request,
          match,
          lazyHandlerPromise: _lazyPromises?.handler,
          lazyRoutePromise: _lazyPromises?.route,
          handlerOverride,
          scopedContext,
        });
      }
      return Promise.resolve({ type: ResultType.data, result: undefined });
    },
  };
}

function getTargetedDataStrategyMatches(
  mapRouteProperties: MapRoutePropertiesFunction,
  manifest: RouteManifest,
  request: Request,
  matches: AgnosticDataRouteMatch[],
  targetMatch: AgnosticDataRouteMatch,
  lazyRoutePropertiesToSkip: string[],
  scopedContext: unknown,
  shouldRevalidateArgs: DataStrategyMatch["unstable_shouldRevalidateArgs"] = null,

Review comment (suggestion):
```suggestion
        middleware && middleware.length > 0 && !loader && !lazy;
```

Code after:
        return shouldLoad;
      }

      if (typeof defaultShouldRevalidate === "boolean") {
        return shouldRevalidateLoader(match, {
          ...unstable_shouldRevalidateArgs,
          defaultShouldRevalidate,
        });
      }
      return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
    },
    resolve(handlerOverride) {
      let { lazy, loader, middleware } = match.route;

      let callHandler =
        isUsingNewApi ||
        shouldLoad ||
        (handlerOverride &&
          !isMutationMethod(request.method) &&
          (lazy || loader));

      // For GET requests, if this match was marked `shouldLoad` due to a
      // middleware and it doesn't have a `loader` to run and no `lazy` to add
      // one, then we can just return undefined from the "loader" here
      let isMiddlewareOnlyRoute =
        middleware && middleware.length > 0 && !loader && !lazy;

      if (
        callHandler &&
        (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)
      ) {
        return callLoaderOrAction({
          request,
          match,
          lazyHandlerPromise: _lazyPromises?.handler,
          lazyRoutePromise: _lazyPromises?.route,
          handlerOverride,
          scopedContext,
        });
      }
      return Promise.resolve({ type: ResultType.data, result: undefined });
    },
  };
}

function getTargetedDataStrategyMatches(
  mapRouteProperties: MapRoutePropertiesFunction,
  manifest: RouteManifest,
  request: Request,
  matches: AgnosticDataRouteMatch[],
  targetMatch: AgnosticDataRouteMatch,