Issue 1:
Bug Report

Current Behavior

as of 7.5.0 the output of my distributed code has become more verbose. I'm not sure if it's a bug or intended side-effect of another change. If it's intended, I haven't worked out how to reduce the output again.

Basically a single-line babel-helper has been replaced at the top of the file with multi in-line functions

Input Code

const test = { t: 'test' };
const { t } = test;
const foo = (...args) => args;

const a = ['a', 'b', 'c'];
const b = [...a, 'foo'];
const c = foo(...a);

export const es6a = foo;
export const es6b = { ...test, t, a, b, c };

output

import _defineProperty from "@babel/runtime/helpers/defineProperty";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var test = {
t: 'test'
};
var t = test.t;

var foo = function foo() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return args;
};

var a = ['a', 'b', 'c'];
var b = [].concat(a, ['foo']);
var c = foo.apply(void 0, a);
export var es6a = foo;
export var es6b = _objectSpread({}, test, {
t: t,
a: a,
b: b,
c: c
});

Expected behavior/code

previously, 7.4.4, output included a helper and much less code.

output

import _objectSpread from "@babel/runtime/helpers/objectSpread";
var test = {
t: 'test'
};
var t = test.t;

var foo = function foo() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return args;
};

var a = ['a', 'b', 'c'];
var b = [].concat(a, ['foo']);
var c = foo.apply(void 0, a);
export var es6a = foo;
export var es6b = _objectSpread({}, test, {
t: t,
a: a,
b: b,
c: c
});

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

module.exports = function babelConfig(api) {
api.cache(true);

return {
presets: [
[
require('@babel/preset-env'),
{
modules: false,
},
],
],
plugins: [
require('@babel/plugin-transform-runtime'),
require('@babel/plugin-proposal-object-rest-spread'),
],
};
};

Environment

Babel version(s): 7.6.0

Node/npm version: v10.16.0

OS: OSX 10.14.6

Monorepo: yes, but reproduce-able in 2 files (js + config)

How you are using Babel: cli for reproducable example (but found change via node api)

Possible Solution

🤔

playing with the browser targets gives a desired output.

targets: {
browsers: [ 'Chrome >= 61', 'Firefox >= 60', 'Opera >= 48' ],
},

has there been an update to the spec which these browsers no longer support?

is there another plugin or way that i can fill this gap rather than adding this code at the top of the file?

Additional context/Screenshots

none

Issue 2:
Bug report

Input Code

I have the next code:

class ThrottleError extends Error {
constructor() {
super();

this.name = 'ThrottleError';
this.message = 'Too many function call';

if (Error.captureStackTrace) {
Error.captureStackTrace(this, ThrottleError);
} else {
this.stack = new Error().stack;
}
}
}

try {
const e = new ThrottleError();
throw e;
} catch (error) {
console.log('error instanceof ThrottleError = ', error instanceof ThrottleError);
}

Expected Behavior

When I run the above code in the console of Google Chrome v58 or node.js v8.5 I get the next output, which is expected behavior:

error instanceof ThrottleError = true

Current Behavior

After transpilation the above code becomes the next:

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

let ThrottleError = function (_Error) {
_inherits(ThrottleError, _Error);

function ThrottleError() {
_classCallCheck(this, ThrottleError);

var _this = _possibleConstructorReturn(this, (ThrottleError.__proto__ || Object.getPrototypeOf(ThrottleError)).call(this));

_this.name = 'ThrottleError';
_this.message = 'Too many function call';

if (Error.captureStackTrace) {
Error.captureStackTrace(_this, ThrottleError);
} else {
_this.stack = new Error().stack;
}
return _this;
}

return ThrottleError;
}(Error);

try {
const e = new ThrottleError();
throw e;
} catch (error) {
console.log('error instanceof ThrottleError = ', error instanceof ThrottleError);
}

When I run the transpiled code it in the console of Google Chrome v58 or node.js v8.5 I get the next output:

error instanceof ThrottleError = false

So it seems that transpilation of ES2015 Classes in this case works wrong!

Possible Solution

After the transpilation, the code should be consistent with smth like the next (1):

function ThrottleError() {
Error.call(this);

this.name = 'ThrottleError';
this.message = 'Too many function call';

if (Error.captureStackTrace) {
Error.captureStackTrace(this, ThrottleError);
} else {
this.stack = new Error().stack;
}
}

ThrottleError.prototype = Object.create(Error.prototype);
ThrottleError.prototype.constructor = ThrottleError;

Babel Configuration

At the moment the bug is reproduced in the browser at http://babeljs.io/repl/

Also, my configuration for running in node.js is:

.babelrc:

{
"plugins": ["transform-es2015-classes"]
}

package.json:

{
"name": "test",
"version": "0.0.1",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-classes": "^6.24.1"
}
}

Fix it plz cuz due to the bug I have to explicitly use the old syntax (1) in my src code in this case. 😊