I caught up with the modern client-side JS ecosystem and read about modular systems like CommonJS and AMD (including related tools - browser, requirejs, onejs, jam, dozens of others). If I am writing a Javascript library, how can I package it so that it can be most widely available (ideally, users who swear by CommonJS, AMD, and especially not)?
Popular libraries like jQuery seem to just use the old school file concatenation to create themselves and dynamically detect whether to write to export or global context. I am currently doing the same thing, but the main drawback is that if I (unlike jQuery) depend on several libraries, it is nice not to ask users to manually enable transitive dialing first. (Although I currently have only two dependencies.) And, of course, global pollution of the namespace.
Or maybe it's clean to generate multiple versions of my library for each context?
It also affects packaging and publication. There are several systems, but I believe that the main one is the gazebo, which is easy to handle, since all it does is sample. However, if I want to pack it for a component, then this requires the CommonJS module.
Are there other important aspects that I should be aware of? Are there any good project examples for all this?
source share