Hello, RequireJS. I can set the base path as follows: base : './app/' , for example, when I'm in ./app/foo/bar/ , and I have a script where I use require('foo'); RequireJS will then search for ./app/foo.js and not in the node_module folder or in ./app/foo/bar/foo.js , this is convenient if you have a structure where it would be much easier for you, as developer, see dependencies instead of ../../foo.js . I could have ./app/foo.js and ./app/foo/foo.js and ./app/foo/bar/foo.js would be much cleaner:
require('foo'); require('foo/foo'); require('foo/bar/foo');
but not:
require('../../foo'); require('../foo'); require('./foo');
Now you could say, why not change the name and hurt foo, let's say that we cannot for some reason ...
Another drawback of the function that I see in node requires a method against RequireJS is the ability to set path mapping, if I have a directory named ./app/super-sized-directory-name/ in RequireJS, I could just do 'big-dir' : 'super-sized-directory-name' and then I could just use require('./app/big-dir/foo') with Node.js requires a method, this is not possible as far as I know. ..
source share