senecajs/seneca-web-adapter-koa2

^ SyntaxError: Unexpected token

cnxuyc opened this issue · 5 comments

const Seneca = require('seneca')
const SenecaWeb = require('seneca-web')
const Koa = require('koa')
const Router = require('koa-router')
const app = Koa()
const seneca = Seneca()
seneca.use(SenecaWeb, {
  context: Router(),
  adapter: require('seneca-web-adapter-koa2')
})
seneca.ready(() => {
  app.use(seneca.export('web/context')().routes())
`})`

Run the above code to get an error

context[method.toLowerCase()](route.path, async (ctx, next) => {
                                                      ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Search You\WebstormProjects\node-ms-user\index.js:13:14)
    at Module._compile (module.js:570:32)

Ya know what - I don't think I ever tried to install this repo after having published it.

The version that is published to npm isn't transpiled, I don't think.

Congratulations, you are the first person to actually install and try the package
(and find it not working at all!)

I'll publish a patch to this shortly....

However, I just upgraded to version nodejs 7.6.0, successfully running,i think you package should add es7 async await support。

I've added the babel transpile which is what the tests run under... this is now published as 1.0.2

Should work with node 4+ now.

Shoot. I just tried installing it actually and it's not pulling in the lib directory properly.

Back to the npm docs to me... standby.

Ok, should be working now... I've verified the install and it has all the bits where they need to be.