Closed mtscout6 closed 12 years ago
I would really like to pull this but the full file indentation change is going to break some meaningful git history or make it a bit more difficult to parse. Could you add the AMD header/wrapper at the top without changing the rest of the file?
Not a problem. I just did a forced update to replace what I did have up there with the non-tabbed as you would like.
Thanks! Way easier :)
I figured to also make all the plugins AMD compliant.
If anyone needs a simple workaround when using Sammy as AMD module and using plugins, do the following. Before requiring any plugins:
// plugins do Sammy = Sammy || {} instead of Sammy = window.Sammy
Sammy = {};
Before starting the app merge the loaded plugins:
require(['jquery', 'sammy', 'plugins/sammy.googleanalytics', function($, sammy) {
$.extend(sammy, window.Sammy);
var app = sammy('#app', function() {
// Plugins
this.use('GoogleAnalytics');
}
@rikkert how does it resolve the issue of multiple anonymous defines when plugins are concatenaned to sammy and minified? As mentioned above, r.js cannot concatenate require or define with variable-based dependency lists.
Having separate Sammy builds - standard and AMD-enabled Seems like the safest solution, as if you look at the AMD drama Underscore went through, AMDing a base lib conjures up a storm and allergic reaction to AMD. with separate but official AMD build, when AMD will fall out of style in a year, Sammy's maintainer will not be stuck supporting it in mainline version. Keeping the AMD wrapper a build-time thing, also opens the for other wrappers ('extends', Harmony etc)
Made compatible with AMD loaders following the Universal Module Definition pattern as laid out by @jrburke at https://github.com/umdjs/umd
For detailed description of what AMD is See: http://addyosmani.com/writing-modular-js/