在 ES6 中,模块会导致多个网络调用,因为不能在单个文件中定义 2 个模块

In ES6 will the module lead to multiple network calls as 2 modules cannot be defined in single file

在 ES6 中,每个模块都在其自己的文件中定义。

这是否意味着如果我们采用 es6 方式,我们将不得不为每个 javascript 模块进行多次网络调用?

是否有连接模块文件的方法,本质上是为 es6 中的应用程序创建一个缩小的 javascript 文件?

我们可以将 es6 代码转译为 es5 并将其连接起来。

但是,如果不转译为 es5,是否意味着要使用模块,我们将无法将所有 javascript 个文件连接并缩小为一个文件?

捆绑是可行的方法。

Modern web applications consist of many, often small, modules. Loading those modules over HTTP impacts performance negatively, because a separate request is needed for each. Therefore, bundling multiple modules as a single file has a long tradition in the web development world. Current approaches are complex and error-prone and only work for JavaScript. Therefore, the W3C Technical Architecture Group is working on a new approach: Arbitrarily nested directories are archived as a single package file. Browsers access files in the package via a new kind of URL:

url-for-package SEPARATOR path-inside-package

来源:http://www.2ality.com/2013/11/es6-modules-browsers.html