It turns out that basedir
is not the same as RequireJS's baseUrl
. As stated by @Ben in the comment above, the official docs says:
opts.basedir
is the directory that browserify starts bundling from for filenames that start with.
.
Meaning that basedir
only applies to the entry
files. Further require
calls deep in the file tree structure will always be resolved relatively to the file currently being parsed.
Answer to my question
The paths
option of browser-resolve
(which is used by browserify
under the hood) is what I was looking for:
paths - require.paths array to use if nothing is found on the normal node_modules recursive walk
Just pass this option along with other browserify
options when instantiating the bundler.
Note: It looks like it is messing up things when using together with browserify-shim
transform.