Reputation: 23803
I spent a lot of time to build a webtemplate (front-end) with a grunt file to "compile" the whole project and have an efficient code in production.
Now that I am working on a back-end project (with node/express) i was wondering if it make sense to "compile" a node project ?
I'm using ES6 syntax with Babel so i imagine that everytime i launch the project (node index.js or nodemon index.js) Babel transpile it in ES5 and then run it.
I don't care if it's done at the beginning of the project and there is no impact once it has been launched. But i'm not sure.
Does node read the whole program and "save" it into ram ? If so i imagine that it's not useful to concat/compile javascript file like we're used to with front-end.
Upvotes: 2
Views: 88
Reputation: 6791
Yes, at least it's not a bad idea.
However:
nodemon
is not meant for productionbabel
as a runtime, you introduce it as additional layer of possible failures, on top of your code.node
platforms or be more efficient when you make it available as a module.So better:
char
count. But the effect is probably really low, since only the real hot functions benefit from it.npm shrinkwrap
is a good tool for this also.Concluding: Don't do it, since it rather feels like premature optimization, which is generally a bad idea. You will meet heavy problems of node debugability, which will be a problem at dev-time.
Rather follow general Node.js performance guide, and if you don't target other platforms than your production environment, choose the newest Node.js version with all the ES6 features you need.
Upvotes: 2