ITADN

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

#613Openrobinp 创建于 2025-12-13
R
robinpcommented
### 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 ```Shell unplugin-auto-import 20.3.0 vite 7.2.7 vue 2.7.16 ``` ### Used Package Manager npm ### Validations - [x] Follow our [Code of Conduct](https://github.com/antfu/.github/blob/main/CODE_OF_CONDUCT.md) - [x] Read the [Contributing Guide](https://github.com/antfu/contribute). - [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. - [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. - [ ] The provided reproduction is a [minimal reproducible](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
0 条评论