Issue 1:
Bug Report

Current Behavior

I am upgrading to babel v7.0.0. I am using mocha for my unit tests, v6.1.4.

In mocha.opts I have specified @babel/register as the compiler and @babel/polyfill for the necessary polyfills.

My tests run fine except when spreading objects. Everywhere that an object is being spread in the tests I encounter this error:

TypeError: Invalid attempt to spread non-iterable instance

This is also impacting my test reporter, mocha-multi. The stack trace for that error takes me to an object-spread.

I have tried adding the @babel/plugin-proposal-object-rest-spread as a plugin in .babelrc for my test env with no success.

Expected behavior/code

I expect to be able to execute my unit tests, and have babel compile all the latest js features, like object-spread.

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

{
"presets": ["@babel/preset-react", "@babel/preset-env", "react-app"],
"env": {
"development": {
"plugins": ["react-hot-loader/babel"]
},
"test": {
"plugins": [
["babel-plugin-webpack-alias-7", { "config": "./build_config/webpack.common.js" }],
"istanbul",
"dynamic-import-node",
"@babel/plugin-proposal-object-rest-spread"
]
},
"production": {
"plugins": ["transform-react-remove-prop-types", ["recharts"]]
}
}
}

mocha.opts

--require @babel/register
--require ./test/compilers/index.js
--require @babel/polyfill
--require test/enzymeSetup.js
--recursive
--reporter mocha-multi
--reporter-options spec=-,mocha-sonar-generic-test-coverage=coverage/sonar-unit.xml,mocha-jenkins-reporter=-,mocha-duplicate-reporter=-
--colors
--inline-diffs
test/**/*Test.{js,jsx}

scripts

"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary --reporter=text mocha",
"test:nc": "cross-env NODE_ENV=test --reporter=text-summary --reporter=text --reporter=html mocha",

package.json

"@babel/core": "7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.4.4",
"autoprefixer": "^7.1.2",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.5",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-istanbul": "^5.0.1",
"babel-plugin-recharts": "^1.1.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.6",
"babel-plugin-webpack-alias-7": "^0.1.1",
"babel-preset-react-app": "^8.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"copy-webpack-plugin": "^5.0.3",
"copyfiles": "^2.1.0",
"cross-env": "^5.0.1",
"css-loader": "^2.1.1",
"dotenv": "^8.0.0",
"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.6.0",
"eslint": "^5.15.3",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.1.0",
"eslint-import-resolver-webpack": "^0.10.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-react": "^7.11.0",
"eslint-plugin-react-hooks": "^1.0.1",
"eslint-plugin-testcafe": "^0.2.1",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"jsdom": "9.0.0",
"mocha": "^6.1.4",
"mocha-duplicate-reporter": "^0.2.1",
"mocha-jenkins-reporter": "^0.4.1",
"mocha-multi": "^1.1.0",
"mocha-sonar-generic-test-coverage": "^0.0.6",
"node-sass": "^4.9.3",
"null-loader": "^1.0.0",
"nyc": "^13.0.1",
"postcss-loader": "^2.0.6",
"preload-webpack-plugin": "^2.3.0",
"process-finder": "1.0.0",
"react-hot-loader": "^4.8.4",
"redux-mock-store": "^1.2.2",
"retire": "^2.0.2",
"rimraf": "^2.5.4",
"sass-loader": "^6.0.6",
"script-ext-html-webpack-plugin": "^2.1.3",
"semver": "^5.3.0",
"simple-mock": "^0.7.3",
"sinon": "^7.2.2",
"style-loader": "^0.20.2",
"stylelint": "^9.10.1",
"stylelint-config-standard": "^18.0.0",
"testcafe": "^1.0.0",
"tree-kill": "1.2.0",
"url-join": "^4.0.0",
"url-loader": "^1.1.2",
"webpack": "^4.30.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.1",
"webpack-dev-middleware": "^3.6.2",
"webpack-dev-server": "^3.3.1",
"webpack-merge": "^4.2.1"

Environment

Babel version(s): v7.0.0

Node/npm version: Node v10.15.0 - npm v6.7.0

OS: OSX 10.14.3

Monorepo: no

How you are using Babel: @babel/register

Additional context/Screenshots

Issue 2:
Is this a bug report or feature request?

More a discussion which may leads to a feature request in @babel/preset-env.

Summary

The useBuiltIns features is great but its usage may not be appropriate for libraries because they affect the global scope.

@babel/plugin-transform-runtime approach is nice but it does not currently supports targets like @babel/preset-env.

Input Code

var a = new Promise();

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

{
presets: [
["env", {
targets: {
node: '6'
}
}]
]
}

Current Behavior

import "core-js/modules/es6.promise";
var a = new Promise();

Expected Behavior

import _promise from "core-js/es6.promise";
var a = new _promise();

Possible Solution

Maybe a new setting in @babel/preset-env which would act similarly to useBuiltIns but without polluting the global scope, like @babel/plugin-transform-runtime does.

Context

Your Environment

software
version(s)

Babel
7.0.0-beta.38

Babylon

node

npm

Operating System