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 committed by Facebook Github Bot 3
parent c6d52e7a89
commit 56c3a581b0
1 changed files with 5 additions and 1 deletions

View File

@ -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);
module.factory = undefined;
// avoid removing factory in DEV mode as it breaks HMR
if (!__DEV__) {
module.factory = undefined;
}
if (__DEV__) {
Systrace.endEvent();