title: Singleton ES6 Module being called multiple times?
body: <p>I am not sure why the module here which has a console.log is being called multiple times.  I thought this was a <strong>singleton</strong>.</p>
  <p>So if I'm importing this module into other modules, since this is a singleton I did not expect the console.log to be called every time...only the first time it's imported by a module but after that I thought that, even when imported by subsequent modules, since it's a singleton, then I shouldn't see a ton of these being logged:</p>
  <p>src/graphql/db/InMemory/<strong>InMemoryDB.ts</strong></p>
  <pre><code>console.log('inMemoryDB');
  const inMemoryDb = newDb();
  inMemoryDb.public.none(fs.readFileSync('001-initial.sql', 'utf8'));
  export default inMemoryDb;
  </code></pre>
  <p>what I'm seeing when I run initially run tests <strong>or</strong> initially start my service which uses this singleton, are 6-7 <code>inMemoryDB</code> being logged.  Even after I changed it to this, same deal:</p>
  <pre><code>const inMemoryDb = () =&gt; {
    console.log('inMemoryDB');
    return newDb();
  }
  inMemoryDb.public.none(fs.readFileSync('001-initial.sql', 'utf8'));
  export default inMemoryDb();
  </code></pre>
  <p>So for example when I start my graphql service, I get like 6-7 of those console.logs when I run <code>yarn graphql-dev</code></p>
  <pre><code>&quot;graphql-dev&quot;: &quot;yarn compile-graphql &amp;&amp; yarn start-graphql-dev&quot;,
  &quot;compile-graphql&quot;: &quot;tsc -b ./src/graphql&quot;,
  &quot;start-graphql-dev&quot;: &quot;node --optimize_for_size --trace-warnings --es-module-specifier-resolution=node --no-warnings dist/graphql/server.js&quot;
  </code></pre>
  <p>deep down in my graphql code, it uses that in-memory DB singleton like this (based on the <strong>first</strong> implementation above):</p>
  <pre><code>const inMemoryPgDb = inMemoryDb;
  </code></pre>