What Are ES6 Modules?

From working with frameworks like React.js, Angular or Vue this syntax should already be known:

export { buttonComponent as Button }
import { Button} from"./components.js"

With this syntax, we can exchange single parts like functions, arrays, objects and more of our source code in single files, by providing them with export and including them with import.
Basically the import and export syntax is used everywhere where we write JavaScript and then transcompile and bundle it to “old-school” javascript. But the time when it can only be used in conjunction with compilers like Babel is over.
Meanwhile Node.js also supports the so-called ES6 modules, and in the browser we can use them if we want to. On both use cases, we will have a look at the end of this article.

#javascript #es6 #web-development #nodejs

Understanding ES6 Modules import / export syntax in JavaScript
1.40 GEEK