简体   繁体   English

Nodejs 4.x上的ES6代码:V8 4.5是直接运行ES6的本地JS引擎吗?

[英]ES6 code on Nodejs 4.x : Is V8 4.5 a native JS engine that runs ES6 directly?

I'm trying to upgrade a micro service that's on Nodejs 1.0.x to Nodejs 4.x. 我正在尝试将Nodejs 1.0.x上的微服务升级到Nodejs4.x。 The purpose is to enhance the functionality of this service & take advantage of ES6 features, especially avoid prototype clutter in new code segment. 目的是增强此服务的功能并利用ES6功能,尤其要避免新代码段中的原型混乱。 While going through few blogs, I've come across a statement that ES6's module pattern is standardised and it's Asynchronous unlike require(). 在浏览几个博客时,我遇到了一条声明,即ES6的模块模式是标准化的,并且与require()不同,它是异步的。

If the module loading is Asynchronous(with import of module syntax), I'm trying to understand how the code in that file take advantage of this feature? 如果模块加载是异步的(带有模块语法的导入),我试图了解该文件中的代码如何利用此功能? All the code that have dependency on this asynchronously imported module will also become asynchronous? 依赖于此异步导入模块的所有代码也都将变为异步代码吗? If yes, instead of combination of require (synchronous) and import/module (asynchronous), I would like to change every thing to import/module assuming the performance gain. 如果是的话,我想将性能(而不是require(同步)和import / module(异步))组合在一起,而是将每件事更改为import / module(输入/模块)。

I need some help in correcting or fine-tuning my thought process. 我需要一些帮助来纠正或调整我的思维过程。

ES6 modules are loaded synchronously in Node.js (server). ES6模块在Node.js(服务器)中同步加载。 They are loaded asynchronously only in the browser. 它们仅在浏览器中异步加载。 The advantage of import is that it's the same keyword for both use cases. import的优点是两个用例的关键字相同。

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

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