I am trying to compile a Koa application, and Koa has statements that verify that I pass the generator functions as middleware. However, I would like to compile my server side code from ES7 using Babel for interface consistency.
Is it possible to configure the target node, not ES5? I do not see anything promising in the settings, but the choice of purpose seems standard, which can be done with the compiler.
Update
Blacklisting Babel regenerator conversion seems inefficient, although I use stage: 1 .
index.js:
require( "babel/register" )({ sourceMaps: "inline", stage: 1, blacklist: [ "regenerator" ], optional: [ "asyncToGenerator" ] }); var app = require( "./src/server" ); app.listen( process.env.port || 3000 );
Src / server.js:
import koa from "koa"; import router from "koa-router"; router.get( "/", function *( next ) { this.body = "Hi!"; }); let app = koa(); app.use( router() ); export default app;
Run: node --harmony index.js
node --version v0.12.4
source share