title: JS wont access const between scripts
body: <p>It seems very simple but it wont work. I just want to access auth variable between index.js and auth.js but it keeps giving me error that auth is not defined in auth.js. I thought if i put the script for index.js above auth.js i would be able to use its variables in auth.js. It should be known that this all works correctly when placed in same file.</p>
  <p>index.html :</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
  
  &lt;meta charset=&quot;UTF-8&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, intial-scale=1.0&quot;/&gt;
  &lt;title&gt;yuh&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  yo
  
  
  &lt;form id=&quot;signup-form&quot;&gt;
    &lt;input type=&quot;email&quot; id=&quot;signup-email&quot;/&gt;
    &lt;input type=&quot;password&quot; id=&quot;signup-password&quot;/&gt;  
  &lt;button&gt;Submit&lt;/button&gt;
  
  &lt;/form&gt;
  
  &lt;script type=&quot;module&quot; src=&quot;index.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;module&quot; src=&quot;auth.js&quot;&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>
  <p>index.js:</p>
  <pre><code>import { getAuth, createUserWithEmailAndPassword  } from &quot;https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js&quot;;
  import { getFirestore} from &quot;https://www.gstatic.com/firebasejs/9.8.1/firebase-firestore.js&quot;;
  
  const firebaseConfig = {
      apiKey: &quot;Afirebase crapYw&quot;,
      authDomain: &quot;firebase crap&quot;,
      databaseURL: &quot;https://firebase crap.firebaseio.com&quot;,
      projectId: &quot;firebase crap&quot;,
      storageBucket: &quot;firebase crap.appspot.com&quot;
     
    };
  
    const app = initializeApp(firebaseConfig); 
    const auth = getAuth(app);
    const db = getFirestore(app);
  </code></pre>
  <p>auth.js:</p>
  <pre><code>signupForm.addEventListener('submit', (e) =&gt; {
  e.preventDefault();
  
  const email = signupForm['signup-email'].value;
  const password = signupForm['signup-password'].value;
  
  console.log(email, password);
  auth.createUserWithEmailAndPassword(email, password).then((cred) =&gt; {
  
    const user = cred.user;
  }).catch((error) =&gt; {
    const errorCode = error.code;
    const errorMessage = error.errorMessage;
  });
  
  
  
  });
  </code></pre>