CommonJS 是一个可以搭载的标准还是只是另一个 JavaScript 模块系统?

Is CommonJS a standard that can be piggybacked on or is it just another JavaScript module system?

维基百科关于 CommonJS 的描述:

[CommonJS] is a project with the goal of specifying an ecosystem for JavaScript outside the browser

我知道这意味着 CommonJS 是一个系统,它与 ES 所使用的平台无关。这是否意味着当在 Web 浏览器的上下文中使用时,它本质上只是 ES 模块系统的另一个大 polyfill(如 SystemJS)?还是它位于像 SystemJS 或 WebPack 这样的模块系统下面,使系统平台不可知?

与 SystemJS 不同,CommonJS 本身是一个 specification, not a module loader. It is platform agnostic in that it relies on core ECMAScript 5 syntax/features; it specifies a set of fields to define - module.exports - and method to read them - require - to facilitate better code organization. It might be thought of as an unofficial precursor to ES6 module syntax. AMD (Asynchronous Module Definition) is a competing unofficial standard, forked from CommonJS 并由 Require.js 实现。

可能是非官方的,浏览器不包含对 CommonJS 模块的任何本机支持,并且使用需要某种模块加载器实现对 CommonJS 的支持(如 Browserify)。 Node.js 实现了 CommonJS 规范,但它甚至 wraps its module executions 在 run-time 的函数中。

CommonJS 是较早的模式之一 (described as "a grass roots effort", as opposed to an official ECMAScript spec addition) intended to account for JavaScript's lack of code organization. According to the project's website) it was created in 2009, around the same time Node.js was originally released, and intended to provided module structure for non-browser execution environments (although it could easily apply to browsers where mega-scripts and globals are just as problematic). The project was founded as result of this blog post

所以回答你的标题问题,这是一个非官方标准,当 ES6 模块(几乎)得到普遍支持时,它就会过时。