cordejs/corde

Support ESM or corde.config.cjs

Closed this issue · 0 comments

Is your feature request related to a problem? Please describe.
I'd like to use ES Modules in order to use various functions like top-level await, the ability to use node-fetch v3, etc. I'd also like to inject bot tokens and IDs using a .env file. To this end, I want to use one of the JavaScript variants of Corde configs. TypeScript would be preferable.

However, Corde does not appear to support projects configured to use ESM (by setting "type": "module" in package.json):

  • With corde.config.ts, Corde complains: require() of ES modules is not supported.
  • With corde.config.cjs (using .cjs to force CommonJS parsing in an ESM environment), Corde complains: Extension '.cjs' is not supported.

Describe the solution you'd like
Corde should either support ESM properly, or support *.cjs configs as a workaround, or both.

Describe alternatives you've considered

  • I could use a corde.config.json file, but that would making CI testing difficult without committing bot tokens and IDs to source control. This is a monumentally bad idea for reasons which I think are obvious.
  • I could re-implementing Corde myself as an ESM project. That's a ton of work, though.
  • I could create a fork to add .cjs support as a workaround. (I might do this later. EDIT: See #1429)