feat: Add experimental vite plugin (#3184)

This PR adds a vite plugin for Fresh. This enables:

- HMR (only for islands for now)
- self-contained output bundles for both server and client
- smarter chunking

It uses vite's new Environment API under the hood.
This commit is contained in:
Marvin Hagemeister
2025-08-04 18:30:05 +02:00
committed by GitHub
parent 57596dc406
commit a1571b76ed
54 changed files with 2181 additions and 742 deletions
+5 -2
View File
@@ -83,7 +83,7 @@ export function serveMiddleware<T>(
(() => new Response("not found", { status: 404 }));
const config = options.config ?? DEFAULT_CONFIG;
const buildCache = options.buildCache ??
new MockBuildCache<T>([]);
new MockBuildCache<T>([], options.config?.mode ?? "production");
const ctx = new Context<T>(
req,
@@ -149,9 +149,12 @@ export async function withTmpDir(
export class MockBuildCache<State> implements BuildCache<State> {
#files: FsRouteFile<State>[];
root = "";
clientEntry = "";
islandRegistry: ServerIslandRegistry = new Map();
features = { errorOverlay: false };
constructor(files: FsRouteFile<State>[]) {
constructor(files: FsRouteFile<State>[], mode: "development" | "production") {
this.features.errorOverlay = mode === "development";
this.#files = files;
}