Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
我使用的框架是@umijs/max v4.0.89,打开了
fastRefresh
和mfsu
..umirc.ts
当npm包引用链混合了
cjs
与es
时,就会报错,提示__webpack_require__.$Refresh$
为空。例如,在代码中引用了
foo
三方库,foo中使用require('bar')
引用了bar,而bar是个es模块,再import
模块就会报错。简单一些,app.tsx -> import 'foo' -> require('bar') -> import 'baz' -> 💥
出错原因主要还是没有判断
__webpack_require__.$Refresh$
是否为空,所以我开了一个PR,改动也很简单,就是在开头和末尾的注入代码,包了一层为空判断。我对webpack不是很精通,反正这么修改在我的项目里不报错了,请审核一下是否需要merge进来吧