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

Vite virtual imports not recognized by Knip #370

Closed
ollejernstrom opened this issue Nov 28, 2023 · 4 comments
Closed

Vite virtual imports not recognized by Knip #370

ollejernstrom opened this issue Nov 28, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@ollejernstrom
Copy link

When using vite virual imports "virtual" appears as an unused dependency when running knip.

Example:

import { registerSW } from 'virtual:pwa-register'

Knip output:

Unlisted dependencies (1)
virtual  src/index.tsx

Actual package name: vite-plugin-pwa

@ollejernstrom ollejernstrom added the bug Something isn't working label Nov 28, 2023
@webpro
Copy link
Member

webpro commented Nov 29, 2023

How can we translate virtual:pwa-register to vite-plugin-pwa?

@ollejernstrom
Copy link
Author

I am not saying we necessarily need to translate it, but maybe knip should not mark these as unused since it is very confusing for users. Either we should ignore them by default when using vite or at least make it clear when using the vite plugin (in the docs perhaps).

@webpro webpro closed this as completed in 9697689 Nov 30, 2023
@webpro
Copy link
Member

webpro commented Nov 30, 2023

🚀 This issue has been resolved in v3.3.3. See Release 3.3.3 for release notes.

@webpro
Copy link
Member

webpro commented Nov 30, 2023

Knip no longer sanitizes virtual:* specifiers, so you seem them unaltered in the report, and you can then add them to ignoreDependencies.

Another option could be to ignore them altogether, but that would be harder to implement and it may lead to confusion (not sure as I know virtually nothing about this technique).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants