electron-vite/vite-plugin-electron

esm module在import electron时报错

liuyisnake opened this issue · 1 comments

运行时弹窗报错如下
import Ae, {app as g, ipcMain as d, BrowserWindow as q, shell as Le} from "electron";

SyntaxError: Tye requested module 'electron' does not provide an export named 'shell'

点击确定可以继续执行
源码是
import { app, BrowserWindow, shell, ipcMain } from 'electron';
main里的 index-DMiFJvki.js parse成了
import Ae, { app as g, ipcMain as d, BrowserWindow as q, shell as Le } from "electron";

package.json有声明为module

{ "main": "dist-electron/main/index.js", "description": "", "author": "", "license": "MIT", "private": true, "debug": { "env": { "VITE_DEV_SERVER_URL": "http://localhost:7777/" } }, "engines": { "node": ">=20.9.0" }, "type": "module" }

vite-plugin-electron 0.28.7
vite 5.3.1
node version 20.14.0

另外work一个线程在import时导致出错