Open
Description
We are using babel-preset-env and this plugin; no other presets or plugins.
Given the source...
const myFunction = async someService => {
'ngInject'
// ...
}
the output from babel is this...
var myFunction = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(['someService', function _callee(someService) {
'ngInject';
// ...
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}]));
return function myFunction(_x) {
return _ref.apply(this, arguments);
};
}();
myFunction.$inject = ['_x'];
I see 3 problems with this:
myFunction.$inject
should be set with['someService']
rather than['_x']
- The function wrapped with
['someService', ...]
should bemyFunction
rather than_callee
- We don't need/want annotation via both inline array way and
$inject
property way.
I believe the desired output would be something like so...
var myFunction = ['someService', function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(someService) {
'ngInject';
// ...
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function myFunction(_x) {
return _ref.apply(this, arguments);
};
}()];
I thought the problem may be that the transforms for async/await are being applied first, but apparently that is not so:
Plugins run before Presets.
Plugin ordering is first to last.
Preset ordering is reversed (last to first).
Source: https://babeljs.io/docs/plugins/#plugin-preset-ordering
@schmod Any ideas how to get around this? (Thanks for stepping up to give ng-annotate es6 support btw. I think this package will catch on and be greatly appreciated by the community!)