[英]Is it ok to use Babel npm package for node.js server application
As Node V6 already supports ~95% of ES6, why are people using Babel on the server side? 由于Node V6已经支持~95%的ES6,为什么人们在服务器端使用Babel? What are the pros and cons of using Babel on the server side?
在服务器端使用Babel的优缺点是什么?
There is one main reason: import
/ export
有一个主要原因:
import
/ export
See: 看到:
There is even a special Babel preset for Node: Node甚至还有一个特殊的Babel预设:
that doesn't transpile anything that Node already supports natively. 这并没有传达Node本已支持的任何东西。
You can also use babel-preset-env
which is "A Babel preset that can automatically determine the Babel plugins and polyfills you need based on your supported environments" - thanks to loganfsmyth for pinting it out in the comments. 你也可以使用
babel-preset-env
,它是“一个Babel预设,它可以根据你支持的环境自动确定你需要的Babel插件和polyfill ” - 感谢loganfsmyth在评论中指出它。 See: 看到:
And Node doesn't support ES6 modules - see this answer for details on why: 并且Node不支持ES6模块 - 有关原因的详细信息,请参阅此答案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.