Ardakilic / alerthub

AlertHub is a simple tool written with NodeJS to get alerted from new GitHub and GitLab repository events.
MIT License
200 stars 12 forks source link

Switch to ES6 modules #57

Closed reconman closed 2 years ago

reconman commented 2 years ago

This is a breaking change, the config.js needs to be defined in ES6 format as indicated by the modified config.example.js.

Ardakilic commented 2 years ago

Heya, Apologies for the late reply. Apparently I never got notified about this.

Thanks! This looks awesome! Merging it 😊

Ardakilic commented 2 years ago

Also, I just invited you as collaborator, for not blocking for such stuff. Thanks again!

reconman commented 2 years ago

I had to revert the type: module line in package.json because of rss-braider. https://github.com/Ardakilic/alerthub/commit/d1dd5df1805adde750f81cbf1f926c55ab79b098

That library can only handle files with .js endings and imports them via the CommonJS syntax of require. You can mark CommonJS files in Node with .cjs, but then rss-braider doesn't pick them up correctly.

So the only way out was to tell Node to treat any .js file as CommonJS module and then mark all ES modules with .mjs file extensions.

Since the rss-braider plugins need to be CommonJS modules and one of them imports utils/Alerthub.js, I also had to revert that file to a CommonJS module.

Btw, if you have Discord, my username is reconman#0562.