Revert "Improve output when wrapping functions"#15979
Revert "Improve output when wrapping functions"#15979nicolo-ribaudo merged 3 commits intobabel:mainfrom
Conversation
…s) (babel#15922)" This reverts commit b9a2244.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55482/ |
|
Could we revert just the changes relative to function expressions and not to function declarations? |
Do you mean that the optimization would apply to expressions but not declarations? Could that be done in a follow up PR - now only quickly fixing the regression by a safe revert of all changes? |
|
I think the problem affects function declarations as well. If you replace the function expression in the example with a declaration, i.e. replace: for (const item of items) {
await f(async (x) => {
console.log(item);
});
}with for (const item of items) {
async function g(x) {
console.log(item);
}
await f(g);
}the wrapper returned from |
|
Ok let's revert this for now, we will reland with a proper fix later. |
|
Releasing, it will take 15 minutes |
|
Thank you for your PR! I have a complete refactor locally and I will reopen a PR later. |
|
@liuxingbaoyu Just to flag that, depending on how you're refactoring, #15945 may also be similar - problem with temporary vars being function-scoped rather than block-scoped. |
This adds a new test to reproduce the bug and reverts #15978 (without removing new tests added there). That's the simplest fix I could think of for now.
cc @liuxingbaoyu