title: How to use Emscripten compiled JavaScript within React / React Native
body: <p>I'm currently using Emscripten to compile a basic C function into JavaScript to use within a React Native project. However, when I import <code>Module</code> from inside React code, the Module object is empty. This occurs in both React and React Native projects.</p>
  
  <p><strong>Running <code>index.js</code> in my terminal with <code>node ./index.js</code> returns the expected result.</strong></p>
  
  <p>I'm compiling ping.c and outputting ping.js with this command:</p>
  
  <p><code>emcc ping.c -o ping.js -s WASM=0 -s EXPORTED_FUNCTIONS='["_pingIt"]'</code></p>
  
  <p><strong>ping.c:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;emscripten.h&gt;
  
  EMSCRIPTEN_KEEPALIVE
  int pingIt() {
    return 1;
  }
  </code></pre>
  
  <p><strong>index.js:</strong></p>
  
  <pre><code>let Module = require('./ping.js');
  
  module.exports = Module;
  </code></pre>
  
  <p>I'm exporting Module from <code>index.js</code> and importing it into my React code.</p>
  
  <h1>Current behavior</h1>
  
  <pre><code>// Running in React
  console.log(Module); // returns {}
  </code></pre>
  
  <h1>Expected behavior</h1>
  
  <pre><code>// Running in React
  console.log(Module._pingIt()); // should return 1
  </code></pre>