diff --git a/packages/editor/playground/vite.config.ts b/packages/editor/playground/vite.config.js similarity index 96% rename from packages/editor/playground/vite.config.ts rename to packages/editor/playground/vite.config.js index 72f731d36..61bb720c9 100644 --- a/packages/editor/playground/vite.config.ts +++ b/packages/editor/playground/vite.config.js @@ -1,3 +1,5 @@ +// @ts-check + import { defineConfig } from "vite" // https://vitejs.dev/config/ diff --git a/packages/electron-main/package.json b/packages/electron-main/package.json index 53b37def6..7a7488ecb 100644 --- a/packages/electron-main/package.json +++ b/packages/electron-main/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "private": true, "scripts": { - "dev": "tsc --build --watch ./src/tsconfig.json", - "build": "tsc --build ./src/tsconfig.json" + "dev": "tsc --build ./src/tsconfig.json && vite build ./src --watch", + "build": "tsc --build ./src/tsconfig.json && vite build ./src" }, "dependencies": { "electron-log": "^4.4.0", @@ -12,7 +12,9 @@ }, "devDependencies": { "@rino.app/electron-types": "workspace:0.0.0", + "builtin-modules": "^3.2.0", "electron": "13.1.7", - "typescript": "^4.3.5" + "typescript": "^4.3.5", + "vite": "^2.4.3" } } diff --git a/packages/electron-main/src/main.ts b/packages/electron-main/src/main.ts index e30410846..ebafd03d3 100644 --- a/packages/electron-main/src/main.ts +++ b/packages/electron-main/src/main.ts @@ -1,4 +1,5 @@ import { app, Menu } from "electron" +import { autoUpdater } from "electron-updater" import { registerIpcInvokeHandlers } from "./api-main" import { buildApplicationMenu } from "./application-menu" @@ -13,7 +14,6 @@ async function setupAutoUpdate() { await app.whenReady() await new Promise((resolve) => setTimeout(resolve, 1000)) try { - const { autoUpdater } = await import("electron-updater") autoUpdater.logger = logger await autoUpdater.checkForUpdatesAndNotify() } catch (e) { diff --git a/packages/electron-main/src/tsconfig.json b/packages/electron-main/src/tsconfig.json index e1cb10f97..e40d66529 100644 --- a/packages/electron-main/src/tsconfig.json +++ b/packages/electron-main/src/tsconfig.json @@ -1,10 +1,10 @@ { "extends": "../../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "noEmit": false, - "outDir": "../dist", "composite": true, + "noEmit": false, + "emitDeclarationOnly": true, + "outDir": "./.cache/typescript", }, "include": [ "./", diff --git a/packages/electron-main/src/vite.config.js b/packages/electron-main/src/vite.config.js new file mode 100644 index 000000000..85dd8d0dc --- /dev/null +++ b/packages/electron-main/src/vite.config.js @@ -0,0 +1,23 @@ +// @ts-check + +import builtinModules from "builtin-modules" +import { defineConfig } from "vite" + +// https://vitejs.dev/config/ +export default defineConfig((env) => ({ + build: { + minify: "esbuild", + sourcemap: true, + chunkSizeWarningLimit: 2000, + outDir: "../dist", + emptyOutDir: true, + + lib: { + entry: "./main.ts", + formats: ["cjs"], + }, + rollupOptions: { + external: [...builtinModules, "electron", "fs/promises"], + }, + }, +})) diff --git a/packages/electron-renderer/src/vite.config.ts b/packages/electron-renderer/src/vite.config.js similarity index 98% rename from packages/electron-renderer/src/vite.config.ts rename to packages/electron-renderer/src/vite.config.js index 4aead21e2..7f843d3e7 100644 --- a/packages/electron-renderer/src/vite.config.ts +++ b/packages/electron-renderer/src/vite.config.js @@ -1,3 +1,5 @@ +// @ts-check + import reactRefresh from "@vitejs/plugin-react-refresh" import { defineConfig } from "vite" diff --git a/packages/electron/package.json b/packages/electron/package.json index 992c8fff5..28a637350 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -2,7 +2,7 @@ "name": "@rino.app/electron", "version": "0.0.0", "private": true, - "main": "./build/electron-main/dist/main.js", + "main": "./build/electron-main/dist/electron-main.cjs.js", "author": "ocavue", "description": "A better way to write Markdown", "scripts": { @@ -16,9 +16,5 @@ "electron-builder": "^22.11.7", "electron-notarize": "^1.0.0", "wait-on": "^6.0.0" - }, - "dependencies": { - "electron-log": "^4.4.0", - "electron-updater": "^4.3.9" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f35ab9212..d30493bdb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -193,13 +193,8 @@ importers: specifiers: electron: 13.1.7 electron-builder: ^22.11.7 - electron-log: ^4.4.0 electron-notarize: ^1.0.0 - electron-updater: ^4.3.9 wait-on: ^6.0.0 - dependencies: - electron-log: 4.4.0 - electron-updater: 4.3.9 devDependencies: electron: 13.1.7 electron-builder: 22.11.7 @@ -209,17 +204,21 @@ importers: packages/electron-main: specifiers: '@rino.app/electron-types': workspace:0.0.0 + builtin-modules: ^3.2.0 electron: 13.1.7 electron-log: ^4.4.0 electron-updater: ^4.3.9 typescript: ^4.3.5 + vite: ^2.4.3 dependencies: electron-log: 4.4.0 electron-updater: 4.3.9 devDependencies: '@rino.app/electron-types': link:../electron-types + builtin-modules: 3.2.0 electron: 13.1.7 typescript: 4.3.5 + vite: 2.4.3 packages/electron-preload: specifiers: @@ -4148,6 +4147,11 @@ packages: - supports-color dev: true + /builtin-modules/3.2.0: + resolution: {integrity: sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==} + engines: {node: '>=6'} + dev: true + /builtin-status-codes/3.0.0: resolution: {integrity: sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=}