Require.js : Uncaught TypeError: Object function … has no method-Collection of common programming errors

I’m getting an Uncaught TypeError when i refresh the page, my js/app/main.js file can’t call the method update() on js/app/utilities/resize.js.

Error output

Uncaught TypeError: Object function U(n){return n&&typeof n=="object"&&!me(n)&&ne.
call(n,"__wrapped__")?W(n)} has no method 'update'

I haven’t managed to isolate/replicate the issue into a simplified working example unfortunately. But you can click on the js files within the folder tree below for gists.

  • index.html
  • js /
    • app.js
    • lib /
      • require.js
      • jquery.js
      • … etc
    • app /

app.js

require.config({

    urlArgs: "bust=" + (new Date()).getTime(),

    baseUrl: WP.THEME_URL+"/js",

    paths: {
        app     : "app"
        , jquery  : "lib/jquery-2.0.2.min"
        , ...
        , resize    : "app/utilities/resize" 
        , ...
    }
});

require(["app/main"],function(){});

The method update() is being called on resize.js from main.js;

main.js

define([ ‘require’ , ‘jquery’ , … ,’resize’ ], function( require , $ , … , resize ) {

function setup() {

 resize.update(); // Uncaught TypeError happens here

}

$doc.ready( setup );

resize.js

define([],function () {   

    var resizeItems = [],
        update = function () {

            for (i = 0; i < resizeItems.length; i++){
                var item = resizeItems[i];
                item.callback( App.screen.width , App.screen.height );
            }
        };

    return {
        update  : update,
        add     : function( item ) { resizeItems.push( item ); }
    }
});

Thanks in advance

Edit : It seems it was a dependancy issue. Adding “resize” to require on app.js has resolved it;

require(["resize","app/main"],function(){});

I thought suppling “resize” to define() in main.js would have ensured correct deps;

define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...