Rollupjs:函数在定义捆绑代码之前被调用?
Rollupjs: function is being called before definition bundled code?
当 运行 我的包时,我得到这个错误:
can't access property "call", Readable is undefined
所以我查看了捆绑代码,并在第 71481 行注意到了这一点:
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
在线 71463(正确使用前):
var Readable = _stream_readable;
但是在第 72148 行(所以此时 Readable$1 实际上是未定义的,这链接到上面的错误):
var _stream_readable = Readable;
/*<replacement>*/
如果我手动将此定义移动到 var Readable = _stream_readable;
之前,那么它就可以工作。我的问题是,如何解决汇总混淆订单的问题?
好的,这是汇总和可读流的已知问题,正如此处指出的:https://github.com/rollup/rollup/issues/4231 and documented in the various issues listed: https://github.com/rollup/rollup/issues/4231#issuecomment-937772340
我设法通过这种方式解决了问题:https://github.com/nodejs/readable-stream/issues/348#issuecomment-937971694,基本上:
npm i readable-stream@npm:vite-compatible-readable-stream
相关概念详述如下:https://github.com/nodejs/readable-stream/issues/348#issuecomment-473804926
当 运行 我的包时,我得到这个错误:
can't access property "call", Readable is undefined
所以我查看了捆绑代码,并在第 71481 行注意到了这一点:
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
在线 71463(正确使用前):
var Readable = _stream_readable;
但是在第 72148 行(所以此时 Readable$1 实际上是未定义的,这链接到上面的错误):
var _stream_readable = Readable;
/*<replacement>*/
如果我手动将此定义移动到 var Readable = _stream_readable;
之前,那么它就可以工作。我的问题是,如何解决汇总混淆订单的问题?
好的,这是汇总和可读流的已知问题,正如此处指出的:https://github.com/rollup/rollup/issues/4231 and documented in the various issues listed: https://github.com/rollup/rollup/issues/4231#issuecomment-937772340
我设法通过这种方式解决了问题:https://github.com/nodejs/readable-stream/issues/348#issuecomment-937971694,基本上:
npm i readable-stream@npm:vite-compatible-readable-stream
相关概念详述如下:https://github.com/nodejs/readable-stream/issues/348#issuecomment-473804926