Open LYSSION opened 2 years ago
感谢你的反馈,似乎确实是个 bug,
如果你有兴趣排查,定位问题,并发个MR 修复的话,可以参考这个文档:https://github.com/JuniorTour/vue-template-babel-compiler/blob/main/CONTRIBUTING.md
有任何疑问可以随时联系我😁
The root cause is vue-template-compiler
use new Function(("return " + exp))
to detect if js expression is valid.
eg: "_s(null ?? 'Nullish Coalescing enabled')
will be convert to new Function
and throw an error in Node.js V12
SyntaxError: Unexpected token '?'
at new Function (<anonymous>)
at checkExpression (build.js:4550)
at checkNode (build.js:4508)
at checkNode (build.js:4504)
at checkNode (build.js:4504)
at detectErrors (build.js:4479)
at Object.compile (build.js:4808)
at compileTemplate (index.js:160)
at actuallyCompile (compileTemplate.js:72)
at compileTemplate (compileTemplate.js:33)
at Object.module.exports (templateLoader.js:46)
at LOADER_EXECUTION (LoaderRunner.js:119)
at runSyncOrAsync (LoaderRunner.js:120)
at iterateNormalLoaders (LoaderRunner.js:232)
at iterateNormalLoaders (LoaderRunner.js:221)
at LoaderRunner.js:236
But actually this code snippet of code will work after this compiler.
So maybe we can disable this expression check?
Current behavior
https://github.com/LYSSION/vue-demo
环境:nodejs12.22.1
复现步骤 1.拉取仓库代码 2.npm run serve 3.向app.vue中添加输出:{{info.aaa ?? 'empty'}}
4.输出错误