Confused about RequireJS requirements

I am trying to wrap my head around dependencies in requirejs.

  • If I already declared dependencies for a file with shim, do I need to re-declare it when I define a module in this file?
  • If I use requiredependencies such as a trunk to load, do I need to re-declare this when I define a module that loads as part require?

Here is my code:

require.config({
    //alias
    paths: {
        Backbone: 'libs/backbone-min',
        Config: 'config',
        Dom: 'dom',
        App: 'app'
    },

    //dependencies
    shim: {
        'Backbone': ['libs/underscore-min'],
        'Dom': ['libs/sizzle']
    }
});

//used to load and use stuff
require(['Config','Dom','App','Backbone'], function(){

});

So, in dom.jscan I just identify the module with define(function(){...});and start using Sizzle? Or I still need to define it like this:define(['libs/sizzle'], function(){...});

Also, if I define a module in app.js, I still need to load the trunk into define, since I already included it as part of it require().

+5
1

1) , , ?

.

2) , , , , ?

,

define(['backbone'], function(Backbone) { .. }
+1

All Articles