Skip to main content
🧙‍♂️ Kris Kowal 🐘 🐙 🧛 📌 📬 Book Store

The CommonJS Dialectic

In the first weeks of 2009, a mailing list that called itself ServerJS argued its way to the module system that Node.js adopted and that npm built upon. I was there, and I posted more than anyone, which is not the same as being right more often than anyone. This series reconstructs how the design was argued and decided, from the list itself.

The record is the group's own archive: 745 threads and 9312 messages, from January 29, 2009 to January 21, 2016, with every message linked here to its place on Google Groups. Where the list pointed at the wiki, I read the wiki through the Internet Archive, and where it pointed at code, I read Narwhal, Node.js and npm at their own commits.

This first part is the timeline and the method: how we summarized, called for hands, asked for positions, and argued point by point. The second part is about modules: require, exports, wildcard imports, and the two kinds of identifier. The third is about packages: the descriptor, versions, and the engine overlays that npm's conditional exports and imports would one day answer. The fourth is my own view, looking back from 2025, with this record set against it.

Each design point is drawn as a small IBIS map: the issue (a question), the positions taken on it, the arguments for and against each, and the resolution the record shows. The full map, eighteen issues with every node cited, is kept in my library; these articles render the ones that carry the story.

Before the list #

Ihab Awad and I had already been at it. I described the run-up at the time: the Caja team and I had designed a module system that "looked just like any other, but also reused inert module factories for multiple sandboxes," and in January 2009 Mark Miller put Ihab and me on the agenda of the ECMAScript committee to present it. At about the same time, Kevin Dangoor asked what server-side JavaScript needed, and a flash crowd answered. So when the list began, we had a proposal ready. I was particularly inspired by Python and Dojo, and disliked the Java-style namespaces of Google's Closure, as I tell it in the last part.

What we did not have was agreement that a module needed its own scope at all. Very few people wanted modules then, and I never took it for granted that they would come to.

The timeline #

These are the moments the record shows mattered. Most of the decisions about modules were made in the first two weeks.

The volume tells the same story. By the year each thread began:

Year Threads Messages
2009 379 4901
2010 247 3489
2011 92 825
2012 to 2016 27 102

How we argued #

Kevin set the tone on the second day. Ycros had asked for a wiki where proposals could be "discussed/voted on". Kevin already had one, and foresaw "some sort of process that involves proposals and counter proposals, voting and people taking on the dictator role for certain parts of the whole that they're very committed to." "Unlike Python," he wrote, "we have no benevolent dictator." And he named the weight that would decide most things in the end: "the people implementing the APIs necessarily have more say than anyone else."

What grew from that was a handful of habits.

Summaries #

Much of the early argument happened on IRC, in #serverjs, which is not in the archive. What survives of it is the summaries people carried back to the list. Kevin's "Are we agreed on require, in general?" reported a day of IRC in a few paragraphs, put the choice as two numbered options, and asked for "a rough idea of whether people are happy with module-scoped require()." Peter Michaux kept an open-issues list on the wiki. Kevin described the wiki as the place "to boil down the discussions into something actionable," and that is how we used it: the list argued, and the proposal page absorbed the outcome. When two proposals diverged, someone wrote both down side by side, as James Burke did for Transport/B and Transport/C, admitting that "my perspective is probably unfairly weighted in this message."

Shows of hands #

The show of hands was the list's signature. Kevin's first one set the form: state the proposal, link it, and "keep this thread to +1 / 0 / -1 and discuss any remaining issues with the proposal in separate threads." Restating objections in a fresh thread, he added, "is not a bad idea, given how much traffic has gone by and how the module proposal has changed over time."

When the choices were many, I lettered them. For what require returns, I offered A through E, with jokes, and restated them without the jokes two days later when Kris Zyp asked on IRC what I actually meant. Peter Michaux added an F. People replied with a letter and, often, a second choice.

Ihab ran "calls for votes" in the same spirit, on the syntax of require in the presence of packages and on the name of the system's own package. The second drew Mark S. Miller's most quotable line: "A global namespace is a bug. Period."

I tried, more than once, to say what a show of hands was not. During the setExports argument I wrote that "our "Show of Hands" tradition is not voting and this isn't a democratic process, but a dialectic process," and that a feature with broad support still should not become a standard "until all of the engines are willing to implement it." A tally told us who still needed convincing. So I asked the proponents to "focus on convincing Mark, Ihab, and Wes."

Asking for positions #

That was the third habit: when a thread stalled, ask the holdouts to state what they wanted. When Tom Robinson voted for Securable Modules but still wanted include, I asked him to "reply with what you would like that to mean". When Hannes objected to one detail of Modules/1.1.1, he did not mince words: "I'm sorry, but changing a ratified spec based on the misapprehension of a single person does not exactly boost my confidence in this whole process." I held the revision for him: "There's no cause for alarm. As always, unanimity is important; I for one have no intention of going forward without your hand up."

Point by point #

The method matured by 2011. When the asynchronous require for Modules/2.0 bogged down, we split it into one thread per point: the name, the invocation arguments, the callback arguments, and eager or lazy evaluation. Each opened with lettered options and a block that said "Current show of hands. Please copy and alter in your responses," so every reply carried the running tally. Then I wrote the summary, whose purpose was "to decompose the issue into bite-size chunks and determine whether some of these issues are pure-bikesheds, moot, and which parts are actually contentious," and which named who stood where on each.

That is IBIS in all but name: an issue, its positions, who argues for each, and which ones are only bikesheds. These maps are an attempt to draw the rest of the record the same way.

Ratification, and its discontents #

Issue: when is a proposal done?

Mark S. Miller had the sharpest diagnosis of the alternative. In the setExports thread he wrote "+100 for picking one way and sticking with it. The most common pathology of a standards body is to "solve" their inability to decide between alternatives by simply doing both. For better or worse, CoomonJS is now a functioning standards body, pathologies and all."

Where the method won, and where it lost #

The method worked best when the people in the room were the people who would implement the result. In February 2009, everyone with a module loader was on the list, and the hands were the implementations. Ihab introduced Securable Modules on February 3, and by February 11 twelve hands were up and none down. By the end of the year, the Modules/1.0 page listed ten implementations passing all of the compliance tests, among them Flusspferd, v8cgi, Narwhal, GPSEE, Chiron and Helma NG, with Persevere fully implemented and three more in development.

By April 2010, that had changed. In "Strategy" I wrote that Ryan had said at JSConf that standardization was premature, and that "as hurtful as this statement was to the CommonJS community, there is also a kernel of truth." Node had its own users and its own momentum. When the list could not agree on replacing the exports object, Node already had module.exports; when the list argued over package mappings, npm already had a folder layout. Mikeal said it plainly in May 2011: "CommonJS can't even agree on a good solution to module.exports, why bet the future on node modules on this list?"

So the show of hands decided the things that every implementation had to agree on to share code at all: module scope, require, exports, the two kinds of identifier. It could not decide the things one dominant implementation had already shipped. Those were settled by Node and npm, and the next two parts follow both kinds of decision through the record. I did not expect Node to exist, and I give it and npm the credit for what they settled, in the last part.


The JavaScript Modules Chronicle:

  1. The CommonJS Dialectic
  2. CommonJS Feature Discussions
  3. CommonJS Packaging
  4. CommonJS Retrospective