Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: asyncToGenerator insert after comments of the next function #16454

Open
1 task
JaxQian opened this issue Apr 27, 2024 · 1 comment
Open
1 task

[Bug]: asyncToGenerator insert after comments of the next function #16454

JaxQian opened this issue Apr 27, 2024 · 1 comment

Comments

@JaxQian
Copy link

JaxQian commented Apr 27, 2024

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@rollup/plugin-babel

Input code

export async function a () {
  ...
}
/**
 * function b
 */
export function b () {
  ...
}

Configuration file name

No response

Configuration

rollup.config.mjs:

import babel from '@rollup/plugin-babel'

export default {
  input: './index.js',
  output: {
    file: 'dist/index.js',
    format: 'cjs'
  },
  plugins: [
    babel.default({
      babelHelpers: 'bundled',
      presets: [
        [
          (await import ('@babel/preset-env')).default,
        ]
      ],
      comments: true,
    })
  ],
}

Current and expected behavior

  • Current result:
function a() {
  return _a.apply(this, arguments);
}
/**
 * function b
 */
function _a() {
  ...
}
function b() {
  ...
}
  • Excepted result:
function a() {
  return _a.apply(this, arguments);
}
function _a() {
  ...
}
/**
 * function b
 */
function b() {
  ...
}

Environment

  • System:
    • OS: macOS 14.4.1
  • Binaries:
    • Node: 16.20.1 - ~/.nvm/versions/node/v16.20.1/bin/node
    • Yarn: 1.22.21 - ~/.nvm/versions/node/v16.20.1/bin/yarn
    • npm: 8.19.4 - ~/.nvm/versions/node/v16.20.1/bin/npm
    • pnpm: 8.15.1 - ~/.nvm/versions/node/v16.20.1/bin/pnpm
  • npmPackages:
    • @babel/preset-env: ^7.11.5 => 7.11.5

Possible solution

No response

Additional context

There is a demo repo in case someone wants to debug.
https://github.com/JaxQian/trans-async-demo

@babel-bot
Copy link
Collaborator

Hey @JaxQian! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants