javascript - Naming modules with RequireJS -


i trying figure out how name modules without using relative path of module itself.

for example:

instead of doing this:

//module defined in app/js/routers.js define('app/js/routers',['app/js/currentview'],function(currentview) {  }); 

i rather this:

//module defined in app/js/routers.js define('routers',['app/js/currentview'],function(currentview) {  }); 

is possible or bad idea? obviously, names give each module have unique. guess don't see point of optional first parameter in define call if has same path of script it's contained in.

i guess don't see point of optional first parameter in define call if has same path of script it's contained in.

yep, if going put module in file path, relative baseurl give in requirejs configuration, name of module, not have provide module name define. in fact, should not give module name in case. requirejs documentation states:

these [i.e. module names] generated optimization tool. can explicitly name modules yourself, makes modules less portable -- if move file directory need change name. it best avoid coding in name module , let optimization tool burn in module names. optimization tool needs add names more 1 module can bundled in file, allow faster loading in browser.

(emphasis added.)


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -