Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

インメモリ Repository とプロセス間通信の実装 #89

Closed
Tracked by #59
a2311kk opened this issue Jun 27, 2024 · 9 comments · Fixed by #92 or #103
Closed
Tracked by #59

インメモリ Repository とプロセス間通信の実装 #89

a2311kk opened this issue Jun 27, 2024 · 9 comments · Fixed by #92 or #103
Assignees

Comments

@a2311kk
Copy link
Contributor

a2311kk commented Jun 27, 2024

概要

何をやるのか

永続化処理を実装する。

なぜやるのか(目的)

各機能に共通して必要となる基盤を実装し、各機能を実装できるようにするため。

完成の定義

永続化処理の実装完了。

その他

@a2311kk a2311kk added this to manakan Jun 27, 2024
@a2311kk a2311kk self-assigned this Jun 27, 2024
@a2311kk a2311kk moved this to Todo in manakan Jun 27, 2024
@a2311kk a2311kk moved this from Todo to In Progress in manakan Jun 27, 2024
@a2311kk
Copy link
Contributor Author

a2311kk commented Jun 30, 2024

そもそも ES Module が何か分かっていなかった

ES Modules入門 JavaScriptのモジュールを使う方法

@a2311kk
Copy link
Contributor Author

a2311kk commented Jun 30, 2024

Electron のドキュメント通りにプロセス間通信を実装しようとして、以下のようなエラーが発生していた。

https://www.electronjs.org/docs/latest/tutorial/ipc#pattern-2-renderer-to-main-two-way

[vite]: Rollup failed to resolve import "electron/main" from "D:/Users/user/Documents/AIIT/PBL/repos/manakan/src/main.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

@a2311kk
Copy link
Contributor Author

a2311kk commented Jun 30, 2024

上記の問題の原因は 2 つあった。

原因 1 vite.xxxx.config.ts の設定漏れ(または tsconfig.json との不整合)

tsconfig.json には "baseUrl": "." の設定が入っていたので、VS Code は Absolute Imports(絶対パスによる import)を解決できた。また、Quick Fix で import 文を追加する際も Absolute Imports になっていた。一方、vite.xxxx.config.ts には Absolute Imports を解決するための設定が入っていなかったので、Vite は Absolute Imports を解決できなかった。

以下のページを参考に、各 vite.xxxx.config.tsresolve.alias の設定を追加することで、Vite が Absolute Imports を解決できるようになった。

How To Create Absolute Imports In Vite React App: A step-by-step Guide - DEV Community

原因 2 electron/xxxx から import していたこと

以下のドキュメントを参考にし、単純に require を import に書き換えた、以下のような import 文を書いていた。

  • import { ... } from 'electron/main'
  • import { ... } from 'electron/renderer'

Inter-Process Communication | Electron

一旦それらの import 文を削除し、Quick Fix から import 文を追加しようとしたところ、electron から import する選択肢があり、こちらから import するようにしたところ、Vite のエラーが出なくなった。

image

ただし、なぜそれで解決したのか不明。

@shunya9811
Copy link
Contributor

shunya9811 commented Jun 30, 2024

@a2311kk
データの保存先については、どう考えてますかね?JSONで保存するのと、SQLiteを使って行くのとあると思うんですけど

@a2311kk
Copy link
Contributor Author

a2311kk commented Jun 30, 2024

@shunya9811

まだあまり深く考えられていませんが、トランザクションのことまで気にするなら SQLite になるような気はしています。

@rt4716 rt4716 closed this as completed in #92 Jul 2, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in manakan Jul 2, 2024
@a2311kk a2311kk changed the title 永続化処理の実装 インメモリ Repository とプロセス間通信の実装 Jul 2, 2024
@rt4716 rt4716 moved this from Done to In Progress in manakan Jul 2, 2024
@shunya9811 shunya9811 reopened this Jul 2, 2024
@shunya9811 shunya9811 moved this from In Progress to Todo in manakan Jul 4, 2024
@shunya9811 shunya9811 moved this from Todo to In Progress in manakan Jul 4, 2024
@shunya9811 shunya9811 linked a pull request Jul 6, 2024 that will close this issue
@a2311kk a2311kk moved this from In Progress to Done in manakan Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants