Skip to content

imported name renamed with $1 suffix in generated code, but not in all cases #613

@robinp

Description

@robinp

Describe the bug

Hard to pin down what is exactly happening, but reporting just to leave a trace in case others run into it.

I have a spread in computed like

...mapStores(useMyStore)

and that works fine.

But if I put the useMyStore on a separate line, like

...mapStores(
    useMyStore
)

then it is problematic. Unfortunately this isn't standalone, it needs using useMyStore in some way in an other module in a larger project. I tried with a minimal project, but couldn't prod a setup that repros so far.

What seems to happen is that the generated bundle will take the useMyStore as a closure (... u as useMyStore) normally, but in the bad case, it is passed as u as useMyStore$1. Actually all the uses are renamed to useMyStore$1 too, so that's fine, but the above mentioned single-line-formatted spread is left out and left as useMyStore, which is then not found.

If I remove either of the newlines around the single useMyStore, so a paren is immediately on the same line, the problem stops happening. Very odd.

Reproduction

tried, but couldn't

System Info

unplugin-auto-import 20.3.0
vite 7.2.7
vue 2.7.16

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions