Shiver My Timbers! Migrating yargs to ECMAScript Modules
summary
Yargs migrates to dual ESM+CJS so existing users keep working while modern platforms can import it, using a TypeScript → ES2020 build plus Rollup to emit a bundled CommonJS file and an .mjs entry via an exports map. The process increases package size and CI complexity, introduces webpack interoperability bugs, and forces fiddly exports-map and extension workarounds, but it runs in browsers and Deno, shows minimal regressions, and supports 24,000 dependents with 10 million downloads a week via rollup + TypeScript build producing index.cjs/index.mjs.
AI-written summary · about
chapters (14)
- 0:00Start
- 2:08What we'll be covering
- 3:51Not a new concept
- 4:08ServerJS, Jan 2009
- 5:30Asynchronous Module Definition, Sep 2010
- 9:52Writing Pure ESM
- 10:45Writing dual ESM/CommonJS
- 12:53Approaches one could take
- 14:34yargs' new build step
- 15:47rollup.config.cjs
- 16:21tsconfig.json
- 16:40package.json
- 19:44In Conclusion...
- 23:1607 Links/Bibliography
related talks
48mESM: EcmaScript Modules in browser and NodeJS. It's about time!
34mNode.js: Path to ES6 modules
32mES Modules in Node JS
33mES6 Modules in the Real World
37mThe time to migrate to ESM in Node.js is now!
36mMigrating Babel from CommonJS to ESM
23mPublishing in JavaScript Ecosystem: How to Keep Everyone Happy?
34mTowards a simpler JavaScript ecosystem
