ES Modules: suggestions for improvement

Wes Garland wes at
Wed Jun 27 13:30:09 PDT 2012

On 27 June 2012 15:45, Kevin Smith <khs4473 at> wrote:

> By implementing it in SpiderMonkey! :)
> That's cheating!  : )
> A social note:  designing the module system for ES6 is a difficult
> position to be in because there's already a more or less de facto module
> system in place (derived from CommonJS).  It's like an empty field has been
> transformed into a garden by the local community, and then the owner of the
> plot wants to plow it up to create a better garden.

Professional gardeners who feed millions plow up their gardens on a regular
basis.  So-called "green manure", usually a nitrogen-fixing legume such as
white clover, is grown after the money-making crop.  This crop will add
nitrogen (a key element in plant growth) from the atmosphere into the soil
through the action of bacteria growing in its roots. Then this crop is
plowed under, allowing it decompose to add organic matter to the soil
before the next crop is sown.

Similarly, while I have a *LOT* of time, money, and effort invested in and
around the CommonJS ecosystem, I eagerly await the addition of a native
module system to the language.   The CommonJS experience helped to generate
a lot of fertile ideas and willpower in the community, and when it is time
for a better crop to be sewn, I see no reason not to plow it under in order
to grow something better.

Remember that CommonJS is not all about modules -- CommonJS modules only a
means to and end, which is to create a base-level environment for executing
ES code on a wide variety of host platforms.  It's impossible to have large
systems without modules.

There are some serious issues which remain to be addressed with CommonJS
modules, in particular,  good ways to handle the global var scope, which
cannot be addressed in the browser... and to address them on the server, I
had to do some things to SpiderMonkey which would probably make Brendan cry.

One thing I hope we can still have in ES6 modules, though, is the ability
to lazy-load modules in a server-side context without altering the
semantics of the program.  I'll have to give that some thought in the


Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list