aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/package.json
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-30 21:47:46 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-30 21:47:46 +0100
commit1383dde6aa0d25b5fa23d7a7b64ba7de21ec5b99 (patch)
tree94739ff48121a1d69358acf5f2c60124d1b1cdec /packages/main/package.json
parentbuild: Only use vite typings in renderer (diff)
downloadsophie-1383dde6aa0d25b5fa23d7a7b64ba7de21ec5b99.tar.gz
sophie-1383dde6aa0d25b5fa23d7a7b64ba7de21ec5b99.tar.zst
sophie-1383dde6aa0d25b5fa23d7a7b64ba7de21ec5b99.zip
build: Fully switch over to ESM
Now we can run with ESM at build and test time and transpile into commonjs for electron. This greatly simplifies testing, since we treat everything as ESM during build with esbuild anyways. Now the test environment and the build scripts match the apparent (but not the actual for the main, preload, and inject modules) runtime environment. Caveats: - We may use top-level async expressions in tests and script, but not in code that gets transpiled into commonjs or scripts that get imported by vite. The limitation w.r.t. commonjs seems fundamental. - Jest only experimentally supports ESM and there are some limitations with mocking. Most limitations (except the lack of automatic mocks) can be worked around by async importing code that uses mocks. - There are packages marked as modules (so that node reads any scripts in them as ESM) that nevertheless get transpiled into commonjs modules. However, these should be clearly marked by using a .cjs extension as their bundle. The worst offender is the root package, which has a .cjs as its main entry point that gets read by electron, but is in fact marked as a module. This doesn't seem to bother electron at all. The service-inject package is an IIFE with a .js extension, but it outputs a fully self-contained bundle, so the choice of module format should be irrelevant.
Diffstat (limited to 'packages/main/package.json')
-rw-r--r--packages/main/package.json2
1 files changed, 1 insertions, 1 deletions
diff --git a/packages/main/package.json b/packages/main/package.json
index c118d2b..99451bd 100644
--- a/packages/main/package.json
+++ b/packages/main/package.json
@@ -2,7 +2,7 @@
2 "name": "@sophie/main", 2 "name": "@sophie/main",
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "main": "dist/index.cjs", 5 "type": "module",
6 "types": "dist-types/index.d.ts", 6 "types": "dist-types/index.d.ts",
7 "scripts": { 7 "scripts": {
8 "typecheck": "tsc" 8 "typecheck": "tsc"