Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/koaPublic

Async Functions with Babel

imed jaberi edited this pageJul 15, 2020 ·1 revision

To useasync functions in Koa in versions of node < 7.6, we recommend usingbabel's require hook.

require('babel-register');// require the rest of the app that needs to be transpiled after the hookconstapp=require('./app');

To parse and transpile async functions,you should at a minimum have thetransform-async-to-generatorortransform-async-to-module-method plugins.For example, in your.babelrc file, you should have:

{"plugins": ["transform-async-to-generator"]}

You can also use theenv preset with a target option"node": "current" instead.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp