farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
15 stars 13 forks source link

Convert from CommonJS to ES Modules #23

Closed jgaehring closed 2 years ago

jgaehring commented 3 years ago

Since this library never saw much use in Node production servers, I think it's safe to require Node v13.2.0 or higher so we can start using import/export instead of require(). I'll open a separate issue related to specifying Node requirements. Note that we'll also need to enable this in our package.json, per https://nodejs.org/api/esm.html#esm_enabling.

jgaehring commented 2 years ago

Worth noting that CommonJS cannot load ES Modules with require() (they have to use the asynchronous import() instead), even though ES Modules can load all CommonJS modules. So we'll be losing a little bit of that flexibility, but I still don't think that's a deal-breaker.

More details from the Node docs: https://nodejs.org/api/esm.html#esm_interoperability_with_commonjs