The installer and launcher is an Electron app in apps/launcher: main process, a sandboxed preload that only forwards allowed channels, and a React window translated into Chinese and English. Every renderer -> main call is declared once in the IPC contract (shared/ipc/contract.ts) with zod schemas for its input and output; the main side validates both when it registers a handler. The main process throws error codes only, and the window translates them. The launcher's own settings (for now the window language) are kept in the user data folder and written through a temporary file and a rename. Development runs can point the user data folder elsewhere with WTO_LAUNCHER_USER_DATA. The workspace packages (@wto/patcher, @wto/server) stay external to the bundle: they ship as TypeScript sources and will run in utility processes, where Electron's Node strips the types and they find their web pages, tuning and keys next to their sources as they do today. The root typecheck leaves out the launcher, which has its own tsconfig files for the main process and the window. Checked with the launcher typecheck, electron-vite build, the root typecheck, and a start on a scratch user data folder.
29 lines
995 B
TypeScript
29 lines
995 B
TypeScript
import { resolve } from 'node:path';
|
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
// The workspace packages (@wto/patcher, @wto/server) stay external: they ship as
|
|
// TypeScript sources and run in utility processes on Electron's own Node, which strips
|
|
// the types itself. Bundling them would break the files they find next to their sources.
|
|
export default defineConfig({
|
|
main: {
|
|
plugins: [externalizeDepsPlugin()],
|
|
resolve: { alias: { '@shared': resolve('src/shared') } },
|
|
},
|
|
preload: {
|
|
plugins: [externalizeDepsPlugin()],
|
|
resolve: { alias: { '@shared': resolve('src/shared') } },
|
|
// A sandboxed preload cannot be an ES module.
|
|
build: { rollupOptions: { output: { format: 'cjs', entryFileNames: '[name].cjs' } } },
|
|
},
|
|
renderer: {
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@shared': resolve('src/shared'),
|
|
'@': resolve('src/renderer/src'),
|
|
},
|
|
},
|
|
},
|
|
});
|