Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Support/Enhancement for other Babel Plugins - Null Coalescing Operator, Optional Chaining and others #161

Open
Kaustix opened this issue Jan 4, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@Kaustix
Copy link

Kaustix commented Jan 4, 2022

Requesting an Enhancement or Support for adding the bellow babel plugin support for vue templates. I know there's a fork of this project that has included support for these https://github.com/pedro-gilmora/vite-vue2, however it would be better if these were added out the box as the fork seems to be behind and not being actively supported. Is this something that can be added to vue templates?

@babel/plugin-proposal-nullish-coalescing-operator
@babel/plugin-proposal-optional-chaining
@babel/plugin-transform-arrow-functions
@babel/plugin-transform-block-scoping
@babel/plugin-transform-destructuring
@babel/plugin-transform-parameters
@babel/plugin-transform-spread

@NikhilVerma
Copy link
Contributor

NikhilVerma commented Mar 17, 2022

Here is a solution if you are using a package manager which supports resolutions in package.json

{
  "resolutions": {
    "vue-template-es2015-compiler": "npm:[email protected]"
  }
}

@souljorje
Copy link

@NikhilVerma which bundlers do this?

@NikhilVerma
Copy link
Contributor

@souljorje Apologies I meant package manager. so

  1. Yarn
  2. pnpm
  3. npm with https://www.npmjs.com/package/npm-force-resolutions

@caocos
Copy link

caocos commented Apr 9, 2022

npm install vue-template-babel-compiler -D

createVuePlugin({
    //........
    vueTemplateOptions: {
      compiler: require('vue-template-babel-compiler'),
      compilerOptions: {
        whitespace: 'preserve'
      }
    }
  })

Optional chaining in templates does not seem to work

[vite] Internal server error: invalid expression: Unexpected token '.'

@NikhilVerma
Copy link
Contributor

I've made a PR to fix this issue - #179

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants