What I've learned from this is to be careful when you use `module.exports
=`.
It doesn't come up much, because it's only a problem (I think) when there
is some mutual recursion in your require() trees. I've done this to myself
when building packages where I was exporting functions via
I've encountered this myself in personal projects. With tests you will
catch it early of course, but I'm not sure if there is a linter/tool that
will catch this early on to save grief later
On Mon, Dec 16, 2013 at 4:49 AM, Patrick Mueller pmue...@gmail.com wrote:
What I've learned from
The big problem with exporting functions - or exporting anything by using
`module.exports =` style of exporting - is recursive require problem. I
couldn't quickly find any ref to this on the web, so did a little gist:
https://gist.github.com/pmuellr/7975152
On Thu, Dec 12, 2013 at 7:37 PM,
Super interesting, I am surprised this doesn't come up more often really.
I suppose the moral of the story is to avoid executing code in your modules
outside of the scope of things you are exporting.
On Mon, Dec 16, 2013 at 3:46 AM, Patrick Mueller pmue...@gmail.com wrote:
The big problem
More fun on the topic.
http://www.richardrodger.com/monolithic-nodejs#.Uq6k4WQW2LB
Love the thinking spreading to hypermedia w/ the term 'microservices'. Not
directly in our wheelhouse but related.
On Mon, Dec 16, 2013 at 12:08 PM, Brian LeRoux b...@brian.io wrote:
Super interesting, I am
Create modules that are the smallest possible unit of code. Less code is
fast code. Faster to write. Faster to maintain. Faster to test. On the
extreme end characters in the Node community such as Substack advocate a
single function per module definition.
module.exports = function() {
// my
I also agree with this except for returning a function from module.exports.
It is possible but makes mocking much much harder for testing.
think of:
var foo = require('foo');
module.exports = {
awesome: function (a) {
foo(a+1);
}
};
It is kind of awkward to test this module's
Maybe. Have a look at Substack's code and you'll see he has no trouble
testing. The reason being he tests interfaces and outputs instead of
implementations. That will be another Node 101!
On Fri, Dec 13, 2013 at 10:24 AM, Gord Tanner gtan...@gmail.com wrote:
I also agree with this except for
ALSO: lets avoid using terms like 'I agree' or 'I disagree'. Its
programming. The answer is ALWAYS 'it depends'. No absolutes in the sea of
change.
On Fri, Dec 13, 2013 at 10:34 AM, Brian LeRoux b...@brian.io wrote:
Maybe. Have a look at Substack's code and you'll see he has no trouble
It depends what you define as outputs.
in a given module:
var foo = require('foo'), bar = require('bar'), baz = require('baz');
module.exports = function(a, b) {
foo(3);
bar.method(a);
baz(b);
return done;
}
I have always counted the calls to foo, bar and baz as output that
10 matches
Mail list logo