Skip to content

Conversation

@nicolo-ribaudo
Copy link
Contributor

We are close to releasing Babel 8 stable, this PR allows this plugin to run with either Babel 7 or Babel 8.

Most of the changes are in tests, to allow testing both versions.


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; }

function _applyDecoratedDescriptor(i, e, r, n, l) { var a = {}; return Object.keys(n).forEach(function (i) { a[i] = n[i]; }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = r.slice().reverse().reduce(function (r, n) { return n(i, e, r) || r; }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of these variables/whitespace changes. I had to update the Babel 7 version used in the test to a later one so that we get the same result for Babel 7 and 8.

@@ -1,4 +1,3 @@
import { Service } from './service';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable was unused in the test, both in types and values, and Babel 7 and 8 have different behavior (Babel 7 removes it, Babel 8 keeps it). Given that it's not relevant for the test, I deleted it from the input just to avoid having two different outputs.

var _awsSdk = _interopRequireDefault(require("aws-sdk"));
var _dec, _dec2, _dec3, _dec4, _class;
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
let SomeService = exports.SomeService = (_dec = Injectable(), _dec2 = function (target, key) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to copy this __module__ folder into a __module-8__ for Babel 8, because Babel 7 and 8 put the exports.SomeService = in different places.

export default declare(
(api: any): PluginObj => {
api.assertVersion(7);
api.assertVersion("^7.0.0 || ^8.0.0-0");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual change that makes the plugin work in Babel 8. No changes needed, other than not asserting that we are not using it :)

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/setup-node@v6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 doesn't work anymore, I'm getting error 400 🤷

@leonardfactory
Copy link
Owner

Thanks @nicolo-ribaudo , lgtm

@leonardfactory leonardfactory merged commit 472c9c6 into leonardfactory:master Oct 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants