instead of require
ing code relatively, ie starting with ./
or ..
, i'd like to define a module "globally". For example, take the following package structure:
/src
/index.js
/a.js
/b.js
/lib
/index.js
...
When in src/a.js
or src/b.js
, to require lib
, I would have to do require('../lib')
each time. This gets annoying when you start nesting more as you would have to manually resolve ../lib
or ../../lib
or ../../../lib
.
I want to be able to do require('lib')
. Can I do this? Or should I just use globals?