-
Notifications
You must be signed in to change notification settings - Fork 311
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
refactor: createLoggerを少しリファクタリング #2489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
🚀 プレビュー用ページを作成しました 🚀 更新時点でのコミットハッシュ: |
require()で動的に読み込めば良さそう? |
ESModuleにしても問題ないようにするなら、 https://github.com/KeJunMao/unplugin-preprocessor-directives こういうのでビルド段階で処理するしかなさそう? |
助言助かります!! |
初回だけ遅れるのを許容すればdynamic importでいい感じにできると思います。 |
たしかに!! |
let electronLogOrNull;
const logInternal = (args) => {
electronLogOrNull.log(args);
}
export const log = (args) => {
if (electronLogOrNull) {
logInternal(args);
} else {
void import("electron-log").then((l) => {
electronLogOrNull = l;
logInternal(args);
});
}
} こういうイメージです |
なるほどです、なんかできそうな気がしてきますね!! とりあえずこのPRマージしちゃえると良さそうかも。 |
electron内では前後しないはず?electronLogOrNullに値が入ってからawait入れなければ他のスレッドに移らないはずなので |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
良さそう。
内容
タイトルの通り、createLoggerを少しリファクタリングしました。
その他
本当はelectron環境問わずloggerを作れる関数を作りたかったんですが、フロントエンドで
electron-log
をimportしようとするとエラーになる問題が解決できずに諦めました。。。なにか解決策ないのかな。。