<blockquote>
<p dir="auto">Issue originally made by Daniel Rossi (danielr)</p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> 6.7.7</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="browserify / babelify config

{
    options: {
        &quot;transform&quot;: [[&quot;babelify&quot;, {

            &quot;presets&quot;: [&quot;es2015&quot;],

            &quot;plugins&quot;: [&quot;external-helpers&quot;],
            //&quot;plugins&quot;: [[ &quot;transform-runtime&quot;, { &quot;polyfill&quot;: false }]],

            sourceMap: false
        }]]
    },
    dist: {
        files: {

            'build/&lt;%= package.name %&gt;.js': ['src/&lt;%= package.name %&gt;.js']

        }
    }
}

//grunt-babel config this doesnt generate and bundle correctly just the main app source, no imports are included

{
    options: {
        sourceMap: false,
        presets: ['es2015'],
        &quot;plugins&quot;: [&quot;external-helpers&quot;]
        //&quot;plugins&quot;: [[ &quot;transform-runtime&quot;, { &quot;polyfill&quot;: false }]],

    },
    dist: {
        files: {
            'build/&lt;%= package.name %&gt;.js': ['src/&lt;%= package.name %&gt;.js']
        }
    }
}"><pre class="notranslate"><code class="notranslate">browserify / babelify config

{
    options: {
        "transform": [["babelify", {

            "presets": ["es2015"],

            "plugins": ["external-helpers"],
            //"plugins": [[ "transform-runtime", { "polyfill": false }]],

            sourceMap: false
        }]]
    },
    dist: {
        files: {

            'build/&lt;%= package.name %&gt;.js': ['src/&lt;%= package.name %&gt;.js']

        }
    }
}

//grunt-babel config this doesnt generate and bundle correctly just the main app source, no imports are included

{
    options: {
        sourceMap: false,
        presets: ['es2015'],
        "plugins": ["external-helpers"]
        //"plugins": [[ "transform-runtime", { "polyfill": false }]],

    },
    dist: {
        files: {
            'build/&lt;%= package.name %&gt;.js': ['src/&lt;%= package.name %&gt;.js']
        }
    }
}
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">Hi there I believe I have run into possible bugs I'm not sure how to deal with. I've been unable to get any help at all.  Detailed info here</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/36869836/grunt-babel-setup-for-es6-with-external-helper" rel="nofollow">http://stackoverflow.com/questions/36869836/grunt-babel-setup-for-es6-with-external-helper</a></p>
<p dir="auto">I am trying to use either the transform-runtime or external-helpers plugin to reduce the bloat for the class generated code.  I am also trying to use Maps without included bloaty code.</p>
<p dir="auto">Using external-helpers it produces cleaner non duplicated class helper code however the actual source for the helpers is missing.</p>
<p dir="auto">There seems to possible be documentation missing but as per the link above the selected helpers needs to be generated to a file and concat in after the build correct ? It took a while to figure our why it wasn't being generated in and how to work around it ?</p>
<p dir="auto">external-helpers still seems to duplicate this for every class module</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Object.defineProperty(exports, &quot;__esModule&quot;, {
    value: true
});"><pre class="notranslate"><code class="notranslate">Object.defineProperty(exports, "__esModule", {
    value: true
});
</code></pre></div>
<p dir="auto">If I try to use transform-runtime it includes a massive amount of code not required or relevant to the sources. I believe it is the core-js polyfill code and it's including all of it not just whatever it needs. None of the flags to disable it work when used in conjunction with babelify.</p>
<p dir="auto">transform-runtime also doesn't reduce the class code duplicates like external-helpers does. They are all clearly duplicated.</p>
<p dir="auto">If I just use the external-helpers and try to import the map polyfill like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import _Map from &quot;babel-runtime/core-js/map&quot;;"><pre class="notranslate"><code class="notranslate">import _Map from "babel-runtime/core-js/map";
</code></pre></div>
<p dir="auto">It generates the same 50kb of polyfill code with extras specific to the map polyfill. That is 50kb just to use maps correct ?</p>
<p dir="auto">I can't also seem to just use grunt-babel I have to use grunt-browserify / babelify or it doesn't bundle the sources correctly just the main app.</p>
<p dir="auto">Hopefully this is explanatory enough and there may be an issue with this.</p>
<h2 dir="auto">Bug Report</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I would like to work on a fix!</li>
</ul>

<p dir="auto"><strong>Current behavior</strong><br>
In a switch case, when I use a <code class="notranslate">const</code> variable with the same name as the variable being switched on, the code isn't correctly transpiled to ES5.</p>
<ul dir="auto">
<li><a href="https://babeljs.io/repl#?browsers=ie%2011&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=G4QwTgBAZg9jEF5oFcB2BjALgSxqgFAKYCUEA3gFAQQDOA7tpugBZGmXXXog2EQCMALiqcueGpgh8kAVgDcI0QCMwhEAGsF1AL4VtQA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Cenv&amp;prettier=false&amp;targets=&amp;version=7.11.6&amp;externalPlugins=" rel="nofollow">babeljs.io/repl</a></li>
</ul>
<p dir="auto"><strong>Input Code</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function foo(e) {
  switch(e) {
    case 1:
      const e = 5;
      break;
  }
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">switch</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-c1">1</span>:
      <span class="pl-k">const</span> <span class="pl-s1">e</span> <span class="pl-c1">=</span> <span class="pl-c1">5</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Output Code</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

function foo(e) {
  switch (_e) {
    case 1:
      var _e = 5;
      break;
  }
}"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-s1">_e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-c1">1</span>:
      <span class="pl-k">var</span> <span class="pl-s1">_e</span> <span class="pl-c1">=</span> <span class="pl-c1">5</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Expected behavior</strong><br>
The transpiled code doesn't switch on <code class="notranslate">_e</code>, but on <code class="notranslate">e</code>.</p>
<p dir="auto"><strong>Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)</strong></p>
<ul dir="auto">
<li>Filename: <code class="notranslate">babel.config.js</code></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
 &quot;presets&quot;: [
   [&quot;@babel/preset-env&quot;, {
     &quot;targets&quot;: {
       &quot;browsers&quot;: [
           &quot;ie &gt;= 11&quot;
       ]
     },
   }],
 ]
}
"><pre class="notranslate"><span class="pl-kos">{</span>
 <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span>
   <span class="pl-kos">[</span><span class="pl-s">"@babel/preset-env"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
     <span class="pl-s">"targets"</span>: <span class="pl-kos">{</span>
       <span class="pl-s">"browsers"</span>: <span class="pl-kos">[</span>
           <span class="pl-s">"ie &gt;= 11"</span>
       <span class="pl-kos">]</span>
     <span class="pl-kos">}</span><span class="pl-kos">,</span>
   <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
 <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="System:
    OS: Linux 4.15 Ubuntu 18.04.5 LTS (Bionic Beaver)
  Binaries:
    Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node
    npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm
  npmPackages:
    @babel/cli: 7.10.3 =&gt; 7.10.3 
    @babel/core: 7.10.3 =&gt; 7.10.3 
    @babel/preset-env: 7.10.3 =&gt; 7.10.3 "><pre class="notranslate"><code class="notranslate">System:
    OS: Linux 4.15 Ubuntu 18.04.5 LTS (Bionic Beaver)
  Binaries:
    Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node
    npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm
  npmPackages:
    @babel/cli: 7.10.3 =&gt; 7.10.3 
    @babel/core: 7.10.3 =&gt; 7.10.3 
    @babel/preset-env: 7.10.3 =&gt; 7.10.3 
</code></pre></div>
<p dir="auto"><strong>Possible Solution</strong><br>
Workaround: don't shadow the variable being switched on, in the switch case. This isn't really an option for us, as it's Terser that introduces the name conflict.</p>
<p dir="auto"><strong>Additional context</strong><br>
You probably wouldn't shadow the existing variable when manually writing code. As a library developer, we ship code that was minified using Terser. It mangles the names, which results in code as described in this issue (with the name conflicts). A library user that wants to target IE11, needs to transpile the ES6 modules down to ES5, and will run into the issue.</p>