diff --git a/src/dev/dev_command.ts b/src/dev/dev_command.ts
index 222a2eb3..958b3b76 100644
--- a/src/dev/dev_command.ts
+++ b/src/dev/dev_command.ts
@@ -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);
}
}
diff --git a/src/server/context.ts b/src/server/context.ts
index d2eff40c..6e593b73 100644
--- a/src/server/context.ts
+++ b/src/server/context.ts
@@ -165,7 +165,11 @@ export class ServerContext {
// Restore snapshot if available
let snapshot: BuildSnapshot | null = null;
// Load from snapshot if not explicitly requested not to
- const loadFromSnapshot = !opts.skipSnapshot;
+ let loadFromSnapshot = !opts.skipSnapshot;
+ // We still need to check for a legacy entry point :S
+ if (Deno.env.has("__FRSH_LEGACY_DEV")) {
+ loadFromSnapshot = false;
+ }
if (loadFromSnapshot) {
const snapshotDirPath = join(
dirname(fromFileUrl(manifest.baseUrl)),
diff --git a/tests/dev_command_test.ts b/tests/dev_command_test.ts
new file mode 100644
index 00000000..5b7132f0
--- /dev/null
+++ b/tests/dev_command_test.ts
@@ -0,0 +1,27 @@
+import { waitForStyle, withPageName } from "$fresh/tests/test_utils.ts";
+
+Deno.test({
+ name: "dev_command config",
+ async fn() {
+ await withPageName(
+ "./tests/fixture_dev_config/main.ts",
+ async (page, address) => {
+ await page.goto(`${address}`);
+ await waitForStyle(page, "h1", "color", "rgb(220, 38, 38)");
+ },
+ );
+ },
+});
+
+Deno.test({
+ name: "dev_command legacy",
+ async fn() {
+ await withPageName(
+ "./tests/fixture_dev_legacy/main.ts",
+ async (page, address) => {
+ await page.goto(`${address}`);
+ await waitForStyle(page, "h1", "color", "rgb(220, 38, 38)");
+ },
+ );
+ },
+});
diff --git a/tests/fixture_dev_config/dev.ts b/tests/fixture_dev_config/dev.ts
new file mode 100644
index 00000000..1b53e2e7
--- /dev/null
+++ b/tests/fixture_dev_config/dev.ts
@@ -0,0 +1,4 @@
+import { dev } from "$fresh/src/dev/dev_command.ts";
+import config from "./fresh.config.ts";
+
+await dev(import.meta.url, "./main.ts", config);
diff --git a/tests/fixture_dev_config/fresh.config.ts b/tests/fixture_dev_config/fresh.config.ts
new file mode 100644
index 00000000..889a6862
--- /dev/null
+++ b/tests/fixture_dev_config/fresh.config.ts
@@ -0,0 +1,8 @@
+import { defineConfig } from "$fresh/server.ts";
+import twind from "$fresh/plugins/twind.ts";
+
+export default defineConfig({
+ plugins: [twind({
+ selfURL: import.meta.url,
+ })],
+});
diff --git a/tests/fixture_dev_config/fresh.gen.ts b/tests/fixture_dev_config/fresh.gen.ts
new file mode 100644
index 00000000..b321c0e0
--- /dev/null
+++ b/tests/fixture_dev_config/fresh.gen.ts
@@ -0,0 +1,15 @@
+// DO NOT EDIT. This file is generated by Fresh.
+// This file SHOULD be checked into source version control.
+// This file is automatically updated during development when running `dev.ts`.
+
+import * as $0 from "./routes/index.tsx";
+
+const manifest = {
+ routes: {
+ "./routes/index.tsx": $0,
+ },
+ islands: {},
+ baseUrl: import.meta.url,
+};
+
+export default manifest;
diff --git a/tests/fixture_dev_config/main.ts b/tests/fixture_dev_config/main.ts
new file mode 100644
index 00000000..fc935921
--- /dev/null
+++ b/tests/fixture_dev_config/main.ts
@@ -0,0 +1,11 @@
+///