简体   繁体   English

是否应将Babel用于Node.js服务器应用程序? 为什么呢?

[英]Should I use Babel for a Node.js server app or not? and why?

I love ES6 syntax and this new object oriented stylish approach, which is easier for me to code that way. 我喜欢ES6语法和这种新的面向对象的时尚方法,这种方法对我来说更容易编码。 But it's just a preference, because I'm new to JavaScript. 但这只是一个偏好,因为我是JavaScript新手。 I just want to know the pros and cons of using Babel in terms of performance (if any) and maintenance in the future, readability, etc.... Thank y'all! 我只是想了解在未来的性能(如果有)和维护,可读性等方面使用Babel的优缺点。...谢谢!

Seems like a duplicate. 好像是重复的。 Is it okay to use babel-node in production 在生产中使用babel-node可以吗

You could use babel-node in development, and then transpile your ES6 to ES5 for production if you are worried about performance. 您可以在开发中使用babel-node,然后在担心性能的情况下将ES6转换为ES5进行生产。

ES6 syntax will be supported for the foreseeable future. 在可预见的将来,将支持ES6语法。 That is the nature of standards. 这就是标准的本质。

A common reason Babel is frequently involved in the build process for Node webapps is that Babel allows us to easily compile ES6 code to older versions (usually ES5), because it has better browser support. Babel经常参与Node webapps的构建过程的一个常见原因是Babel允许我们轻松地将ES6代码编译为旧版本(通常是ES5),因为它具有更好的浏览器支持。

For a purely server-side app, there is no reason, other than maybe slight performance gains, to compile to ES5. 对于纯粹的服务器端应用程序,除了可能会有一点性能提升之外,没有其他理由可以编译到ES5。

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

相关问题 是否可以使用Babel npm包用于node.js服务器应用程序 - Is it ok to use Babel npm package for node.js server application 我必须在Node.js中使用Babel吗? - Do I have to use Babel in Node.js? 为什么我不能在共享服务器上使用 node.js? - why can't i use node.js on shared server? 如果我在本地运行Node.js服务器,我究竟应该在http请求中使用什么作为参数'url'? - What exactly should I use as an argument 'url' in http request if i run Node.js server locally? 为什么我应该在带有 node.js 的 http 服务器中的请求处理对象上声明 handle["/"] ? - why should i declare handle["/"] at request handling object in http server with node.js? 我应该如何在使用 node.js 和 vanilla javascript 制作的 web 应用程序中使用代理? - How should I use proxy in a web app made with node.js and vanilla javascript? 我应该将node.js用于我的singe-page-app吗? - Should I use node.js for my singe-page-app? 使用 Babel 编译 Node.js + TypeScript 应用程序:为什么它不使用可选链接? - Transpiling a Node.js + TypeScript app with Babel: why it's not using optional chaining? 为什么 Node.js simple http 服务器应用程序无法在服务器上运行? - Why is Node.js simple http server app not working on server? 我应该使用哪个node.js套接字引擎? - Which node.js socket engine should I use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM