javascript - Using Node.js require vs. ES6 import/export -


in project i'm collaborating on, have 2 choices on module system can use:

  1. importing modules using require, , exporting using module.exports , exports.foo.
  2. importing modules using es6 import, , exporting using es6 export

are there performance benefits using 1 on other? there else should know if use es6 modules on node ones?

are there performance benefits using 1 on other?

keep in mind there no javascript engine yet natively supports es6 modules. said using babel. babel converts import , export declaration commonjs (require/module.exports) default anyway. if use es6 module syntax, using commonjs under hood if run code in node.

there technical difference between commonjs , es6 modules, e.g. commonjs allows load modules dynamically. es6 doesn't allow this, but there api in development that.

since es6 modules part of standard, use them.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -