我想把我的反应项目转换成一个电子应用程序。由于该项目是通过webpack捆绑,我开始使用电子webpack的建设。运行electron-webpack dev时,/main和/renderer都不会正确编译。
控制台日志抛出解码器插件错误
The decorators plugin requires a 'decoratorsBeforeExport' option,
whose value must be a boolean. If you want to use the
legacy decorators semantics, you can set the 'legacy: true' option所以,为什么不遵循这个明智的建议呢?然后,我更新了我的所有依赖项,并更新了我的.babelrc文件,以添加.babelrc和遗留选项(分别为false和true )。
"plugins": [
["@babel/plugin-proposal-decorators", {
"decoratorsBeforeExport": false,
"legacy": true,
}],由于在此之后仍然显示错误,我从_/node_打开plugin-proposal-decorators文件夹,并为选项添加了一个日志。显然,它没有识别我的选项集。我直接尝试从webpack的装载机配置,但问题仍然显示。
我的env
发布于 2019-07-09 11:11:31
这个.babelrc适用于我:
{
"presets": [
"@babel/preset-react",
[ "@babel/preset-env", {
"targets": {
"browsers": [ "last 1 version" ]
}
} ]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }]
]
}请注意decorators插件是如何先于class-properties的。
不知怎么的,它在非legacy模式下对我不起作用。根据官方文档:loose:decorators在legacy模式下运行时需要legacy选项
它还指出:
在Babel 7中,变换-装饰师.遗产将是第0阶段的默认插件。(资料来源:https://babeljs.io/docs/en/babel-plugin-transform-decorators.html)
https://stackoverflow.com/questions/54393089
复制相似问题