vue-property-decorator icon indicating copy to clipboard operation
vue-property-decorator copied to clipboard

Babel 7 support?

Open lbssousa opened this issue 7 years ago • 8 comments

It's known that vue-property-decorator's @Prop decorators don't work with Babel 6. Is there any chance this scenario changes with upcoming Babel 7 decorators implementation?

lbssousa avatar Jun 05 '17 17:06 lbssousa

It would be nice if it is)

krasevych avatar Jul 06 '17 12:07 krasevych

is this repo dead? If not, please please please respond .

I don't know why vue doesn't take over this library which is supposed to be provided by vue itself.

chaoyangnz avatar Aug 15 '18 08:08 chaoyangnz

support use

    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/plugin-proposal-decorators": "^7.1.0",

cybermerlin avatar Sep 21 '18 15:09 cybermerlin

Has anyone found a work-around for this yet?

I'm using babel 7 I've got the following in my .babelrc:

["@babel/plugin-proposal-decorators", { "legacy": true}],
["@babel/plugin-proposal-class-properties", { "loose": true}],

I'm using @Prop like so:

@Prop({required: true}) item!: IHyperlinked;

Babel seems happy transpiling this, but throws runtime errors that seem to imply that the value is never set, so presumably vue isn't being told it's a prop.

mavarok avatar Apr 18 '19 07:04 mavarok

Seems like the issue mentioned by the OP is still there. For instance, initialising data with props doesn't work when transpiled by babel. It does work with ts-loader though.

import { Component, Prop, Vue } from 'vue-property-decorator';

@Component
export default class HelloWorld extends Vue {
  @Prop()
  msg;

  msgData = this.msg + '_data';
}

SecretPocketCat avatar Jun 13 '19 08:06 SecretPocketCat

@SecretPocketCat, @mavarok, just check versions of npm packages:

    "@babel/core": "=7.4.5",
    "@babel/generator": "=7.4.4",
    "@babel/plugin-proposal-class-properties": "=7.4.4",
    "@babel/plugin-proposal-decorators": "=7.4.4",
    "@babel/plugin-proposal-object-rest-spread": "=7.4.4",
    "@babel/plugin-syntax-dynamic-import": "=7.2.0",
    "@babel/plugin-transform-async-to-generator": "=7.4.4",
    "@babel/plugin-transform-block-scoping": "=7.4.4",
    "@babel/plugin-transform-exponentiation-operator": "=7.2.0",
    "@babel/plugin-transform-modules-commonjs": "=7.4.4",
    "@babel/plugin-transform-parameters": "=7.4.4",
    "@babel/plugin-transform-runtime": "=7.4.4",
    "@babel/preset-env": "=7.4.5",
    "@vue/cli": "^3.8.4",
    "@vue/cli-plugin-babel": "=3.8.0",
    "@vue/cli-plugin-e2e-nightwatch": "=3.8.0",
    "@vue/cli-plugin-eslint": "=3.8.0",
    "@vue/cli-plugin-pwa": "=3.8.0",
    "@vue/cli-plugin-unit-mocha": "=3.8.0",
    "@vue/cli-service": "=3.8.4",
    "@vue/test-utils": "^1.0.0-beta.29",
    "autoprefixer": "=9.5.1",
    "babel-eslint": "^10.0.1",
    "babel-loader": "=8.0.6",
    "babel-plugin-istanbul": "^5.1.4",
    "babel-plugin-root-import": "=6.2.0",
    "babel-plugin-syntax-async-functions": "=6.13.0",
    "babel-plugin-syntax-trailing-function-commas": "=6.22.0",
    "babel-plugin-transform-es2015-constants": "=6.1.4",
    "babel-plugin-transform-inline-environment-variables": "=0.4.3",
..
    "vue-loader": "=15.7.0",
    "vue-template-compiler": "=2.6.10"

btw, for big sources mb need modify ur shell command to: "serve": "cross-env NODE_OPTIONS=--max_old_space_size=8192 vue-cli-service serve --open "

if u've sometimes exception about not exist template render function, then remove node_modules n rerun npm i -f

cybermerlin avatar Jun 25 '19 13:06 cybermerlin

@mavarok you can find a working example at vue-webpack-typescript it uses babel loader. Here's the prop

Any more work on this one, can we close this issue @lbssousa ?

akoidan avatar Nov 16 '19 19:11 akoidan

Any update on this?

Mikilll94 avatar Aug 10 '20 14:08 Mikilll94