首页 文章

热模块更换不适用于某些模块

提问于
浏览
1

我遇到了反应热装载机3的问题 .

我的应用程序中的一些模块得到热更新,有些则没有 . 我有一个文件夹(app),其中包含我的所有组件 . 在这个文件夹中我有index.js,我从文件夹中导出所有模块 . 在文件夹中我有 index.js 文件,它导出组件本身 . 例:

app/test 包含 test.jsindex.js app/test/index.js 包含 export test from ./test.js app/index.js 包含 export * as test from ./test

在我的应用程序的某个地方我导入这个测试应用程序像这样 import { test } from ../app

在这里魔术出现了 . hmr不适用于test.js.但是,如果我在 app/index.js 中评论行 export * as test from ./test ,我直接导入我的测试组件 import test from ../app/test/test.js hmr工作 . 我一直试图修复它3天了 . app/index.js 在我的 routes.js 文件中导入 . 它是唯一进口的地方 . 只有 app 文件夹中的所有组件才能运行 .

在控制台中,我看到了

[WDS] App updated. Recompiling...
log-apply-result.js?d762:11 [HMR] The following modules couldn't be hot updated: (They would     need a full reload!)
log-apply-result.js?d762:18 [HMR] Nothing hot updated.
only-dev-server.js?2f87:49 [HMR] App is up to date.
client?e36c:37 [WDS] App updated. Recompiling...
client?e36c:37 [WDS] Nothing changed.

1 回答

  • 0

    问题在于文件夹的结构 . 循环依赖关系失败了hmr . 修复它修复了问题 .

相关问题