Closed tevko closed 4 years ago
Here is a cool video that explains what are ESMs or ES Modules and what problem do they solve: JavaScript Modules: From IIFEs to CommonJS to ES6 Modules.
This library links the CommonJs world with the ESM, more precisely it allows to dynamically import ESM modules from a CommonJs module/app.
If you'll indulge a shameless plug from the #2 contributor to this library, and you're curious about the basics of ESM, here's a talk I gave at Empire Node 2015 called "The Importance of import
and export
": https://www.youtube.com/watch?v=-zch_YmKfa0
Most of what I said in that talk is still true in late 2019, but it's frustrating that ES2015 modules (ESM for short) are still not usable everywhere by default, without a compilation or bundling step.
Roughly speaking, this library attempts to close that gap for the Node.js platform, by transparently enabling import
and export
syntax in any .js
file in a Node program, so you can use ESM on the server instead of the traditional CommonJS require
and exports
module API.
The good news is that Node has made tremendous progress towards native support for ESM recently, and @jdalton (the #1 contributor to this library) has been an important part of that effort, along with many others.
Thanks @benjamn ! This is super helpful!!
But I'm seriously struggling to truly understand what it does. Perhaps if there were a demo or screenshots, this would be easier to digest, but for now, 2 questions:
1.) What is ESM 2.) What problem does this solve?
I've read the post and watched the video in the readme, and still don't feel any closer to understanding this tool