Files
Yunfei He 0a774ddc8c refactor(vite)!: make @vue-tui/vite dev-only; build apps with tsdown (#247)
`vite build` is a browser-first bundler, so producing a runnable Node program
from it meant constantly overriding its defaults (platform, externalization,
inlineDynamicImports, module-preload). Building a Node app is a Node bundler's
job — so split vue-tui's two jobs across two tools:

- @vue-tui/vite is now DEV-ONLY (in-terminal dev server + HMR). Removed
  buildConfigPlugin and the externalize predicate: deleted src/build.ts,
  src/external.ts (+ external.spec.ts) and test/build.sequential.test.ts.
  vueTui() returns just the dev + dev-vmod plugins, and entry normalization is
  dev-only; dev.spec.ts updated.
- Production builds move to tsdown + unplugin-vue: a plain tsdown.config.ts that
  bundles the whole app into one self-contained Node file (dist/*.mjs) runnable
  with no node_modules. platform:node keeps builtins external and emits a real
  createRequire for CJS deps; deps.alwaysBundle inlines everything else.
- Migrated all five examples to tsdown (including flappy-bird, which hand-rolled
  a vite lib-mode self-contained build), and rewrote the examples smoke suite to
  build via tsdown and launch each self-contained bundle from an empty sandbox.
- Added tsdown + unplugin-vue-jsx to the catalog; updated the root and
  @vue-tui/vite READMEs.

BREAKING CHANGE: @vue-tui/vite no longer configures `vite build`. Build the app
with tsdown instead (see the @vue-tui/vite README, examples/*, and the starter).
2026-07-06 00:29:28 +08:00
..

basic-template

A minimal vue-tui app written with Vue SFC <template> syntax. It is the canonical reference for wiring up the @vue-tui/vite plugin.

Setup

// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { vueTui } from "@vue-tui/vite";

export default defineConfig({
  plugins: [vue(), vueTui()],
});
// package.json
{
  "scripts": {
    "dev": "vite", // in-process terminal dev server with HMR
    "build": "vite build", // bundles src/main.ts -> dist/main.js
    "preview": "vite build && node dist/main.js",
  },
}

Running it (use vanilla vite@8)

This example is a configuration reference. The recommended and proven setup is vanilla vite@8: npm run dev boots the app in-process and applies state-preserving HMR as you edit src/app.vue; npm run build emits a single self-contained dist/main.js.

Caveat inside this monorepo

In the vue-tui monorepo, the vite specifier is overridden to @voidzero-dev/vite-plus-core (see pnpm-workspace.yaml overrides/catalog). With that override:

  • vite build works — the production bundle is produced normally, and the workspace build (vp run build) includes this example.
  • vite (dev) does not run the app here — vite-plus-core's ssr environment is not a runnable dev environment, so the in-process launcher cannot start the app and the plugin reports [vue-tui] the "ssr" environment is not runnable instead of crashing. This is a vite-plus-core limitation, not a problem with @vue-tui/vite. To exercise the terminal HMR dev server, run this example outside the monorepo against a plain vite@8 install.