question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`function.sent` proposal prevents other plugins from transforming subsequent code in the generator function scope

See original GitHub issue

Subsequent transforms after using function.sent in the generator scope are ignored when using shorthand syntax method definition.

When using @babel/babel-plugin-proposal-function-sent together with:

or

The Issue

In a generator function using the shorthand syntax, logical assignments after function.sent usage are being ignored and not transformed.

let t;
const o = {
  *s(){
    t ||= 'value'; // former logical assignment - ✔ Transformed 
    function.sent;
    t ||= 'value'; // latter logical assignment - ❌ Not transformed
  }
}

Example where function bind isn’t being transformed:

babeljs.io/repl example

Work around

Use named property instead of shorthand syntax for method definition i.e. the following works:

let t;
const o = {
  s: function*(){ // ❗ notice the named property method definition
    t ||= 'value'; // former logical assignment - ✔ Transformed 
    function.sent;
    t ||= 'value'; // latter logical assignment - ✔ Transformed 
  }
}

Version

Babel 7.4.3

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolo-ribaudocommented, Jun 25, 2020

I think that the problem is that the new path isn’t requeued, and thus it isn’t processed by other plugins.

1reaction
nicolo-ribaudocommented, Jun 24, 2020

If it has been accidentally fixed we should add a test to prevent future regressions

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/plugin-proposal-function-sent
Is compiled roughly to let generator = _skipFirstGeneratorNext(function*() { const _functionSent = yield; console.log("Sent", ...
Read more >
switch-expression/CHANGELOG.md at master · koblas/switch ...
Babel is a compiler for writing next generation JavaScript. ... #9314 Disallow async functions as loop body. ... babel-plugin-proposal-function-sent ...
Read more >
@babel/plugin-transform-block-scoped-functions | Yarn - Package ...
Babel plugin to ensure function declarations at the block level are block scoped. babel-plugin ... The compiler for writing next generation JavaScript.
Read more >
function* - JavaScript - MDN Web Docs - Mozilla
When a generator is finished, subsequent next() calls will not execute any of that generator's code, they will just return an object of...
Read more >
Top 18 Most Common AngularJS Developer Mistakes - Toptal
function MainController($scope) { $scope.foo = 1; $scope.bar = {innerProperty: 2}; } angular.module('myApp', []) .controller('MainController', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found