Vuepress: Async / await

Created on 18 Apr 2018  路  9Comments  路  Source: vuejs/vuepress

we can't use async await by default with a custom components in doc

.vuepress
--components
----customcomponents.vue

async sendRequest(){
 const response = await axios.post(this.url, JSON.parse(this.$refs.requestBody.innerText))
  //do soomething
}

need a specific loader (babel i suppose).

Maybe a good thing to embed babel async await loader by default

feature request

Most helpful comment

You can also use chainWebpack to replace the loader used for js:

module.exports = {
  chainWebpack: config => {
    const jsRule = config.module.rule('js')
    jsRule.uses.delete('buble-loader')
    jsRule.use('babel-loader').loader('babel-loader')
  }
}

Then install babel-core, babel-loader etc. and configure it as usual.

All 9 comments

VuePress used Buble whose support for Async/Await is still in code review: https://github.com/Rich-Harris/buble/pull/125.

ok, i changed buble to babel into my fork. Hope coming soon :)

You can also use chainWebpack to replace the loader used for js:

module.exports = {
  chainWebpack: config => {
    const jsRule = config.module.rule('js')
    jsRule.uses.delete('buble-loader')
    jsRule.use('babel-loader').loader('babel-loader')
  }
}

Then install babel-core, babel-loader etc. and configure it as usual.

done! hope buble implements async await soon :)

@yyx990803 Just curious, is there any particular reason that we use buble? It seems to lack a lot of essential features, e.g. proper polyfills, async/await... etc.

@ycmjason Because it's a lighter and faster default and produces a smaller bundle.

@yyx990803 In an exchange of less-complete functionality :disappointed:

Cool, always trying different stuffs, waiting..

Supported by #336 and merged as 82cd8bdbae6400032d79332302f06c7d196b58f2

Was this page helpful?
0 / 5 - 0 ratings