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
118 stars 9 forks source link

not working on node12 #41

Closed tworry closed 2 years ago

tworry commented 2 years ago

在反复切换node版本后确定,只在node14上生效 node12上还是会报错

invalid expression: Unexpected token '.' in

    name?.value !== 1
JuniorTour commented 2 years ago

是的,你说的没错。

我在MDN的文档上又确认了一遍,Node.js 对 optional chainig, nullish coalesing 语法的兼容性是从 V14 开始的:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility


根本原因是:https://github.com/JuniorTour/vue-template-babel-compiler/issues/29#issuecomment-1005424023


临时优化方案是:“修改 package.json 中的 engine 字段到 >=14.0.0”

https://github.com/JuniorTour/vue-template-babel-compiler/blob/95ed545f0322ee106293835e9e37f92a1d934092/package.json#L12

欢迎你随时发个 Pull Request 改一下 😋