babel/example-node-server

Reason for precompiling

rrrnld opened this issue · 2 comments

Hello,

It says the following in README.md:

So we've cheated a little bit by using babel-node. While this is great for getting something going. It's not a good idea to use it in production.

We should be precompiling your files, so let's do that now.

I'm curious, why exactly is it not a good idea? Isn't the code getting executed the same? And as servers are generally longer-running then clients, the code doesn't get recompiled so often but only when the app crashes or gets redeployed. I see the advantages of pre-compiling on the client side, but I'm not sure why it's necessary on the server side. Could someone elaborate?

from https://babeljs.io/docs/usage/cli/#babel-node:

You should not be using babel-node in production. It is unnecessarily heavy, with high memory usage due to the cache being stored in memory. You will also always experience a startup performance penalty as the entire app needs to be compiled on the fly.

Our medium sized Express app takes about 20% more memory (120MB vs 100MB) and startup time is not that important if the process is long-running. The docs only list these two reasons, does that mean if we're aware of these downsides it is safe to use in production?