Avoid clearing out factory on DEV mode

Summary:
grabbou pointed out this issue.

We recently started cleaning out the factory function after module are required to save some memory. This broke HMR on some edge cases because sometimes the factory function may need to be re-executed. This PR just wraps the optimization into `__DEV__` to make sure we don't use it while developing.
Closes https://github.com/facebook/react-native/pull/7568

Differential Revision: D3305120

Pulled By: martinbigio

fbshipit-source-id: 741cffbb327d118f0bd0ec34dc1af53d4f94880e
This commit is contained in:
Martín Bigio 2016-05-16 10:28:37 -07:00 коммит произвёл Facebook Github Bot 3
Родитель 3fe2e6581c
Коммит 6457effb7b
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -120,7 +120,11 @@ function loadModuleImplementation(moduleId, module) {
// keep args in sync with with defineModuleCode in
// packager/react-packager/src/Resolver/index.js
factory(global, require, moduleObject, exports);
// avoid removing factory in DEV mode as it breaks HMR
if (!__DEV__) {
module.factory = undefined;
}
if (__DEV__) {
Systrace.endEvent();