🐛 SvelteKit's src/service-worker.{ts,js} is marked as unused
Prerequisites
- [x] I'm using the latest version
- [x] I've read the relevant documentation
- [x] I've searched for existing issues
- [x] I've checked the list of known issues
- [x] I've read the issue reproduction guide
Reproduction url
https://stackblitz.com/edit/vitejs-vite-xdzv7lv3?file=src%2Fservice-worker.ts
Reproduction access
- [x] I've made sure the reproduction is publicly accessible
Description of the issue
The file src/service-worker.ts, which is special-cased in sveltekit as a auto-registered service worker, is reported as unused by knip.
Moreover, any exported function that is only used in the service worker is reported as unused
Just run npm run knip in a terminal in the repro link. Relevant files are src/service-worker.ts and src/lib/exported.ts
See https://svelte.dev/docs/kit/service-workers
Oh and also, $service-worker is not resolved properly
it is even showing .svelte files from $lib/components as unused files though i am actively using them.
maybe sveltekit or svelte support need to be added.
Someone could extend the existing Svelte plugin.
Preview release available:
npm i -D https://pkg.pr.new/knip@c0ed40a
Any chance someone could give the preview release a shot and see if it behaves as expected?
:rocket: This issue has been resolved in v5.81.0. See Release 5.81.0 for release notes.
Using Knip in a commercial project? Please consider becoming a sponsor.