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

Provide a Common JS distributable #57

Closed jgaehring closed 2 years ago

jgaehring commented 2 years ago

When I converted from CommonJS modules to ES6 modules (#23), I did not take into account that this would result in an error (Error [ERR_REQUIRE_ESM]: require() of ES Module) in Node projects that are still using CJS.

I think it should be a small matter to create a dist folder for a transpiled version, although I want to make sure I only transpile the source files, and not the dependencies if I can at all avoid it. I'm hopeful that rollup may provide a solution to this w/o too much configuration, since my impression is that rollup is more well-suited to bundling libraries than, say, Webpack. The trickiest dependency may be Ramda, because I ran into issues during #23 that required me to import each function from their sepearate source files.

jgaehring commented 2 years ago

This is definitely important, especially for the SurveyStack work that has begun this week, but I'm going to move this to the next milestone, since it will not introduce any breaking changes and is not a blocker for the Field Kit beta.

jgaehring commented 2 years ago

So I realized today I broke this much worse than I thought with #23, and after a good deal of aggravation I believe I've got it all working again, after many failed builds of the develop.farmos.app branch deployment.

So we've now got ESM, UMD and CJS modules as options, via Rollup. It's working in both Field Kit and the various scripts and tests in farmOS.js that run in Node, so we should be good. I'll try to confirm with the SurveyStack team after the holiday, but will close this for now.