Using Node.js require vs. ES6 import/export

后端 未结 10 776
醉酒成梦
醉酒成梦 2020-11-22 05:19

In a project I\'m collaborating on, we have two choices on which module system we can use:

  1. Importing modules using require, and exporting using
10条回答
  •  粉色の甜心
    2020-11-22 05:21

    The main advantages are syntactic:

    • More declarative/compact syntax
    • ES6 modules will basically make UMD (Universal Module Definition) obsolete - essentially removes the schism between CommonJS and AMD (server vs browser).

    You are unlikely to see any performance benefits with ES6 modules. You will still need an extra library to bundle the modules, even when there is full support for ES6 features in the browser.

提交回复
热议问题