

ES6 Module Transpiler - Tomorrow's JavaScript module syntax today - tomdale
http://corner.squareup.com/2013/02/es6-module-transpiler.html

======
wycats
Good work Brian! I'm glad you ported my initial Ruby implementation to
JavaScript, which will make it available to a much wider group of users!
Special thanks to Erik Bryn for convincing Brian to do the port in the first
place ;)

The next step would be to take this and use it to polyfill the ES6 Loader API
(probably using something like the require.js loader, but doing the actual
transpilation in JavaScript). I also hope that people build tools on top for
things like grunt, brunch and other common build tools.

There's still a lot of work to be done before final approval of the module
spec, but I hope that wider use of the module syntax will provide some much-
needed perspective on the syntax and how it is likely to be used.

One important point: I wrote the original Ruby version of this when single-
export was still a part of the proposal. It has since been deferred (although
that may still change again! We live in interesting times).

To emulate single export using ES6 modules (this syntax is not yet supported
by the transpiler, but it should be):

    
    
        // glob.js
        function module() {
          // implementation of glob
        }
        export module;
    
        // glob_user.js
        import { module: glob } from "glob";
        glob("**/*.js");
    

I hope that the transpiler continues to track the current state of the spec as
it moves towards completion :)

~~~
eranation
Hope it's not completely off topic, but since I've just learned you are behind
the Ruby version, I'm sure you'll be able to shed some light on my utter
confusion in this field, I'm trying to wrap my head around how to organize my
JS project, there are so many build tools and package managers (yeoman,
brunch, grunt, volo, bower, component.io) and so many technologies (AMD,
CommonJS, RequireJS) and tools (this, browserify, TypeScript). It's a bit hard
for me to get started.

I hope you don't mind if I ask, how do you organize your projects? How do you
organize Ember.js development? Is there a package manager out there that does
bower/volo/componet install X and also adds it to my RequireJS config? or is
this still done manually? Is there a bullet proof grunt configuration that you
would recommend? any skeleton projects that you would use? I find it really
hard to come up with a best practice, when there are so many possible
practices, so your opinion is highly appreciated.

Sorry for the a bit off topic question, but thought others might benefit from
your answer.

~~~
wycats
Right now it's mostly a "roll your own" affair. Rails provides a decent system
(via the asset pipeline) for people fully inside the Rails ecosystem, but
something better really needs to exist.

I'd bet that it will within a year (or maybe even a few months if we get
lucky!)

~~~
eranation
Thanks, I assume that if I'd like to try and help it a little bit then the
starting point is the CommonJS Google group?

------
eranation
Really nice, I'm sure I've seen a few other similar alternatives, but I can't
remember exactly. Is there a grunt plugin for this, did anyone work with it
and had any issues?

------
33a
How does it handle module.exports?

That's the preferred way to export a single function in CommonJS/Node, and one
of the main sticking points in the current ES6 spec.

------
cpeterso
OT, but light grey text on a white background can be difficult to read. :\

