Skip to content

Commit

Permalink
Import mockServer only if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanne committed Feb 12, 2025
1 parent 4154a7f commit f9905ad
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/dito/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import type { EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { mockServer } from "mocks/node";
import { renderToPipeableStream } from "react-dom/server";
import logResponseStatus from "utils/logging";
import { NonceProvider } from "utils/nonce";

if (process.env.MOCK_EXTERNAL_APIS && process.env.NODE_ENV !== "production") {
console.warn("Mock external APIs.");
mockServer.listen({
// This is going to perform unhandled requests
// but print no warning whatsoever when they happen.
onUnhandledRequest: "bypass",
await import("mocks/node").then(({ mockServer }) => {
console.warn("Mock external APIs.");
mockServer.listen({
// This is going to perform unhandled requests
// but print no warning whatsoever when they happen.
onUnhandledRequest: "bypass",
});
});
}

Expand Down

0 comments on commit f9905ad

Please sign in to comment.