Skip to content

Commit 3e07785

Browse files
author
Robert Jackson
committed
Simplify reproduction.
Remove `@babel/preset-env` from minimal reproduction.
1 parent d944023 commit 3e07785

1 file changed

Lines changed: 13 additions & 48 deletions

File tree

__tests__/index-test.js

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ function transform7(source, _plugins) {
2323
return result.code;
2424
}
2525

26-
function transformWithPresetEnv(source) {
26+
function transformWithPresetEnv(source, _plugins) {
27+
let plugins = [].concat([[Plugin]], _plugins || []);
2728
let result = babel7.transformSync(source, {
28-
plugins: [
29-
[Plugin],
30-
['@babel/plugin-proposal-decorators', { legacy: true }],
31-
],
29+
plugins,
30+
3231
presets: [['@babel/preset-env', { targets: { ie: '8' }, modules: false }]],
3332
});
3433

@@ -440,55 +439,21 @@ export default class MyController extends Controller {
440439
}
441440
`;
442441

443-
let actual = transformWithPresetEnv(source);
442+
let actual = transform7(source, [
443+
[Plugin],
444+
['@babel/plugin-proposal-decorators', { legacy: true }],
445+
]);
444446

445447
expect(actual)
446-
.toEqual(`function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
447-
448-
var _dec, _class;
449-
450-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
451-
452-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
453-
454-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
455-
456-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
457-
458-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
459-
460-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
461-
462-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
463-
464-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
465-
466-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
467-
468-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
448+
.toEqual(`var _class;
469449
470450
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
471451
472-
var MyController = (_dec = Ember._action, (_class = /*#__PURE__*/function (_Ember$Controller) {
473-
_inherits(MyController, _Ember$Controller);
474-
475-
var _super = _createSuper(MyController);
476-
477-
function MyController() {
478-
_classCallCheck(this, MyController);
479-
480-
return _super.apply(this, arguments);
452+
let MyController = (_class = class MyController extends Ember.Controller {
453+
addAction(action) {
454+
this.actions.pushObject(action);
481455
}
482-
483-
_createClass(MyController, [{
484-
key: "addAction",
485-
value: function addAction(action) {
486-
this.actions.pushObject(action);
487-
}
488-
}]);
489-
490-
return MyController;
491-
}(Ember.Controller), (_applyDecoratedDescriptor(_class.prototype, "addAction", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "addAction"), _class.prototype)), _class));
456+
}, (_applyDecoratedDescriptor(_class.prototype, "addAction", [Ember._action], Object.getOwnPropertyDescriptor(_class.prototype, "addAction"), _class.prototype)), _class);
492457
export { MyController as default };`);
493458
});
494459
});

0 commit comments

Comments
 (0)