diff --git a/lib/index.js b/lib/index.js index c078ab00..eff358c4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,6 +18,13 @@ 'use strict'; +console.log("outerRealmConstructor: " + typeof outerRealmConstructor); +if (typeof outerRealmConstructor !== 'undefined') { + var realmConstructor = outerRealmConstructor; + module.exports = realmConstructor; +} + +if (typeof outerRealmConstructor === 'undefined') { const require_method = require; // Prevent React Native packager from seeing modules required with this @@ -57,6 +64,9 @@ function getContext() { return 'chromedebugger'; } + // react-native-desktop expects "nodejs" env + return 'nodejs'; + // Otherwise, we must be in a "normal" react native situation. // In that case, the Realm type should have been injected by the native code. // If it hasn't, the user likely forgot to run link. @@ -120,3 +130,4 @@ if (!realmConstructor) { require('./extensions')(realmConstructor); module.exports = realmConstructor; +}