Hello, Modules!

Sindre Sorhus on 2021-05-05

JavaScript Modules, also known as ESM, is finally here!

It has already been available for some time in modern browsers, but we can now finally use it in Node.js, thanks to Node.js 10 becoming obsolete.

As I wrote about earlier this year, I have personally been waiting for this day for 10 years.

Here’s a good overview of JavaScript Modules.

What are the benefits of JavaScript Modules over CommonJS?

I’m a package maintainer, what should I do?

There are two ways to handle the migration:

  1. Pure: Rip off the bandaid and completely move to JavaScript Modules.
  2. Dual: Introduce a build step that transpiles a CommonJS fallback.

I would recommend 1, which is what I’m going with. 2 has a lot of downsides.

Please first read everything here.

You can then follow my migration guide.