I was going to post this as a comment under #110, dealing with component.json support for Volo, but thought it was more appropriate for a groups post.
Folder-based packages
Folder-based package management is simpler to understand for users and users are more likely to use a simpler process over one they don't understand fully, which in some ways the Volo system may appear to be, for some. Also Bower have shown no interest in implementing the single-file download method (
https://github.com/twitter/bower/issues/317).
Consider a jquery plugin, instead of having to write:
require(['jquery-plugin/plugin', 'css!jquery-plugin/plugin'], function(plugin) { ... });
we want to just be able to do:
require(['jquery-plugin']).
One solution here is to automatically generate the base-level 'jquery-plugin.js' file from the component.json. For example, a component.json might show:
{
"name": "jquery-plugin",
"version": "0.0.1",
"main": ["./plugin.js", "./plugin.css"],
"dependencies": {
"jquery": "components/jquery#1.9.1"
}
}
Then a base-level wrapper would be generated of the form:
define(['jquery-plugin/plugin.js', 'css!jquery-plugin/plugin.css'], function(plugin) {
return plugin;
});
The wrapper has been entirely informed from the "main" property of the component.json.
The component.json could even include shim configuration, for example:
{
"shim": {
"exports": "jquery.plugin",
"deps": ["jquery"]
}
}
This would translate into the following in the wrapper:
requirejs.config({
"shim": {
"jquery-plugin/plugin": {
"exports": "jquery.plugin",
"deps": ["jquery"]
}
}
});
define(['define(['jquery-plugin/plugin.js', 'css!jquery-plugin/plugin.css'], function(plugin) {
return plugin;
});
This way, existing repositories can be loaded in an AMD-compatible way, simply by "overriding" their component.json in the registry, just as Volo currently allows overrides.
So the hidden benefit in folder-based packages, is that we are free to create wrappers at the base level which are able to provide a shortcut to the main entry point, while also allowing modular configuration injection and CSS or LESS injection.
This is a major benefit since currently configuration injection can't be handled in a similar way between various AMD implementations.
Dependency ranges and resolution in component.json
The dependencies in component.json now support the name value pairs of `"name": "endpoint#semver range"`. The version management is interesting because it will download the matching versions within the semver range, and alert version conflicts where they happen asking for a resolution. Currently multiple versions are not supported at all in the same repo even under separate names in order to handle version conflict resolution properly. This mostly makes sense on a per-project basis, although in future there may become ways to support this. They are still working at refining this version resolution, but in theory all the conflicts (even with varying names) can be sorted out with a suitable prompt or resolution.
They're not that different really (well to users)
Otherwise, the component.json doesn't feel that far away from volo syntax (at least in terms of dependencies and when using folder-based packages), so it could well be worth working towards a component.json spec like AMD for package management that Volo could also integrate. I think that AMD pushes for a separation of browser and server that is in parallel to the separation of component.json and package.json. I think this is an important distinction because the environments are separate enough that one has to reconsider the implementations quite deeply. So in principle I think the component.json has the best chance of a spec at the moment.
I'm trialling Bower a little more simply to get a feel for it. The codebase still does need some work and there are bugs, but it behaves mostly quite similarly to Volo (in terms of how it comes across to an end user).
Towards an AMD-friendly registry that "just works"
I've been exploring this area because I am looking at building up an AMD-specific registry of modules that "play well together". Jam doesn't seem to solve the version conflict issues, so I am directly tackling these head on. I have a very basic demo up, which I could share offline, and would be quite interested to discuss further to see where these areas are going.