Skip to content

Commit

Permalink
fix: make dev compiler lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
deckchairlabs committed Jul 28, 2023
1 parent e58ec93 commit 9d77a61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/middleware/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { extname, join, sprintf, toFileUrl } from "../deps.ts";
import { log } from "../logger.ts";
import type { CompilerOptions, Context, Next } from "../types.ts";

const { transform } = await createCompiler();

export const compiler = (options: CompilerOptions) => {
const {
root,
jsxImportSource = "react",
} = options;

return async (context: Context, next: Next) => {
const { transform } = await createCompiler();

const method = context.req.method;
const requestPathname = decodeURIComponent(
new URL(context.req.url).pathname,
Expand Down
2 changes: 0 additions & 2 deletions lib/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ULTRA_COMPILER_PATH } from "./constants.ts";
import { assert, dotenv, Hono, resolve, toFileUrl } from "./deps.ts";
import { ensureMinDenoVersion } from "./dev/ensureMinDenoVersion.ts";
import { log } from "./logger.ts";
import { serveStatic } from "./middleware/serveStatic.ts";
import { CreateServerOptions, Env, Mode } from "./types.ts";
import { UltraServer } from "./ultra.ts";
Expand Down Expand Up @@ -91,7 +90,6 @@ export async function createServer<
}));

if (mode === "development") {
log.info("Loading compiler");
const { compiler } = await import("./middleware/compiler.ts");

// deno-fmt-ignore
Expand Down

0 comments on commit 9d77a61

Please sign in to comment.