Just a user-experience report with traceur: the following code fails to
compile in the repl.html and command line compiler:
-----
import {WrapNewObjectTransformer} from './WrapNewObjectTransformer';

export function transcode(src, url) {
    var file = new SourceFile(url, src);
    var reporter = new ErrorReporter();
    var tree = new Parser(reporter, file).parseProgram(true);
    return (new WrapNewObjectTransformer()).transformAny(tree);
}
----

It fails on 'unexpected token export'. This was unexpected by me ;-)

However it does seem consistent with the grammar in
http://wiki.ecmascript.org/doku.php?id=harmony:modules.  The |export|
keyword is part of an ExportDeclaration which appears in a ModuleElement
but not in a ScriptElement. The parser believes it is parsing a Script. So
the only way to legally parse JS as a Module is as a side-effect of module
loading?

I suppose that a Script is intended to be the root of the dependency tree,
so the error message is trying to tell me "You are compiling an interior
node of the dependency tree silly". But both Script and Module are things
that JS devs will want to compile. Concretely I will want to be able to
copy the contents of a JS file and paste it into a repl window to analyze
it without having it die on syntax errors because it is a module.

hth,
jjb
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to