Don't assume the SourceCode native module exists
Reviewed By: yungsters Differential Revision: D7185837 fbshipit-source-id: e8efc22ac0af092dbc1fdf616b0b3f111390dd5d
This commit is contained in:
parent
596bcb6d84
commit
8cdc7d3e02
|
@ -25,7 +25,7 @@ type DevServerInfo = {
|
|||
*/
|
||||
function getDevServer(): DevServerInfo {
|
||||
if (_cachedDevServerURL === undefined) {
|
||||
const match = SourceCode.scriptURL && SourceCode.scriptURL.match(/^https?:\/\/.*?\//);
|
||||
const match = SourceCode && SourceCode.scriptURL && SourceCode.scriptURL.match(/^https?:\/\/.*?\//);
|
||||
_cachedDevServerURL = match ? match[0] : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ if (!sourceCode) {
|
|||
const NativeModules = require('NativeModules');
|
||||
sourceCode = NativeModules && NativeModules.SourceCode;
|
||||
}
|
||||
_sourceCodeScriptURL = sourceCode.scriptURL;
|
||||
_sourceCodeScriptURL = sourceCode && sourceCode.scriptURL;
|
||||
|
||||
module.exports = resolveAssetSource;
|
||||
module.exports.pickScale = AssetSourceResolver.pickScale;
|
||||
|
|
Loading…
Reference in New Issue