I would recommend you not to go that way. There's several advantages on 
separating your coding into small pieces and requiring each other when you need 
them. This modular way of developing ensures code reuse.

--  
Diogo Resende


On Tuesday, May 22, 2012 at 18:26 , François wrote:

> Hi,
>  
> I don't like to always use "require(...)" and "module.exports =" in my code.
>  
> That's why I'm asking myself if it would be a good idea to load all .js files 
> and run them with the help of the vm or child_process modules.
>  
> Then the code would be something like this:
>  
> var FS = require('fs');
> var VM = require('vm');
>  
> var root = 'app';
> var code = '';  
>  
> (function read(root) {
>  FS.readdirSync(root).forEach(function (entry) {
>  var path = root + '/' + entry;
>  
>  if (FS.statSync(path).isDirectory())
>  read(path);
>  else
>  code += FS.readFileSync(path, 'UTF-8');
>  });  
> })(root);
>  
> VM.runInNewContext(code);
>  
> What do you think of that ? Could there be performance issues ?
>  
> Regards
>  --  
>  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] 
> (mailto:[email protected])
>  To unsubscribe from this group, send email to
> [email protected] 
> (mailto:[email protected])
>  For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en


-- 
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

Reply via email to