I have been thinking about how libraries in ESO work and am unsatisfied with the current state.
Ideally each addon would have its own dependencies isolated into a sandbox, but that's not how ESO works so instead all addons have to share the same libraries in the same sandbox. That's why we use LibStub to keep only the newest version in memory and hope nothing breaks. In most cases we also just bundle them into the addon, which pushes a lot of responsibilities onto the author of the addon.
I came to the conclusion that they should not be bundled with addons at all. Instead it should be the responsibility of the user to install the necessary dependencies like in any other environment. Having a standalone-only libary also has the benefit that it can use saved variables and xml controls and most importantly, specify dependencies for the library. Right now if a library depends on another library, the library author has to add a check to make sure it is loaded and the addon author who wants to use the library is responsible to load them in the correct order. We already have a dependency system in ESO which could easily handle this for us if we stopped bundling the libraries.
Of course we cannot expect the average user to do this manually, so it needs to become a feature of ESOUI and Minion to install the necessary dependencies automatically. For this to work we should be able to somehow specify the addon id or name and minimum required version of a dependency when we upload the addon. Minion then just installs and updates them in addition to the selected addon and ESOUI could for example automatically supply a bundled zip alongside the normal one. This would also make it possible to create collections of addons without having to put all of them into one zip file manually (e.g. PhinixUI) and also allow it to show lists of who uses what on the addon pages.
In order to compare version numbers properly we should decide on a common format for libraries and addons. I am currently thinking of using the following number based format:
Major reflects changes that break compatibility with other addons, minor symbolizes any small feature update that does not break anything and build number is automatically increased whenever a new build is made. For authors who don't use a build system it's probably just some arbitrary number. Either way it should never become smaller than it was before.
- AddonA specifies LibSomething 1.23.* as a minimum dependency
- Minion/ESOUI would supply the user with any 1.*.* version after it (e.g. 1.23.456), but not with version 2.*.*.
- Another addonB depends on LibSomething 2.0.*
- Minion/ESOUI adds any version after that (e.g. 2.0.789) for the user.
- The author of LibSomething has to make sure that v1 and v2 are able to run side by side and any future v1 or v2 stays backwards compatible.
- The author of AddonA has to specify LibSomething and a minimum version as a dependency and does not care about updates or dependencies of the library
- The user has to make sure that all dependencies are fulfilled
- Minion/ESOUI makes this simple for users by automatically resolving them
For library authors this means, the library should still use LibStub which would get an update to support this version format and maybe also to separate libraries and addons into two lists in the addon manger.
For addon authors it means they no longer should bundle libraries and instead make sure that they reference them in the meta file and on ESOUI.
For Dolby it means a lot of work to implement the required features.
For users not much would change.