Bug Report
Current Behavior
The objectSpread is not being transformed by runtime-transform into a require to the respective helper. See REPL link.
I've also setup a project to make it easy to show this issue, the instructions are on the README file, see https://github.com/fabiomcosta/babel_transform_runtime_helpers_bug
On that project you'll notice that @babel/core v7.0.0 used to behave properly, and the regression started happening on v7.0.1.
Note that I'm mentioning transform-runtime because that's the plugin that actually activates this transform, but the issue seems to be inside @babel/core (see the repro project).
Input Code
REPL
If the issue hasn't been fixed yet, you'll see that _objectSpread didn't become a require from its respective helper:
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _defineProperty2 = _interopRequireDefault(require("@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) { (0, _defineProperty2["default"])(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 x = _objectSpread({}, {});
Expected behavior/code
The expected behavior for that is what used to happen on v7.0.0, the following code:
Should transpile to:
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var x = (0, _objectSpread2.default)({}, {});
Environment
- Babel version(s): 7.0.1 and up
- Node/npm version: I used Node 10, but I'm not sure this matter that much for this report
- OS: OSX 10.14.5
- Monorepo: unrelated
- How you are using Babel: cli
Bug Report
Current Behavior
The
objectSpreadis not being transformed by runtime-transform into a require to the respective helper. See REPL link.I've also setup a project to make it easy to show this issue, the instructions are on the
READMEfile, see https://github.com/fabiomcosta/babel_transform_runtime_helpers_bugOn that project you'll notice that
@babel/corev7.0.0 used to behave properly, and the regression started happening on v7.0.1.Note that I'm mentioning
transform-runtimebecause that's the plugin that actually activates this transform, but the issue seems to be inside@babel/core(see the repro project).Input Code
REPL
If the issue hasn't been fixed yet, you'll see that
_objectSpreaddidn't become a require from its respective helper:Expected behavior/code
The expected behavior for that is what used to happen on v7.0.0, the following code:
Should transpile to:
Environment