From d018660b95047fd61a3769c0803838f19da5416b Mon Sep 17 00:00:00 2001 From: Iha Shin Date: Fri, 30 Aug 2024 16:30:35 +0900 Subject: [PATCH 1/2] Add support for Vite --mode --- packages/vinxi/bin/cli.mjs | 5 +++++ packages/vinxi/lib/app.js | 5 +++++ packages/vinxi/lib/build.js | 1 + packages/vinxi/lib/dev-server.js | 1 + packages/vinxi/lib/load-app.js | 2 ++ 5 files changed, 14 insertions(+) diff --git a/packages/vinxi/bin/cli.mjs b/packages/vinxi/bin/cli.mjs index d11ac0e8..8d4447a9 100755 --- a/packages/vinxi/bin/cli.mjs +++ b/packages/vinxi/bin/cli.mjs @@ -23,6 +23,10 @@ const command = defineCommand({ type: "string", description: "Path to config file (default: app.config.js)", }, + mode: { + type: "string", + description: "Vite mode", + } }, subCommands: () => ({ dev: { @@ -419,6 +423,7 @@ const command = defineCommand({ const { fetchModule, createServer } = await import("vite"); const { ViteRuntime, ESModulesRunner } = await import("vite/runtime"); const server = await createServer({ + mode: context.args.mode, resolve: { alias: { "vinxi/sh": fileURLToPath( diff --git a/packages/vinxi/lib/app.js b/packages/vinxi/lib/app.js index 9138d769..5d998794 100644 --- a/packages/vinxi/lib/app.js +++ b/packages/vinxi/lib/app.js @@ -14,6 +14,7 @@ import { resolveRouterConfig, routerSchema } from "./router-modes.js"; string; server?: Omit & { https?: import('@vinxi/listhen').HTTPSOptions | boolean }; root?: string + mode?: string }} AppOptions */ /** @typedef {{ @@ -23,6 +24,7 @@ import { resolveRouterConfig, routerSchema } from "./router-modes.js"; server: Omit & { https?: import('@vinxi/listhen').HTTPSOptions | boolean }; routers: import("./router-mode.js").Router[]; root: string; + mode?: string; }; addRouter: (router: any) => App; addRouterPlugins: (apply: (router: import("./router-mode.js").Router) => boolean, plugins: () => any[]) => void; @@ -45,6 +47,7 @@ export function createApp({ name = "vinxi", server = {}, root = process.cwd(), + mode, } = {}) { const hooks = createHooks(); hooks.afterEach((result) => { @@ -96,6 +99,7 @@ export function createApp({ routers: parsedRouters, server, root, + mode, }, index, ), @@ -113,6 +117,7 @@ export function createApp({ routers: resolvedRouters, server, root, + mode, }; hooks.callHook("app:config-resolved", { config }); diff --git a/packages/vinxi/lib/build.js b/packages/vinxi/lib/build.js index 66d611dd..d8473f07 100644 --- a/packages/vinxi/lib/build.js +++ b/packages/vinxi/lib/build.js @@ -369,6 +369,7 @@ async function createRouterBuild(app, router) { await createViteBuild({ app: app, root: router.root, + mode: app.config.mode, build: { ssr: true, ssrManifest: true, diff --git a/packages/vinxi/lib/dev-server.js b/packages/vinxi/lib/dev-server.js index 2174f99b..381b6326 100644 --- a/packages/vinxi/lib/dev-server.js +++ b/packages/vinxi/lib/dev-server.js @@ -69,6 +69,7 @@ export async function createViteHandler(router, app, serveConfig) { force: serveConfig.force, }, dev: serveConfig, + mode: app.config.mode, router, app, server: { diff --git a/packages/vinxi/lib/load-app.js b/packages/vinxi/lib/load-app.js index 12788dbb..370dfa95 100644 --- a/packages/vinxi/lib/load-app.js +++ b/packages/vinxi/lib/load-app.js @@ -128,6 +128,7 @@ async function loadFile( /** * * @param {string | undefined} configFile + * @param {{ mode?: string }} args * @returns {Promise} */ export async function loadApp(configFile = undefined, args = {}) { @@ -178,6 +179,7 @@ export async function loadApp(configFile = undefined, args = {}) { ); const app = createApp({ + mode: args.mode, routers: [ { name: "public", From 1b4381a03379b1dcacea4fbbe7b14b7a9c847b48 Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Tue, 3 Sep 2024 10:04:22 -0700 Subject: [PATCH 2/2] Create great-boats-laugh.md --- .changeset/great-boats-laugh.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/great-boats-laugh.md diff --git a/.changeset/great-boats-laugh.md b/.changeset/great-boats-laugh.md new file mode 100644 index 00000000..c1400209 --- /dev/null +++ b/.changeset/great-boats-laugh.md @@ -0,0 +1,5 @@ +--- +"vinxi": patch +--- + +Add support for Vite --mode