deltachat-desktop icon indicating copy to clipboard operation
deltachat-desktop copied to clipboard

Refactoring for ESM module support

Open link2xt opened this issue 2 months ago • 4 comments

This is an attempt to make https://github.com/deltachat/deltachat-core-rust/pull/4971 works. It works without ESM modules currently, but with ESM module PR there are still problems:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/src/deltachat/deltachat-core-rust/node/dist/index.js from /home/user/src/deltachat/deltachat-desktop/tsc-dist/main/deltachat/controller.js not supported.
Instead change the require of index.js in /home/user/src/deltachat/deltachat-desktop/tsc-dist/main/deltachat/controller.js to a dynamic import() which is available in all CommonJS modules.
    at c._load (node:electron/js2c/node_init:2:13672)
    at Object.<anonymous> (/home/user/src/deltachat/deltachat-desktop/tsc-dist/main/deltachat/controller.js:39:39)
    at c._load (node:electron/js2c/node_init:2:13672)
    at Object.<anonymous> (/home/user/src/deltachat/deltachat-desktop/tsc-dist/main/ipc.js:56:38)
    at c._load (node:electron/js2c/node_init:2:13672)
    at Object.<anonymous> (/home/user/src/deltachat/deltachat-desktop/tsc-dist/main/index.js:134:26)
    at c._load (node:electron/js2c/node_init:2:13672)
    at Object.<anonymous> (/home/user/src/deltachat/deltachat-desktop/index.js:11:1)
    at c._load (node:electron/js2c/node_init:2:13672)

I don't understand where this require comes from. Maybe it is because main module is a CommonJS module: https://github.com/deltachat/deltachat-desktop/blob/e603178e5eae0f933138e3e7cbfe399bf70f3c06/src/main/tsconfig.json#L6

link2xt avatar Apr 30 '24 15:04 link2xt