【发布时间】:2017-06-22 00:07:27
【问题描述】:
我遇到了 react hot loader 3 的问题。
我的应用程序中的一些模块得到了热更新,而另一些则没有。我有一个文件夹(应用程序),其中包含我所有的组件。在这个文件夹中,我有 index.js,我从文件夹中导出所有模块。在文件夹中,我有 index.js 导出组件本身的文件。
示例:
app/test 包含 test.js 和 index.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.
【问题讨论】:
标签: reactjs webpack react-hot-loader hot-module-replacement