refactor: replace references of options with config (#1903)
This commit is contained in:
+2
-2
@@ -3,10 +3,10 @@ import { join } from "../server/deps.ts";
|
||||
import { colors, fs } from "./deps.ts";
|
||||
import { BuildSnapshotJson } from "../build/mod.ts";
|
||||
import { BUILD_ID } from "../server/build_id.ts";
|
||||
import { InternalFreshOptions } from "../server/types.ts";
|
||||
import { InternalFreshConfig } from "../server/types.ts";
|
||||
|
||||
export async function build(
|
||||
config: InternalFreshOptions,
|
||||
config: InternalFreshConfig,
|
||||
) {
|
||||
// Ensure that build dir is empty
|
||||
await fs.emptyDir(config.build.outDir);
|
||||
|
||||
+15
-15
@@ -1,6 +1,6 @@
|
||||
import { updateCheck } from "./update_check.ts";
|
||||
import { DAY, dirname, fromFileUrl, join, toFileUrl } from "./deps.ts";
|
||||
import { FreshOptions, Manifest as ServerManifest } from "../server/mod.ts";
|
||||
import { FreshConfig, Manifest as ServerManifest } from "../server/mod.ts";
|
||||
import { build } from "./build.ts";
|
||||
import { collect, ensureMinDenoVersion, generate, Manifest } from "./mod.ts";
|
||||
import { startFromContext } from "../server/boot.ts";
|
||||
@@ -10,7 +10,7 @@ import { getServerContext } from "$fresh/src/server/context.ts";
|
||||
export async function dev(
|
||||
base: string,
|
||||
entrypoint: string,
|
||||
options?: FreshOptions,
|
||||
config?: FreshConfig,
|
||||
) {
|
||||
ensureMinDenoVersion();
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function dev(
|
||||
} else {
|
||||
currentManifest = { islands: [], routes: [] };
|
||||
}
|
||||
const newManifest = await collect(dir, options?.router?.ignoreFilePattern);
|
||||
const newManifest = await collect(dir, config?.router?.ignoreFilePattern);
|
||||
Deno.env.set("FRSH_DEV_PREVIOUS_MANIFEST", JSON.stringify(newManifest));
|
||||
|
||||
const manifestChanged =
|
||||
@@ -39,22 +39,22 @@ export async function dev(
|
||||
.default as ServerManifest;
|
||||
|
||||
if (Deno.args.includes("build")) {
|
||||
const config = await getFreshConfigWithDefaults(
|
||||
const configWithDefaults = await getFreshConfigWithDefaults(
|
||||
manifest,
|
||||
options ?? {},
|
||||
config ?? {},
|
||||
);
|
||||
config.dev = false;
|
||||
config.loadSnapshot = false;
|
||||
await build(config);
|
||||
} else if (options) {
|
||||
const config = await getFreshConfigWithDefaults(
|
||||
configWithDefaults.dev = false;
|
||||
configWithDefaults.loadSnapshot = false;
|
||||
await build(configWithDefaults);
|
||||
} else if (config) {
|
||||
const configWithDefaults = await getFreshConfigWithDefaults(
|
||||
manifest,
|
||||
options,
|
||||
config,
|
||||
);
|
||||
config.dev = true;
|
||||
config.loadSnapshot = false;
|
||||
const ctx = await getServerContext(config);
|
||||
await startFromContext(ctx, config.server);
|
||||
configWithDefaults.dev = true;
|
||||
configWithDefaults.loadSnapshot = false;
|
||||
const ctx = await getServerContext(configWithDefaults);
|
||||
await startFromContext(ctx, configWithDefaults.server);
|
||||
} else {
|
||||
// Legacy entry point: Back then `dev.ts` would call `main.ts` but
|
||||
// this causes duplicate plugin instantiation if both `dev.ts` and
|
||||
|
||||
Reference in New Issue
Block a user