wooorm/dioscuri

Compatibility with CommonJS?

Closed this issue · 2 comments

While ESM is on the rise, it's not supported absolutely everywhere. Electron doesn't work with ESM (my particular concern), and CommonJS is still the default in Node.JS's latest LTS release (v14). What is the advantage of limiting this module to ESM code? (As far as I know, ESM cannot be used by CommonJS modules)

Background
I'm making a gemini client with Electron. I'd like to parse it with dioscuri. Electron doesn't yet support running ESM code in the main process (see electron/electron#21457). In the renderer process, I tried both using the import() function and loading it as type=module, and it complained about bad imports and/or was unable to find the module.

Hi there!

There seems to be an override possible: electron/electron#21457 (comment)
Not the prettiest, but you could also bundle dioscuri yourself, with Rollup or so?

CommonJS is still the default in Node.JS's latest LTS release (v14)

Says who?

What is the advantage of limiting this module to ESM code? (As far as I know, ESM cannot be used by CommonJS modules)

Because we as a community will have to make the switch. And that’s soon: electron/electron#21457 (comment).

Yes, it’s going to be pretty bad for a bit. Several places don’t support them yet. But I believe that making the switch, will also cause that support. Whereas not making the switch will delay it.

@wooorm You did me a favor: I ended up writing my own parser function. It wasn't as hard as I thought! 😂 It's not perfect, but it's here: https://github.com/binyamin/gemium/blob/main/app/parser.js (feel free to take a look).