Issue 1:
Issue originally made by Daniel Rossi (danielr)

Bug information

Babel version: 6.7.7

Options

browserify / babelify config

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

"presets": ["es2015"],

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

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

'build/<%= package.name %>.js': ['src/<%= package.name %>.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/<%= package.name %>.js': ['src/<%= package.name %>.js']
}
}
}

Input code

Description

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

http://stackoverflow.com/questions/36869836/grunt-babel-setup-for-es6-with-external-helper

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.

Using external-helpers it produces cleaner non duplicated class helper code however the actual source for the helpers is missing.

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 ?

external-helpers still seems to duplicate this for every class module

Object.defineProperty(exports, "__esModule", {
value: true
});

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.

transform-runtime also doesn't reduce the class code duplicates like external-helpers does. They are all clearly duplicated.

If I just use the external-helpers and try to import the map polyfill like

import _Map from "babel-runtime/core-js/map";

It generates the same 50kb of polyfill code with extras specific to the map polyfill. That is 50kb just to use maps correct ?

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.

Hopefully this is explanatory enough and there may be an issue with this.

Issue 2:
Bug Report

I would like to work on a fix!

Current behavior

In a switch case, when I use a const variable with the same name as the variable being switched on, the code isn't correctly transpiled to ES5.

babeljs.io/repl

Input Code

function foo(e) {
switch(e) {
case 1:
const e = 5;
break;
}
}

Output Code

"use strict";

function foo(e) {
switch (_e) {
case 1:
var _e = 5;
break;
}
}

Expected behavior

The transpiled code doesn't switch on _e, but on e.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

Filename: babel.config.js

{
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": [
"ie >= 11"
]
},
}],
]
}

Environment

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 => 7.10.3
@babel/core: 7.10.3 => 7.10.3
@babel/preset-env: 7.10.3 => 7.10.3

Possible Solution

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.

Additional context

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.