On Apr 22, 2014 8:10 PM, "Aria Stewart" <aredri...@nbtsc.org> wrote: > > On Tue, Apr 22, 2014 at 01:08:52AM -0700, Chetan Dhembre wrote: > > I end up looking their directory structure which is more or less nested .. i > > find following code > > > > var fs = require('fs'), > > > config = require('../../server/config') > > > > > > > which requiring local module using relative path and there is no second > > thought is this is error prone. > > I don't see this as problematic: If you're not burying requires in late, > conditional code (which is an antipattern because blocking the runtime is no > fun), you'd discover this error early, if you make it at all. > > It DOES require a paradigim shift if you're used to something like a PHP > autoloader, where location is irrelevant, or something like Java's import that > abstracts away from the notion of directories to some degree, but I don't think > it introduces any new kinds of breakage. > > In this specific case, perhaps your module should have its configuration > injected by what requires it, rather than requiring its own configuration: > > var fs = require('fs'); > module.exports = function myModule(config) { > }; > > And where it's assembled: > > var config = require('./server/config'); > var mod = require('./modules/myModule.js')(config); > > I think re-arranging to make your dependencies be both a directed, acyclic > graph (which it is now for you, since config doesn't require further things) > and making the directory structure map to that 1:1 as much as possible, you'll > find that things are easier to keep straight and you'll build less > interdependency. > > > My question how does other large project manage code .. because there so > > many small piece code which are closely related to project so can not > > publish on npm and creating that number or private repo is not financially > > feasible (talking about github) > > > > Can any one tell how people manage large code base ? > > Break things up into small modules -- commit them in node_modules, or isolate
I created module (local-require) which simple create symbolic link of ur local module to node_modules folder so that you can use them directly from any place from codebase. > them into better groups (so you don't have to do deep requires). If github's > pricing model bites you, consider using your own git repositories. A simple > http server will suffice, as will a git daemon. > > It may in fact be a sign that you're designing something too tightly coupled > and you need to refactor better shapes. > > Aria -- -- 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com 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 nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.