noppa / babel-plugin-angularjs-digest-await

Babel plugin for applying $digest loop after await expressions in AngularJS apps
MIT License
2 stars 1 forks source link

Plugin not working since @babel/preset-env@7.7.7 #1

Open cyrilgandon opened 4 years ago

cyrilgandon commented 4 years ago

I have post an issue on the babel repo too: https://github.com/babel/babel/issues/11940

This plugin is working well until version 7.7.7 of @babel/preset-env.

After that, the AwaitExpression is never visited because the plugin @babel/plugin-transform-async-to-generators is transforming it before.

I don't know if there is a fix, I have just downgraded @babel/preset-env to 7.7.6.

noppa commented 4 years ago

I don't think using this library is the best option if you are actually transpiling async/await to generators (and further to the regenerator polyfill, I assume).
IIRC something like this should do the trick

angular.module('your app')
   .run(['$q', function($q) {
     window.Promise = $q;
   }]);

I think regenerator runtime should then use Angular's Promise implementation ($q), which will already cause $digest, so this library isn't really needed.