fix: plugins not loaded with legacy dev (#1764)

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Tomofumi Chiba
2023-09-13 16:09:50 +02:00
committed by GitHub
co-authored by Marvin Hagemeister
parent 42dc54500c
commit ec2f785455
14 changed files with 149 additions and 10 deletions
+4 -4
View File
@@ -12,15 +12,13 @@ import { startFromContext } from "../server/boot.ts";
export async function dev(
base: string,
entrypoint: string,
options: FreshOptions = {},
options?: FreshOptions,
) {
ensureMinDenoVersion();
// Run update check in background
updateCheck(DAY).catch(() => {});
entrypoint = new URL(entrypoint, base).href;
const dir = dirname(fromFileUrl(base));
let currentManifest: Manifest;
@@ -54,13 +52,15 @@ export async function dev(
if (isBuild) {
// Ensure that build dir is empty
await fs.emptyDir(outDir);
await build(join(dir, "fresh.gen.ts"), options);
await build(join(dir, "fresh.gen.ts"), options ?? {});
} else if (options) {
await startFromContext(ctx, options);
} else {
// Legacy entry point: Back then `dev.ts` would call `main.ts` but
// this causes duplicate plugin instantiation if both `dev.ts` and
// `main.ts` instantiate plugins.
Deno.env.set("__FRSH_LEGACY_DEV", "true");
entrypoint = new URL(entrypoint, base).href;
await import(entrypoint);
}
}