Resolve a module conditionally in react-native
<p>I want to import ReactNativePropRegistry in my React Native package. </p>

<p>I used to import it from <code>'react/lib/ReactNativePropRegistry'</code> before React Native 0.38.0 but it has changed to <code>'react-native/Libraries/Renderer/src/renderers/native/ReactNativePropRegistry'</code> in React Native 0.38.0.</p>

<p>I want my package to be supported on all the React Native versions including 0.38.0 so I did this</p>

<pre><code>if(semver.gte(reactNativeVersion, '0.38.0-rc.0')) {
  const ReactNativePropRegistry = require('react-native/Libraries/Renderer/src/renderers/native/ReactNativePropRegistry');
} else {
  const ReactNativePropRegistry = require('react/lib/ReactNativePropRegistry');
}
</code></pre>

<p>But it seems that the packager tries to resolve the modules statically. So even if reactNativeVersion is less than 0.38.0-rc.0, it tries to resolve the module at this path <code>'react-native/Libraries/Renderer/src/renderers/native/ReactNativePropRegistry'</code> which causes it to throw an error <code>Unable to resolve module ...</code>.</p>

<p>Is there any way get around this?</p>