unplugin-auto-import
unplugin-auto-import copied to clipboard
exported vitest members are auto imported in app if referenced within a callback
Describe the bug
If any auto import keywords are referenced as defined variable in a callback, an error is thrown
e.g. vitest exports it, and if we have const filteredArr = arr.filter((it) => it.data) within our app, an error is thrown.
On our side we can fix by renaming it to anything else, but it was a little bit of an investigation to find it out.
Linked is a simple devbox reproducing the error
Reproduction
https://codesandbox.io/p/sandbox/autoimport-bug-nxn56h
System Info
n/a
Used Package Manager
npm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guide.
- [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.
- [X] The provided reproduction is a minimal reproducible of the bug.
You should be able to create a vitest.config.ts, and then pass a different auto import configuration to that. The auto configuration in your vite.config.ts should not have vitest in it.