为什么我的无效的科拉斯式操作员没有被汇总插件转移给Babel?
我有一个Svelte项目,我想使用Rollup Plugin @lollup/plumin/plugin-babel
将无效的无效操作员(ES2020)转换为ES5,它是默认情况下启用了@babel/preset-env-env
,因为babel v7.6.3 。
但是,在我的项目中,它行不通。我在这样的组件中的脚本标签中有一个无效的coalascing操作员:
<script>
let count = 0;
let aCool;
let canio;
const increment = () => {
if (count % 6 === 0) {
canio = 1;
}
count += 1;
aCool = canio ?? 0;
};
console.log('aCool', aCool);
</script>
可以找到一个最小的svelte项目在这里。
Babel似乎正在运行并添加来自Core-Js的多填充物,但它与??
运算符无关。为什么不移交?
I have a svelte project that I would like to transpile nullish-coalascing operators (es2020) to es5 using the rollup plugin @rollup/plugin-babel
which is enabled by default in @babel/preset-env
since babel v7.6.3.
However in my project it does not work. I have a nullish-coalascing operator in a script tag in a component like this:
<script>
let count = 0;
let aCool;
let canio;
const increment = () => {
if (count % 6 === 0) {
canio = 1;
}
count += 1;
aCool = canio ?? 0;
};
console.log('aCool', aCool);
</script>
A minimal svelte project can be found here.
Babel seems to run and add the polyfills from core-js but it does nothing with the ??
operator. Why is it not transpiled?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现它不起作用的原因是因为我忘了将
.svelte
作为文件扩展名,而Babel应该在 rollup插件因此,它甚至都不查看Svelte代码。谢谢@jlhwung!I found out the reason why it does not work is because I forgot to set
.svelte
as a file extension that Babel should transpile in the rollup plugin hence it doesn't even look at the svelte code. Thanks @JLHwung!!