JuniorTour / vue-template-babel-compiler

Enable Optional Chaining(?.), Nullish Coalescing(??) and many new ES syntax for Vue.js SFC based on Babel
https://www.npmjs.com/package/vue-template-babel-compiler
119 stars 9 forks source link

[Question] it can't work with unplugin-vue2-script-setup #22

Open moliyu opened 3 years ago

moliyu commented 3 years ago

image image image

JuniorTour commented 3 years ago

It is a bug.

This lib may have something wrong with unplugin-vue2-script-setup || vue-composition-api.

unplugin-vue2-script-setup && vue-composition-api works fine with this compiler.

See https://github.com/JuniorTour/vue-template-babel-compiler-VueUse-Example

I will look into it and fix it ASAP.

Thanks for your feedback.


If anyone has interest to fix this issue, you can:

  1. Try to reproduce this code snippet and error by setup DEMO Project.

  2. Follow CONTRIBUTING.md to make a contribution.

JuniorTour commented 3 years ago

Do you use VueCompositionAPI?

I found the unplugin-vue2-script-setup && vue-composition-api works fine with this compiler.

But if you forget to write Vue.use(VueCompositionAPI) , there will be the same undefined error as yours.

So try to add these to your main.ts:

// main.ts || .js
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)

145e0cc8ba9759f75f1c0461ecc59ca

If your issue is still not resolved. Just let me know.

moliyu commented 3 years ago

image it can not work for me. here is my package.json

{
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "dev": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "@vue/composition-api": "^1.3.3",
    "@vueuse/core": "^6.7.6",
    "vue": "^2.6.14"
  },
  "devDependencies": {
    "@vue/cli-plugin-typescript": "^4.5.13",
    "@vue/cli-service": "^4.5.13",
    "@vue/runtime-dom": "^3.2.21",
    "typescript": "^4.3.5",
    "unplugin-vue2-script-setup": "^0.6.13",
    "vue-template-babel-compiler": "^1.0.6-0",
    "vue-template-compiler": "^2.6.14"
  }
}
moliyu commented 3 years ago

@JuniorTour it works fine with latest @vue/composition-api

moliyu commented 3 years ago

thank you

JuniorTour commented 2 years ago

I also made an Example project for vue-template-babel-compiler && VueUse && unplugin-vue2-script-setup && vuejs/composition-api

See https://github.com/JuniorTour/vue-template-babel-compiler-VueUse-Example

92df1606f5d2a510acdb4b8d41742cb