Using traceur compiler with meteor

I would like to use Javascript generators on client code (and other ES6 features), but AFAIK it's not yet implemented in all major browsers yet or enabled by default. So I found traceur.

But I'm having trouble with Meteor integration. Traceur provides a command line compiler, which I could call as meteor-typescript (even if it's not recommended), because I couldn't find documentation about compiling a string from Javascript with traceur.

Then, I guess a runtime dependency is also required and has to be served to the client. Can I use bower for that?

Thanks in advance for any suggestions or pointers.

Edit: I could call the compiler (see my meteor-traceur), but I don't know how to add the runtime dependency. Traceur defines a RUNTIME_PATH, but I can't use it with api.add_files because the npm module isn't imported inside package.js (where Packages.on_use should be defined).

Answers


The npm depencies are installed in the .npm directoy in the package. You can add the traceur runtime by adding this to package.js:

Package.on_use(function (api) {
    api.add_files(".npm/plugin/compileTraceur/node_modules/traceur/bin/traceur-runtime.js");
});

I forked your repository and fixed this: https://github.com/Sanjo/meteor-traceur

I also created a demo app: https://github.com/Sanjo/meteor-traceur-demo


Need Your Help