title: Rollup, multiple files, same constants name in multiple files: error in browser: Uncaught SyntaxError: Identifier 'o' has already been declared
body: <p>I have a problem.</p>
  
  <h3>EXPLANATION</h3>
  
  <p>In a website I navigate on page /one, the code in the <em>one.js</em> file executes fine.</p>
  
  <p>After a while I insert in the page (pjax, ajax: no matter how) the second code in <em>two.js</em> file.</p>
  
  <p>The browser complains with this error:</p>
  
  <pre><code>Uncaught SyntaxError: Identifier 'o' has already been declared
  - at two.js:1
  </code></pre>
  
  <h3>REPRODUCTION and SOURCE CODE</h3>
  
  <ol>
  <li><p><em>rollup.config.js</em>:</p>
  
  <pre class="lang-js prettyprint-override"><code>import resolve from 'rollup-plugin-node-resolve'
  import commonjs from 'rollup-plugin-commonjs'
  import { terser } from 'rollup-plugin-terser'
  import multiInput from 'rollup-plugin-multi-input'
  
  export default {
    input: ['src/**/*.js'],
    output: {
      format: 'esm',
      dir: 'dist/js'
    },
    plugins: [
      multiInput({ relative: 'src' }),
      resolve({ browser: true }),
      commonjs(),
      terser()
    ]
  }
  </code></pre></li>
  <li><p><em>src/one.js</em>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const names1 = ['john1', 'carl1', 'bob1']
  names1.forEach(name1 =&gt; {
    console.log('name1:', name1, ', in names1:', ...names1)
  })
  </code></pre></li>
  <li><p><em>src/two.js</em>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const names2 = ['john2', 'carl2', 'bob2']
  names2.forEach(name2 =&gt; {
    console.log('name2:', name2, ', in names2:', ...names2)
  })
  </code></pre></li>
  <li><p><em>dist/js/one.js</em>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const o=["john1","carl1","bob1"];o.forEach(n=&gt;{console.log("name1:",n,", in names1:",...o)});
  </code></pre></li>
  <li><p><em>dist/js/two.js</em>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const o=["john2","carl2","bob2"];o.forEach(n=&gt;{console.log("name2:",n,", in names2:",...o)});
  </code></pre></li>
  </ol>
  
  <h3>QUESTIONS</h3>
  
  <p>How to fix this problem?</p>
  
  <p>Can we "prefix" constants name based on file name?</p>
  
  <p>If of course I put everything in just <em>one.js</em> file it works but it's not possible because of the structure of the project.</p>