openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 70 forks source link

Added initial CommonJS support #270

Closed jpg0 closed 4 years ago

jpg0 commented 4 years ago

PR as discussed in #267

This implements a CommonJS module system for loading libraries.

I do believe that pulling the loading engine up into OH code would be better, but agree that we should wait for JDK9/ES6 before we do this (although if it really drags on, I may do it). Either way, this PR means that all library code written now would be compatible with that future.

jpg0 commented 4 years ago

Oh, and one other thing as mentioned elsewhere: this really shows that utils.js should be broken up into logical parts. It seems to cover a little bit of everything. For example one of the first things that I'd do is move getItem, sendCommand, postUpdate to items.js (#266)

jpg0 commented 4 years ago

After looking at this, I have discovered that there is a problem: