require(['JxLib/src/Source/Button/button'], function(button) {
// do app specific stuff with 'button' module by referenceing the parameter 'button'
});
As for combined versions, requirejs kinda discourages that unless you use their packaging utility which suppossedly manages all of the references correctly.
RequireJS would need to be included somehow - whether individually or through a base file we create.
Well, with those answered, here's what I'm thinking. These points might come out kinda random (and I haven't worked up any kind of POC)....
First, a key decision needs to be made:
1) Do we stick with a Jx namespace and do everything globally or do we do everything as AMD wants us to and avoid globals?
Once that's determined we can go forward to:
1) We would define everything with modules either attaching to the global Jx object or returning appropriate AMD compatible objects. If we go the AMD compatible route then we would need to re-write everything to account for that.
2) I envisioned writing a wrapper around the require and define functions (call them requireJx and defineJx) that would allow us to reference objects using their Jx namespace (either as Jx.Button, Jx.Field.Text or just as Button and Field.Text) and would translate that into an AMD compatible path. This would be done most likely by simply replacing the '.' character with a '/'.
3) We would need to decide if we're going to include requirejs in the build process and how much we include as a "base" file (perhaps just the stuff in common.js) and how to include mootools functions before they finish their AMD support.
4) If we go the global route then we could also setup the build to strip out the AMD support for anyone who wants a single file that they could use as they always have. This would simply be a matter of wrapping anything AMD specific in tags similar to how mootools wraps their compatibility layer. The build script is already designed to strip those out. I could then build in an option to include or remove the AMD support as people want.
5) We would indeed need to reorganize the source tree to make paths work properly which would, thankfully, not impact the build process for a monolithic build due to the way things implemented in that process.
So, at this point we need to decide which way we're going to go on the whole global object question. Once we have that I may start to work on a proof of concept in a separate branch so we can play around with things.
Jon