Gil Tayar explains the history, challenges, and strategic decisions behind migrating Node.js applications to ES Modules.
Yes, they’re here. Node v13.2.0 marked the first version of Node.JS where ESM support is unflagged, meaning you can start using ES Modules. It’s been a long, four-year journey from defining them in the spec (June 2015!) till they could be used in Node.JS (November 2019).
Why did it take so long? What were the major hurdles? Should we migrate? How does the migration path look like? Are they really better than CommonJS Modules? What is in store for the future?
Gil Tayar, a former member of the Node.JS Modules Working Group, and now just a passionate observer of it, will try and navigate these confusing waters, and hopefully make you understand why, when, and how to migrate your Node.JS code to use ES Modules.
Slide deck: docs.google.com/presentation/d/1k45i4nq3cNHsTq-84V19fv4-9M6J…
Event: NodeConf Remote 2020 (NodeConf EU)
nodeconfremote.com/
Twitter: twitter.com/NodeConfEU
Why it's here
2 people recommend this
What people say. Recommended for understanding the complex details and strategic decisions of adopting ES Modules in Node.js.
y
u/yonatannnin r/node • Recommends
On “Advanced Node.js videos”
**Title:** ES Modules in Node.JS
**Abstract:** This one is not about the ESM syntax rather about the harder parts and more strategic decisions one should consider before he hopes to this journey
**Length:** 30 min
[video
On “10 Insights from Adopting TypeScript at Scale”
Having been part of Node's Modules team, I can do a bit of myth-busting on classic CommonJS (CJS) vs the new ES Modules (ESM) support in Node.
* Node's ES Module support is fully compliant with ECMAScript specification
* There is no obligation to use `*.mjs` extension. If you set `"type": "module"` in `package.json` all `*.js` files are interpreted as ESM. In which case you can use `*.cjs` to opt-back individual files to be CJS.
* ESM files can `import` CJS files. The CJS `exports` object is accessed via the `default` import.
* `import everything from "./my-module.cjs"`
* ESM files can use named imports to access properties on the CJS `exports` object, in nearly all cases.
* `impor…