Examples of ES Modules #210
Description
I have been attempting to follow the evolving discussion around ESM support in Node.js, but I'm very confused about some fundamental points, and I suspect others are as well. In particular, I can't figure out whether import
only operate on files with mjs
extensions or work within files with mjs extension. Statements like this unfortunately do not clear it up for me:
import statements will only support files with an .mjs extension, and will import only ES modules, for now.
Also: module.createRequireFromPath
. I have no idea how I'd even start to use this method. I'm the "javascript expert" at my work but I struggle to explain the future (or present state) of module loading in
JavaScript so I'm keen to understand this better.
🙏 Request: Is a list of concrete examples in the offing? A blog post, a repository, or a gist of runnable examples would be very helpful.