vite-plugin-vue2
vite-plugin-vue2 copied to clipboard
Support/Enhancement for other Babel Plugins - Null Coalescing Operator, Optional Chaining and others
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
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]"
}
}
@NikhilVerma which bundlers do this?
@souljorje Apologies I meant package manager. so
- Yarn
- pnpm
- npm with https://www.npmjs.com/package/npm-force-resolutions
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 '.'
I've made a PR to fix this issue - https://github.com/underfin/vite-plugin-vue2/pull/179