From 50d98f67b324a5aabf80e716e7f85a20e616d5fa Mon Sep 17 00:00:00 2001
From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com>
Date: Sun, 24 Sep 2023 02:01:43 -0700
Subject: [PATCH] =?UTF-8?q?Electron=20ESM!=20=F0=9F=94=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Wow, can't believe this day has finally come! You can essentially write most of your Electron code in pure ESM now! The only holdup is that preload scripts must be CommonJS still. But you can just add the `.cjs/.cts` extension for that one module, so that works out really well.
This was what made me come back to work on this project a little bit again. Rather than starting fresh with a new Electron project, I thought it would be a better idea to update this one to use my more recent tooling (TS, ESM in this case), and I want to try some Electron-specific things out too, like Accelerators, things like that. Ooh, I want to get Vite/live reload working with this too, I didn't end up getting that set up when I started this, Node projects were still above my head at that time.
https://github.com/electron/electron/issues/21457
https://github.com/electron/electron/pull/37535
https://github.com/electron/electron/blob/main/docs/tutorial/esm.md
This was a placeholder I set up for the reference to resolve the preload script, since `__dirname` isn't an available global from within ESM.
https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/
Sevendust Next is definitely one of my favorite albums of theirs for me, looking back on it more recently the last year or so.
---
index.html | 2 +-
main.ts | 7 ++++--
package-lock.json | 50 +++++++++++++++++++--------------------
package.json | 3 ++-
preload.ts => preload.cts | 0
tsconfig.json | 5 ++--
6 files changed, 36 insertions(+), 31 deletions(-)
rename preload.ts => preload.cts (100%)
diff --git a/index.html b/index.html
index 5e05141..54b21da 100644
--- a/index.html
+++ b/index.html
@@ -37,7 +37,7 @@
-
+