linkasu / linka.looks-electron

6 stars 4 forks source link

Epic: переезд на vite #16

Open BruceAndyLee opened 1 year ago

BruceAndyLee commented 1 year ago

Кажется, что vite, хоть и не панацея, спасает от многих проблем с быстродействием прод-сборки и dev-сервера.

Стоит почитать ниже про electron-vite и попробовать переехать на него

https://electron-vite.org/guide/#command-line-interface


Шаги:

BruceAndyLee commented 11 months ago

Статус quo:

Uncaught ReferenceError: __dirname is not defined
    at node_modules/electron/index.js (index.js:4:28)
    at __require2 (chunk-W7S2ME4R.js?v=9bd6c0f1:18:50)
    at electron.js?v=9bd6c0f1:6:16

Эта ошибка триггерится кодом, который генерится командой electron-vite build и складывается в out/renderer/assets/index-<artifact-hash>.js

Рабочая гипотеза: Ошибка триггерится каким-то плохим импортом в одном из файлов в папке renderer (там лежат файлы на vue для фронта). Вероятнее всего, это связано с импортом electron-а из electron-модуля

electron-vite generated faulty snippet ```jsx const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal); const fs$3 = require$$0$1; const path$6 = require$$0$1; const pathFile = path$6.join(__dirname, "path.txt"); // <- this thing here! function getElectronPath() { let executablePath; if (fs$3.existsSync(pathFile)) { executablePath = fs$3.readFileSync(pathFile, "utf-8"); } if ({}.ELECTRON_OVERRIDE_DIST_PATH) { return path$6.join({}.ELECTRON_OVERRIDE_DIST_PATH, executablePath || "electron"); } if (executablePath) { return path$6.join(__dirname, "dist", executablePath); } else { throw new Error("Electron failed to install correctly, please delete node_modules/electron and try installing again"); } } ```

Актуальное состояние проекта лежит в ветке