[英]'createConsumer' is not exported by node_modules/@rails/actioncable/app/assets/javascripts/action_cable.js
I'm trying to import createConsumer
from actioncable in the following script.我正在尝试从以下脚本中的 actioncable 导入createConsumer
。 https://github.com/jonathan-s/sockpuppet/blob/stimulus/javascript/stimulus/consumer.js#L1 https://github.com/jonathan-s/sockpuppet/blob/stimulus/javascript/stimulus/consumer.js#L1
When I try to build it with rollup.js it all fails with the following error.当我尝试使用 rollup.js 构建它时,它都失败并出现以下错误。
[!] Error: 'createConsumer' is not exported by
node_modules/@rails/actioncable/app/assets/javascripts/action_cable.js,
imported by javascript/stimulus/consumer.js
When I take a look at node_modules, it does look like action_cable.js
is exporting createConsumer
so I'm unsure of what is going wrong here.当我查看 node_modules 时,看起来action_cable.js
正在导出createConsumer
,所以我不确定这里出了什么问题。
What made the error go away was to use commonjs with named exports.导致错误 go 消失的原因是使用带有命名导出的 commonjs。
plugins: [
commonjs({
namedExports: {
"node_modules/@rails/actioncable/app/assets/javascripts/action_cable.js": ["createConsumer"]
}
}),
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.