Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] async / await for example #1337

Closed
VdustR opened this issue Dec 25, 2017 · 0 comments · Fixed by #1345
Closed

[Docs] async / await for example #1337

VdustR opened this issue Dec 25, 2017 · 0 comments · Fixed by #1345

Comments

@VdustR
Copy link
Member

VdustR commented Dec 25, 2017

Steps to reproduce

Write a method in any example format like this:

async onSelect (val) {
}

Which browser?

vue-material@vue-material@1.0.0-beta-7

Chrome 63.0.3239.108 (64bit) on Xubuntu

What is expected?

Transformed into onSelect: async function onSelect (val) {

What is actually happening?

It's transformed into async onSelect: function onSelect (val) { and throw error:

ERROR in ./build/loaders/component-example-loader.js!./docs/app/pages/Components/Autocomplete/examples/AutocompleteTemplate.vue
Module build failed: SyntaxError: Unexpected token, expected (61:15)
  59 |   window.alert('noop')
  60 | },
> 61 | async onSelect: function onSelect (val) {
     |               ^
  62 |   await this.$nextTick()
  63 |   this.value = val
  64 | }
    at createError$1 (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/parser-babylon.js:1:50)
    at parse (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/parser-babylon.js:1:793)
    at Object.parse (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/index.js:4220:12)
    at formatWithCursor (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/index.js:24819:22)
    at format (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/index.js:24859:10)
    at Object.format (/home/vipro/Documents/projects/maxwin/vue-material/node_modules/prettier/index.js:25098:12)
    at Object.module.exports (/home/vipro/Documents/projects/maxwin/vue-material/build/loaders/component-example-loader.js:88:23)
 @ ./docs/app/pages/Components/Autocomplete/Autocomplete.vue 39:18-123
 @ ./docs/app/pages lazy ^\.\/.*$
 @ ./docs/app/config.js
 @ ./docs/app/index.js
 @ multi ./docs/app/index.js ./build/local/client

Is it possible to replace vue-template-es2015-compiler with babel with same configuration as .babelrc?

I think it's might because async / await is es2017 not es2015 and Bublé(which vue-template-es2015-compiler dependent on) is an ES2015 compiler?

Til now, we could still write onSelect: async function onSelect (val) { in our documentation example.

marcosmoura pushed a commit that referenced this issue Dec 27, 2017
…1345)

* docs(componentExampleLoader): replace `vue-template-es2015-compiler` with `babel`

using babel to compile javascript in examples

fix #1337

* refactor(componentExampleLoader): replace `path.join` with `resolvePath`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant