title: How to execute IIFE script file in Node.js
body: <p>I have a very specific scenario.</p>
  
  <p>I have a javascript file called <code>ApplicationExtension.js</code> and inside, it has an <strong>IIFE</strong> structure as:</p>
  
  <pre><code>const ApplicationExtension = (function() {
      ...
      ...
      return {
          functionName : functionToExpose
      }
  })();
  </code></pre>
  
  <p>I have another file <code>script.js</code> and inside it, I want to access the <code>ApplicationExtension</code> so that I can execute <code>ApplicationExtension.functionName()</code></p>
  
  <p>I will be running <code>script.js</code> in a node environment and <code>ApplicationExtension.js</code> is being executed in a browser environment.</p>
  
  <p>I have tried,</p>
  
  <pre><code>const App = require('./js/extended/application_extension');
  console.log(App)
  </code></pre>
  
  <p>which as expected is an <code>{}</code> object since there is no <code>export</code> in <code>ApplicationExtension</code>.</p>
  
  <p><strong>Points to Note</strong></p>
  
  <ol>
  <li><code>ApplicationExtension.js</code> is currently being executed in browser and <code>script.js</code> is executed in 
   Node.js.</li>
  <li>I can't use <code>export</code> in <code>ApplicationExtension.js</code> as there are quite a lot of dependencies on it and it is practically impossible to change everything to <strong>module</strong> based project because of legacy reasons.</li>
  </ol>