~/talk

Shiver My Timbers! Migrating yargs to ECMAScript Modules

Talkat OpenJS World 2021 · 2021-06-02..06-03· [javascript, nodejs]
links:none on file
slides:none on file

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

  1. 0:00Start
  2. 2:08What we'll be covering
  3. 3:51Not a new concept
  4. 4:08ServerJS, Jan 2009
  5. 5:30Asynchronous Module Definition, Sep 2010
  6. 9:52Writing Pure ESM
  7. 10:45Writing dual ESM/CommonJS
  8. 12:53Approaches one could take
  9. 14:34yargs' new build step
  10. 15:47rollup.config.cjs
  11. 16:21tsconfig.json
  12. 16:40package.json
  13. 19:44In Conclusion...
  14. 23:1607 Links/Bibliography
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.