feat: remove MODE global (#2483)

This commit is contained in:
Marvin Hagemeister
2024-06-03 16:54:37 +02:00
committed by GitHub
parent aa19b393e7
commit e007597ff3
5 changed files with 60 additions and 61 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
import * as path from "@std/path";
import { MODE, type Mode } from "./runtime/server/mod.ts";
import type { Mode } from "./runtime/server/mod.ts";
export interface FreshPlugin {
name: string;
@@ -69,7 +69,7 @@ export function normalizeConfig(options: FreshConfig): ResolvedFreshConfig {
},
basePath: options.basePath ?? "",
staticDir: options.staticDir ?? path.join(root, "static"),
mode: MODE,
mode: "production",
};
}
+6 -1
View File
@@ -70,6 +70,8 @@ export class Builder implements FreshBuilder {
.use(devErrorOverlay())
.mountApp("*", app);
devApp.config.mode = "development";
setBuildCache(
devApp,
new MemoryBuildCache(
@@ -97,6 +99,7 @@ export class Builder implements FreshBuilder {
this.#options.target,
),
);
return await this.#build(app, false);
}
@@ -117,7 +120,9 @@ export class Builder implements FreshBuilder {
// Ignore
}
const buildCache = getBuildCache(app)! as MemoryBuildCache | DiskBuildCache;
const buildCache = getBuildCache(app)! as
| MemoryBuildCache
| DiskBuildCache;
const runtimePath = dev
? "../runtime/client/dev.ts"
-4
View File
@@ -1,10 +1,6 @@
import { setMode } from "../runtime/server/mod.ts";
export { Builder, type FreshBuilder } from "./builder.ts";
export {
type OnTransformArgs,
type OnTransformOptions,
type TransformFn,
} from "./file_transformer.ts";
setMode("development");
+1 -6
View File
@@ -1,9 +1,4 @@
/**
* The mode Fresh can run in.
*/
export type Mode = "development" | "build" | "production";
export let MODE: Mode = "production";
export function setMode(mode: Mode) {
MODE = mode;
}
export type Mode = "development" | "production";