vue-template-babel-compiler icon indicating copy to clipboard operation
vue-template-babel-compiler copied to clipboard

[Fixed Bug] Unexpected token for optional?.chaining

Open jwtong opened this issue 4 years ago • 15 comments

invalid expression: Unexpected token '.' in

optional?.chaining

v1.0.0

jwtong avatar Aug 06 '21 20:08 jwtong

@jwtong Thank yor for your feedback

Could you provide more context? So that we can help you ASAP.

For example:

  1. Your usage, Vue-cli, Nuxt.js, Webpack etc.
  2. Your steps or code snippets whiclh got the error above.
  3. A minimal reproduction project is prefer, eg: vue-template-babel-compiler-nuxt-project

JuniorTour avatar Aug 07 '21 15:08 JuniorTour

@JuniorTour This was from the Nuxt demo project actually (vue-template-babel-compiler-nuxt-project), and is consistent with my other project I am trying to set this up for. "nuxt": "^2.15.7", "vue-template-babel-compiler": "^1.0.0"

jwtong avatar Aug 09 '21 21:08 jwtong

@jwtong Sorry for late reply.

Is your problem solved?

I just test Nuxt.js DEMO project again.

It will throw the same error when not config nuxt.config.js: ZI$4NLF%)_DDOT0SST13FVV

So the solution could be add build.loaders.vue to your nuxt.config.js:

// nuxt.config.js
export default {
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    loaders: {
      vue: {
        compiler: require('vue-template-babel-compiler')
      }
    },
  },
  // ...
}

If the problem still not be solved, feel free to ask my again.

JuniorTour avatar Aug 29 '21 04:08 JuniorTour

@JuniorTour Yes, so it now works with that config, just from upgrading to 1.0.2. There is now just a SSR issue, I know someone else opened a PR for that as well.

https://github.com/JuniorTour/vue-template-babel-compiler/issues/7

jwtong avatar Sep 01 '21 19:09 jwtong

@jwtong Thank you for your help!

It is a bug indeed, I just published 1.0.3 to fix it.

You can try it by:

npm install [email protected] -D
// or yarn
yarn add [email protected] -D

Now this compiler will work for SSR too!

8b40e54c646984a92edb58ac2fcf7b4

I also update vue-template-babel-compiler-nuxt-project

Thank you for your feedback again!

JuniorTour avatar Sep 03 '21 15:09 JuniorTour

Doesnt work with latest nuxt project

flozero avatar Nov 19 '21 04:11 flozero

Doesnt work with latest nuxt project

@f3ltron Thanks for your feedback.

I just test by this demo-nuxt-project with "nuxt": "^2.15.8" and "vue-template-babel-compiler": "^1.0.6-0".

It works fine.

How do you use this lib?

Could you provide more details? For example:

  • Your nuxt.config.js
  • Error message you got

I'd be glad to help you use this lib.

JuniorTour avatar Nov 19 '21 08:11 JuniorTour

Hi, Having error with demo-nuxt-project. I cloned the demo repo and started the project. then got the following error:

It is working while building but it doesn't work with npm run dev Using node v12.22.4 Nuxt v2.15.7 image

zavaremre avatar Feb 01 '22 13:02 zavaremre

Hi, Having error with demo-nuxt-project. I cloned the demo repo and started the project. then got the following error:

It is working while building but it doesn't work with npm run dev Using node v12.22.4 Nuxt v2.15.7

Currently, The nullish coealasing (??) only work for node.js v14+.

So a temp workaround is:

  • upgrade node.js to great than 14.
  • delete ?? usage

I'm still look into can we use it below v14, welcome for working toghther.

Thanks for your feedback.

Related:

  • https://github.com/JuniorTour/vue-template-babel-compiler/issues/29

JuniorTour avatar Feb 01 '22 13:02 JuniorTour

npm Installed to vue 2 webpack project, added "compiler: require('vue-template-babel-compiler'),"

But code still crash on .?
Anybody who got this working ? Are there some additional installation settings needed ?

Songoo7 avatar Oct 10 '22 14:10 Songoo7

npm Installed to vue 2 webpack project, added "compiler: require('vue-template-babel-compiler'),"

But code still crash on .?
Anybody who got this working ? Are there some additional installation settings needed ?

@Songoo7

What is your Nodejs version? Currently this lib need nodejs v14 aboce.

Could your provide a reproduction repo or online demo?

It would be my pleasure to help you.

JuniorTour avatar Oct 10 '22 15:10 JuniorTour

npm Installed to vue 2 webpack project, added "compiler: require('vue-template-babel-compiler')," But code still crash on .? Anybody who got this working ? Are there some additional installation settings needed ?

@Songoo7

What is your Nodejs version? Currently this lib need nodejs v14 aboce.

Could your provide a reproduction repo or online demo?

It would be my pleasure to help you.

Hello , I have node v16.15, webpack 3, babel 6, vue 2.4.4 . (tried to update to webpack 4 and babel 7, but was really not able to :) ) https://i.imgur.com/8Z6GBzi.png . Not sure how to do demo hmm, maybe copy package.json and then npm install and do some blank project uh oh ?

Songoo7 avatar Oct 10 '22 16:10 Songoo7

@Songoo7 What is the version of vue-loader you are using?

If version is smaller than v15.0.0, the compiler option is not valid. It only valid for vue-loader >= v15.0.0.

vue-loader v14 does NOT have this option to use vue-template-babel-compiler.

JuniorTour avatar Oct 11 '22 03:10 JuniorTour

"vue-loader": "^13.0.5", so I should raise to 15 ? I'll try if it let me.

Songoo7 avatar Oct 11 '22 11:10 Songoo7

I got to vue-loader 14.0.0. But sadly going to 15 is impossible for me :( tried to follow https://vue-loader.vuejs.org/migrating.html#notable-breaking-changes and https://vue-loader.vuejs.org/guide/#vue-cli . But those guides are not enough detailed for this. Added new loader, added new less sass configs installed less-loader, sass-loader but in the end got an hundreds and hundreds red errors :) .

Songoo7 avatar Oct 11 '22 12:10 Songoo7