I am using require Js and am getting rather confused as to why my modules are loading but dependencies are always undefined and even upon using require.defined() function to check if my module has been loaded it indeed has been but when i use the require([deps],function(deps){}); all of my dependencies are undefined (except for jquery ,underscore and knockout)
my file structure is as follows my file structure is as follows
scripts | | main.js | |_________BusinessScripts | | | | jquery.js | | | | boostrapper.js-undefined ko.js | | dataservice.js-undefined
here is a example of my main file that kicks off require
requirejs.config( { paths: { 'jquery': 'jquery-1.7.1', 'underscore': 'underscore', 'ko': 'knockout-2.2.1' }, shim: { underscore: { exports: '_' }, } } ); requirejs(['require', 'BusinessScripts/bootstrapper', 'BusinessScripts/dataservice'], function (require,bootstrapper, dataservice) { var def = require.defined('BusinessScripts/bootstrapper'); //this returns true if (dataservice !== undefined) { // always undefined alert("Loaded properly"); } else { alert("not loaded!!!"); } if (bootstrapper !== undefined) { // always undefined alert("Loaded properly"); } else { alert("not loaded!!!"); } });
my data service class does a quite lengthy jquery get but as a simple example my bootstrapper is doing next to nothing
//bootstrapper define(function () { var one = 1; var run = function () { } }); //dataservice define(['jquery', 'underscore'],function ($, _) { $.ajax({lengthy work...}); });
as i said both modules are being loaded but are never resolving
any help would be much appreciated.