简体   繁体   English

带有Webpack的Node.js后端API

[英]Node.js Backend API with Webpack

I was just curious if it is worth while to use webpack to bundle a Node.js backend API or if others out there are doing this in practice. 我只是很好奇,是否值得使用webpack捆绑Node.js后端API,或者实际上是否有其他人这样做。 I am currently developing a few Node.js APIs and wondered if others felt that this was worth while or if just using straight up Node.js without webpack or babel was the better way to go. 我目前正在开发一些Node.js API,想知道其他人是否认为值得这样做,或者仅使用没有webpack或babel的Node.js是更好的方法。

Thanks. 谢谢。

I've yet to see the benefit of using something like webpack for the backend. 我还没有看到在后端使用webpack之类的好处。 This is running in your server so bundling and concatenation etc make little sense. 这是在您的服务器上运行,因此捆绑和串联等都没有意义。

Transpilation, on the other hand, is a great thing to have for your javascript code. 另一方面,对于您的JavaScript代码而言,转译是一件很棒的事情。 As long as you're compiling from something that doesn't try to completely mutate javascript (I'm looking at you coffeescript). 只要您使用的是无法完全变异javascript的内容(我在看您的coffeescript)。 So feel free to use Babel or Typescript for your backend. 因此,请随时为您的后端使用Babel或Typescript。

I have worked on node project that has been built by webpack/babel because await and several things from ES7 were used. 我从事的工作是由webpack / babel构建的节点项目,因为使用了await和ES7的一些功能。

For example await is compiled like while(true) till the query receive the result. 例如, awaitwhile(true)一样被编译while(true)直到查询接收到结果为止。 I don't think that is optimal. 我认为那不是最佳选择。

Node.js supports ES6 and it is enough to use it clear. Node.js支持ES6,足以将其清除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM