TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ES6 Module Transpiler - Tomorrow's JavaScript module syntax today

28 pointsby tomdaleover 12 years ago

4 comments

wycatsover 12 years ago
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 ;)<p>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.<p>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.<p>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).<p>To emulate single export using ES6 modules (this syntax is not yet supported by the transpiler, but it should be):<p><pre><code> // glob.js function module() { // implementation of glob } export module; // glob_user.js import { module: glob } from "glob"; glob("**/*.js"); </code></pre> I hope that the transpiler continues to track the current state of the spec as it moves towards completion :)
评论 #5242058 未加载
eranationover 12 years ago
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?
评论 #5241938 未加载
33aover 12 years ago
How does it handle module.exports?<p>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.
cpetersoover 12 years ago
OT, but light grey text on a white background can be difficult to read. :\