Skip to content

Instantly share code, notes, and snippets.

@johnpapa
Created June 26, 2012 17:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpapa/2997380 to your computer and use it in GitHub Desktop.
Save johnpapa/2997380 to your computer and use it in GitHub Desktop.
main.js for Jim
requirejs.config({
// script default location
baseUrl: 'scripts/app',
// shim in the libs that don't know define.amd (excluding extensions)
shim: {
'amplify': { deps: [], exports: 'amplify' },
// jquery 1.7.x understands define; no shim needed.
'jquery.ui': ['jquery'],
'jquery.wijmo':['jquery.ui'],
'json2': { exports: 'JSON' },
'knockout.wijmo': ['ko', 'jquery.wijmo'],
//'ko': { deps: ['jquery'], exports: 'ko' }, //ko 2.1 understands define; no shim needed
// moment understands define; no shim needed.
'sammy': { deps: ['jquery'], exports: 'Sammy' },
'toastr': { deps: ['jquery'], exports: 'toastr' },
'underscore': { deps: [], exports: '_' }
},
// List paths to js files that are not in the baseUrl.
// Could simplify for libraries that are conventionally named
// (which is all of them except jquery which identifies the version).
paths: {
'activity-indicator': '../lib/activity-indicator',
'amplify': '../lib/amplify.core',
'amplify.request': '../lib/amplify.request',
'amplify.store': '../lib/amplify.store',
'jquery': '../lib/jquery-1.7.2.min',
'jquery.mockjson': '../lib/jquery.mockjson',
'jquery.ui': '../lib/jquery-ui.min',
'jquery.wijmo': '../lib/jquery.wijmo-open.all.2.1.2.min',
'json2': '../lib/json2.min',
'infuser': '../lib/infuser-amd',
'knockout.changetracker': '../lib/knockout.changetracker-amd',
'knockout.wijmo': '../lib/knockout.wijmo',
'ko.validation': '../lib/knockout.validation',
'ko': '../lib/knockout-2.1.0',
'koExternalTemplateEngine': '../lib/koExternalTemplateEngine-amd',
'moment': '../lib/moment',
'sammy': '../lib/sammy',
'sammy.title': '../lib/sammy.title',
'toastr': '../lib/toastr',
'trafficcop': '../lib/TrafficCop-amd',
'underscore': '../lib/underscore.min'
}
});
// Require that pre-requisites be loaded immediately, before anything else
// ToDo: Pare back the ones that don't have plugins?
requirejs([
// 3rd party libraries
'ko',
'json2',
'jquery',
'underscore',
'moment',
'sammy',
'amplify',
'toastr'
],
// use the parameterized signature if you want to confirm that dependencies are loaded with the debugger
// function (ko, json2, $, _, moment, Sammy, amplify, toastr) {
// debugger;
function (ko) {
// ensure KO is in the global namespace ('this')
if (!this.ko) {
this.ko = ko;
};
// Require that plugins be loaded, after the prerequisite libraries
// We load the plugins here and now so that we don't have to
// name them specifically in the modules that use them because
// we don't want those modules to know that they use plugins.
requirejs([
'activity-indicator', // jquery plugin
'sammy.title', // sammy plugin
'amplify.request', // amplify plugin
'amplify.store', // amplify plugin
'jquery.mockjson', // jquery plugin
'jquery.activity-ex', // jquery plugin
'jquery.ui', // jquery plugin
'jquery.wijmo', // jquery plugin
'ko.utils', // Knockout custom utilities
'ko.bindingHandlers', // Knockout custom binding handlers
'ko.bindingHandlers.activity', // Knockout custom binding handlers
'ko.bindingHandlers.command', // Knockout custom binding handlers
'ko.asyncCommand', // Knockout custom asyncCommand
'knockout.changetracker',
'knockout.wijmo', // Knockout wijmo binding handlers
'koExternalTemplateEngine',
'ko.validation', // Knockout validation
'debug.helpers' // our app's ko debugging plugin
],
// Plugins generally don't return module objects
// so there would be point in passing parameters to the function
function () {
// Start-up the app, now that all prerequisites are in place.
require(['bootstrapper'],
function (bs) {
bs.run();
});
});
}
);
@adrienne
Copy link

adrienne commented Apr 7, 2013

Thanks for this, it helped me get Wijmo working with Require.js !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment