From b061c1ddf5afa5ed52ce049cc340d4c267d88850 Mon Sep 17 00:00:00 2001 From: Manuel Schiller Date: Sun, 27 Oct 2024 00:03:23 +0200 Subject: [PATCH 1/2] feat: allow custom HMR configuration fixes #394 --- packages/vinxi/lib/dev-server.js | 5 +++-- packages/vinxi/lib/vite-dev.d.ts | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/vinxi/lib/dev-server.js b/packages/vinxi/lib/dev-server.js index 381b6326..5b728728 100644 --- a/packages/vinxi/lib/dev-server.js +++ b/packages/vinxi/lib/dev-server.js @@ -8,7 +8,7 @@ import { join, normalize } from "./path.js"; export * from "./router-dev-plugins.js"; /** @typedef {{ force?: boolean; devtools?: boolean; port?: number; ws?: { port?: number }; https?: import('@vinxi/listhen').HTTPSOptions | boolean; }} DevConfigInput */ -/** @typedef {{ force: boolean; port: number; devtools: boolean; ws: { port: number }; https?: import('@vinxi/listhen').Certificate; }} DevConfig */ +/** @typedef {{ force: boolean; port: number; devtools: boolean; ws: { port: number }; https?: import('@vinxi/listhen').Certificate; hmr?: Exclude["hmr"], boolean> }} DevConfig */ /** * @@ -49,7 +49,7 @@ export async function createViteDevServer(config) { export async function createViteHandler(router, app, serveConfig) { const vite = await import("vite"); const { getRandomPort } = await import("get-port-please"); - const port = await getRandomPort(); + const port = serveConfig.hmr?.port ?? await getRandomPort(); const plugins = [ // ...(serveConfig.devtools ? [inspect()] : []), ...(((await router.internals.type.dev.plugins?.(router, app)) ?? []).filter( @@ -81,6 +81,7 @@ export async function createViteHandler(router, app, serveConfig) { }, middlewareMode: true, hmr: { + ...serveConfig.hmr, port, }, https: serveConfig.https, diff --git a/packages/vinxi/lib/vite-dev.d.ts b/packages/vinxi/lib/vite-dev.d.ts index a27f1bca..aed76edd 100644 --- a/packages/vinxi/lib/vite-dev.d.ts +++ b/packages/vinxi/lib/vite-dev.d.ts @@ -48,6 +48,9 @@ export type CustomizableConfig = Omit< "outDir" | "ssr" | "ssrManifest" | "rollupOptions" > & { rollupOptions?: Omit; + server?: { + hmr?: Exclude["hmr"], boolean>; + } }; }; From 6cb0bf96efb89fb0e5535f5bbe6fb78cbf26401a Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Thu, 31 Oct 2024 10:29:37 -0700 Subject: [PATCH 2/2] Create light-panthers-bow.md --- .changeset/light-panthers-bow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/light-panthers-bow.md diff --git a/.changeset/light-panthers-bow.md b/.changeset/light-panthers-bow.md new file mode 100644 index 00000000..01c10fcb --- /dev/null +++ b/.changeset/light-panthers-bow.md @@ -0,0 +1,5 @@ +--- +"vinxi": patch +--- + +feat: allow custom HMR configuration