vuejs / vue-template-es2015-compiler

Support a subset of handy ES2015 features in Vue 2.0 templates.
61 stars 23 forks source link

Support arrow functions and destructuring #1

Closed kudos closed 8 years ago

kudos commented 8 years ago

I knocked my head against a wall for a while until I realised that maybe Babel wasn't involved in the template's embedded JS. I'm not sure whether there are any good arguments against adding these two?

yyx990803 commented 8 years ago

I wanted to be conservative since some ES2015 features can potentially transpile into code that breaks Vue's codegen. Could you list your use case where you are using these in templates?

kudos commented 8 years ago

I'm only using arrow functions in my templates right now (just started using Vue a week ago), I've since reverted this to use a plain function: https://gitlab.com/kudos/match.audio/blob/master/public/src/views/index.vue#L16

Destructuring seemed safe enough to me versus some of the other optional transforms, but I'm not using it in my templates yet.

kudos commented 8 years ago

@yyx990803 happy to remove destructuring from this if it makes it an easier decision.

yyx990803 commented 8 years ago

Released 1.1.0, but unfortunately it did cause errors - somehow Webpack incorrectly thinks the compiled code is an ES module and enforces strict mode when arrow function is compiled in some cases. Had to revert it in 1.1.1.