unplugin / unplugin/unplugin-auto-import
imported name renamed with $1 suffix in generated code, but not in all cases
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files, entry points, or tests are identified, and the report has no minimal reproduction. Start by reproducing the two formatting variants with unplugin-auto-import 20.3.0, Vite 7.2.7, and Vue 2.7.16; done means generated code consistently uses the renamed import in both cases and the failure is covered by a reproducible test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100