Will all nodeJS packages work on MeteorJS?

I experiment with Meter and fall in love with him. My question is:

Is it possible to install any nodeJS package like NodeMailer on my Meteor and make it work out of the box? If not, what are the usual steps to start it?

+3


source to share


1 answer


The short answer is no, Meteor has a dependency on Fibers that breaks compatibility with many pacakges. Currently, getting a package that does not use Fibers to work inside Meteor is done on a case-by-case basis. Here's a recent example

You can follow these instructions to deploy packages with your meteor application.



Here's the rationale behind why Meteor is built with fibers by David Greenspan, one of the main developers of Meteor, highlights mine:

There is really no inherent or obvious performance compromise [between using Fibers or not], so we decided to expose the simpler API (or both).

The Node model is basically, your application receives one thread, an event loop. If you want your application to be fast, the request handler is better off getting out of the thread quickly! The way it is done in vanilla Node is to complete and return after passing the callback somewhere if there is still a lot of work to do. With fibers, the request handler can instead "yield" when doing I / O, so it exits the stream, but is invisible to the programmer. ... It's like there are callbacks in synchronous calls, but the callback is just a continuation of the program. This is what the optimization is trying to mimic, but it happens at the V8 level.

The important point is that Meteor's "synchronous" calls do not block, they are given in the event loop. While typically the event loop will bounce between any callbacks requiring a call, it instead bounces between any functions requiring further execution.

+1


source







All Articles