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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval function breaks async function (name conflict) #6413

Closed
ambar opened this issue Nov 12, 2022 · 2 comments
Closed

Eval function breaks async function (name conflict) #6413

ambar opened this issue Nov 12, 2022 · 2 comments
Labels

Comments

@ambar
Copy link

ambar commented Nov 12, 2022

Describe the bug

There's a eval call after two async functions in file-type@16:

https://github.com/sindresorhus/file-type/blob/b5fe3b9596711a42c0141d97a11e4f0fa5fcc7a0/core.js#L1417-L1419

swc generates two _fromTokenizer functions, which are considered invalid in ESM:

Identifier '_fromTokenizer' has already been declared

Input code

async function fromTokenizer() {}
async function _fromTokenizer() {}
eval()

Config

{
  "jsc": {
    "externalHelpers": true,
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link

https://play.swc.rs/?version=1.3.14&code=H4sIAAAAAAAAA0ssrsxLVkgrzUsuyczPU0grys8Nyc9OzcusSi3S0FSoruVKRFURj0VJallijoYmFwCmDQFwTAAAAA%3D%3D&config=H4sIAAAAAAAAA0WOSw7DIAxE7%2BI123bBCbrpISzqRFT8ZDtSEOLuhYgq25k3T9PgKw5sAzqVOGF4USjEAlb5IAMFWYgnIDUpnmCBXERx7IuCGesRbRiEugFF3kknIo%2FRhZyFVmsg%2BuS3Ok0ux8IkcleY9vAn%2BxDF%2FDlm0EBroUv4hH471s7Le4HzbP8Bh3dPJ8wAAAA%3D

Expected behavior

The transform works correctly, and the function names do not conflict.

Actual behavior

Module parse error.

Version

1.3.14

Additional context

No response

@ambar ambar added the C-bug label Nov 12, 2022
@kdy1
Copy link
Member

kdy1 commented Nov 12, 2022

#5068

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Dec 13, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants