One of the things I enjoy about ECMAScript modules is their ease on the eyes. They look good — the same way Python’s import statement can look nice. It’s also nice to have to explicitly import the things necessary for a file/module to its work. Need the whole module? That’s a choice that has to be made.
import { oneThing, twoThing } from 'some-module';
One way to mimic this what the plain old require
call is to use descructuring on the left side of require
.
const { oneThing, twoThing } = require('some-module');
Still fairly aesthetically pleasing, but works fine with Node where ECMAScript modules are still experimental.