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

时间:2017-02-04 18:53:26

标签: reactjs webpack react-hot-loader hot-module-replacement

我遇到了反应热装载机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.但是,如果我在export * as test from ./test中评论行app/index.js并且我直接导入我的测试组件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 :(得分:0)

问题在于文件夹的结构。循环依赖关系失败了hmr。解决它固定的问题。