Compare commits

...

7 Commits

5 changed files with 695 additions and 847 deletions

View File

@ -69,34 +69,34 @@
}
},
"devDependencies": {
"@eslint/js": "^9.37.0",
"@eslint/js": "^10.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^12.1.4",
"@swc/core": "^1.13.5",
"@rollup/plugin-typescript": "^12.3.0",
"@swc/core": "^1.15.21",
"@types/babel__core": "^7.20.5",
"@types/node": "^22.18.11",
"eslint": "^9.37.0",
"@types/node": "^22.19.15",
"eslint": "^10.1.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.4.0",
"lint-staged": "^16.2.4",
"prettier": "^3.6.2",
"rollup": "^4.52.4",
"rollup-plugin-dts": "^6.2.3",
"eslint-plugin-prettier": "^5.5.5",
"globals": "^17.4.0",
"lint-staged": "^16.4.0",
"prettier": "^3.8.1",
"rollup": "^4.60.0",
"rollup-plugin-dts": "^6.4.1",
"rollup-plugin-rm": "^1.0.2",
"simple-git-hooks": "^2.13.1",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.1",
"typescript-eslint": "^8.57.2",
"vite": "^7.1.10"
},
"dependencies": {
"@babel/core": "^7.28.4",
"@babel/core": "^7.29.0",
"@babel/plugin-transform-arrow-functions": "^7.27.1",
"cac": "^6.7.14",
"cac": "^7.0.0",
"esbuild": "^0.25.11",
"magic-string": "^0.30.19",
"magic-string": "^0.30.21",
"picocolors": "^1.1.1"
},
"pnpm": {

1481
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ export default defineConfig([
plugins: [
rm('dist', 'buildStart'),
json(),
ts({ compilerOptions: { rootDir: 'src', declaration: true, declarationDir: 'dist/types' } }),
ts({ compilerOptions: { rootDir: 'src', outDir: 'dist', declaration: true, declarationDir: 'dist/types' } }),
resolve()
],
treeshake: {

View File

@ -96,6 +96,13 @@ export interface PreloadViteConfig extends BaseViteConfig<PreloadBuildOptions> {
export interface RendererViteConfig extends BaseViteConfig<RendererBuildOptions> {}
export interface UserConfig {
/**
* Custom Electron package name (e.g., '@overwolf/ow-electron').
* Can also be set via ELECTRON_PKG_NAME environment variable.
*
* @default 'electron'
*/
electronPackage?: string
/**
* Vite config options for electron main process
*
@ -313,6 +320,16 @@ export async function resolveConfig(
}
}
// Set ELECTRON_PKG_NAME from config or environment variable
// Priority: existing env var > config file > default to 'electron'
if (!process.env.ELECTRON_PKG_NAME) {
if (userConfig?.electronPackage) {
process.env.ELECTRON_PKG_NAME = userConfig.electronPackage
} else {
process.env.ELECTRON_PKG_NAME = 'electron'
}
}
const resolved: ResolvedConfig = {
config: userConfig,
configFile: configFile ? normalizePath(configFile) : undefined,

View File

@ -6,6 +6,10 @@ import { loadPackageData } from './utils'
const _require = createRequire(import.meta.url)
const getElectronPackageName = (): string => {
return process.env.ELECTRON_PKG_NAME || 'electron'
}
const ensureElectronEntryFile = (root = process.cwd()): void => {
if (process.env.ELECTRON_ENTRY) return
const pkg = loadPackageData()
@ -26,7 +30,8 @@ const ensureElectronEntryFile = (root = process.cwd()): void => {
const getElectronMajorVer = (): string => {
let majorVer = process.env.ELECTRON_MAJOR_VER || ''
if (!majorVer) {
const pkg = _require.resolve('electron/package.json')
const electronPkgName = getElectronPackageName()
const pkg = _require.resolve(`${electronPkgName}/package.json`)
if (fs.existsSync(pkg)) {
const version = _require(pkg).version
majorVer = version.split('.')[0]
@ -49,7 +54,8 @@ export function supportImportMetaPaths(): boolean {
export function getElectronPath(): string {
let electronExecPath = process.env.ELECTRON_EXEC_PATH || ''
if (!electronExecPath) {
const electronModulePath = path.dirname(_require.resolve('electron'))
const electronPkgName = getElectronPackageName()
const electronModulePath = path.dirname(_require.resolve(electronPkgName))
const pathFile = path.join(electronModulePath, 'path.txt')
let executablePath
if (fs.existsSync(pathFile)) {
@ -59,7 +65,7 @@ export function getElectronPath(): string {
electronExecPath = path.join(electronModulePath, 'dist', executablePath)
process.env.ELECTRON_EXEC_PATH = electronExecPath
} else {
throw new Error('Electron uninstall')
throw new Error(`Electron package "${electronPkgName}" not found or uninstalled`)
}
}
return electronExecPath