There is definitely a method to my madness.
First, I would only recommend doing this in a deployable application, not a
module that deploys to NPM. The best NPM packages are small and focused;
having lots of internal dependencies is probably a smell.
Second, I do this to help filter out code that belongs in a library
anyways. I have two directories at the root of my project which separate
code functionality.
/app <-- contains MVC architecture of web application
/lib <-- contains emerging utility libraries
Note that *nothing* in /lib should directly require anything in /app. The
libraries in lib should evolve into separate, and self-contained modules.
These are the future candidates for NPM modules.
Since modules in lib should behave like external libraries, I require them
like external libraries. I symlink lib into node_modules.
/node_module
/lib --> ../lib
In your application, you can require any of these modules with
var module = require('lib/module');
When time comes to actually refactor these modules into their own code, it
is a relatively straight forward to change your application.
*Under this model, I was able to hunt down all my upward requires and help
eliminate some bad design in the process.*
There is really no functional difference between using this vs relative
requires, it's psychological. It makes me focus on keeping lib pure, and
the lack of ../ gives me the warm fuzzies.
Finally, if your only reason is to avoid typing two periods, I would
question your whole approach. Fewer keystrokes do not make a better
application.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.