Hello with RequireJS I can set a base path like this: base : './app/'
so when I am in ./app/foo/bar/
for example and I have a script where I use require('foo');
RequireJS then would search for ./app/foo.js
and not in node_module
folder or in ./app/foo/bar/foo.js
this comes handy when you have a kind of structure where it would be much cleaner for you as a developer to see the dependencies instead of having ../../foo.js
. I could have ./app/foo.js
and ./app/foo/foo.js
and ./app/foo/bar/foo.js
it would be much more cleaner to have:
require('foo');
require('foo/foo');
require('foo/bar/foo');
rather than:
require('../../foo');
require('../foo');
require('./foo');
Now you could say why not change the name and not have foo everywhere, let's say that we can't for any reason…
Another lack of feature that I see in node's require method against RequireJS is the ability of setting path mapping, if I have a directory named ./app/super-sized-directory-name/
in RequireJS I could simply do 'big-dir' : 'super-sized-directory-name'
and then I could simply use require('./app/big-dir/foo')
with Node.js's require method this is not possible as far as I know…
--alias, -a Register an alias with a colon separator: "to:from"
Example: --alias 'jquery:jquery-browserify'
You can register aliases with browserify, so that covers your renaming.
As for your rooted absolute paths, that can't really be done. As mentioned modul8
has a namespacing mechanism to solve this.
I would recommend you pong SubStack in #stackvm on freenode and ask him directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With