Issue 1:
I have a function that takes a complicated options object as its only argument.

Also, I am using object destructuring with default values to set default values, which are actually callbacks with similar signatures.

The parameters of the callbacks should be independent of each other. However, babel 6.26.0 is still giving a "Duplicate declaration" error.

Input Code

export function createConnectionType({
resolveTotalCount = ({ first, ...searchContext }) => {},
resolveEdges = ({ first, ...searchContext }) => {},
}) {}

REPL: http://bit.ly/2CVCWuB

Babel/Babylon Configuration (.babelrc, package.json, cli command)

# .babelrc
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}],
"stage-3"
]
}

# Versions
$ node_modules/.bin/babel --version
6.26.0 (babel-core 6.26.0)

Expected Behavior

It should compile to something like:

export function createConnectionType({
resolveTotalCount,
resolveEdges,
}) {
if(!resolveTotalCount) resolveTotalCount = (_ref) => {const {first} = _ref; const searchContext = _objectWithoutProperties(_ref)};
if(!resolveEdges) resolveEdges = (_ref) => {const {first} = _ref; const searchContext = _objectWithoutProperties(_ref)};
}

Current Behavior

When babel-preset-env is enabled, it gives compile error

repl: Duplicate declaration "searchContext"
1 | export function createConnectionType({
2 | resolveTotalCount = ({ first, ...searchContext }) => {},
> 3 | resolveEdges = ({ first, ...searchContext }) => {},
| ^
4 | }) {}

When babel-preset-env is disabled, it gives:

/* (_objectWithoutProperties omitted) */
export function createConnectionType(_ref) {
let {
resolveTotalCount = ({ first }) => {},
resolveEdges = ({ first }) => {}
} = _ref,
searchContext = _objectWithoutProperties(_ref.resolveTotalCount, ["first"]),
searchContext = _objectWithoutProperties(_ref.resolveEdges, ["first"]);
}

Note that searchContext in the two default values are totally messed up.

Seems that there are something wrong with object rest destructuring on function arguments.

Context

This is the full code:

https://github.com/cofacts/rumors-api/tree/914b16ea0bc9274f7b16c6a09669f3a2627fe030/src/graphql/util.js#L146-L181

The repository was using Babel-core 6.18 and it successfully compiles.

Your Environment

software
version(s)

Babel
6.26.0

node
8.9.1

npm
5.5.1

Operating System
Mac OSX 10.11

Issue 2:
Issue originally made by @branneman

Bug information

Babel version: 6

Node version: any

npm version: any

Input code

My .babelrc:

{
"presets": ["es2015", "stage-3"],
"plugins": [
"external-helpers-2",
"transform-es2015-modules-amd",
"transform-class-properties"
]
}

Description

During my search for generating and serving as few bytes as possible in the name of performance, I've struck a wall. I am using the stage-3 and es2015 presets, and thus I need the Polyfill and Helpers.

My question is basically this:

Is it possible to generate the polyfill and external-helpers custom for only the features I actually use?

1. Polyfill:

The polyfill is almost 90kb, and seems to include Promises, Iterators, Generators, Reflect, Map/Set and the entire ES2015 standard library. Most of it, I don't actually need. What if I'm only using Iterators and Generators? I'd like to shave off every possible byte from that 90kb. It seems the polyfill is an all or nothing situation.

I could achieve this manually of course, by just bundling only the parts of core-js I need, but then I'd need to maintain a list of which exact ES features I use, I'd like to avoid that if possible.

2. External Helpers:

Since I don't want my external-helpers to be duplicate, I went looking for a way to generate them. The documentation seems sparse, but I found this:

var code = require('./node_modules/babel-core/lib/tools/build-external-helpers')();

This gives me //all// the helpers that exist in babel, instead of just the ones I need, the same situation as with the polyfill. Internally, Babel probably knows which features I'm using, because it generates code like babelHelpers.createClass.