Decorated async functions with retainLines is line-breaking after async #11870
Labels
i: bug
i: needs triage
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
Bug Report
Current behavior
Babel will generate invalid output from valid input when the following conditions hold:
@babel/plugin-proposal-decorators
inlegacy
(stage 1) mode.@babel/preset-env
is used targeting a version of Node that does not requireregenerator-runtime
(i.e. 12)retainLines
is set totrue
in the babel configWith this combination, the generated code will contain
async
anddecorateMe()
(in the below example), on two different lines. This does not make a valid async function declaration, and so node will complain about the presence ofawait
in a non-async
function.Small Reproduction Repo: https://gitlab.com/andrew.gies.axiom/babel-repro
Input Code
Expected behavior
This code will generate valid output that can be run by Node 12.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
.babelrc
Environment
Possible Solution
A workaround is removing any of the four necessary conditions listed above, the easiest of which is to ditch
retainLines
. This is currently what I'm doing for my project - we don't actually needretainLines
, it's a vestige of an older time.Additional Context
I did some digging and found the following historical info related to this problem:
repo and
yarn link
ing the latest contents of main, including the merged PR #11836, into this test repo.)The text was updated successfully, but these errors were encountered: