Closed didier closed 1 year ago
Yes, non-JS/TS files are not included by default. Please see https://github.com/webpro/knip/blob/main/docs/compilers.md
Hey, appreciate the swift response. This is however not about non-JS/TS files, the files (routes) in question are +(page.)server.ts files used by SvelteKit. These aren't necessarily 'imported' in the traditional sense, but they are native to the framework and thus always in use.
:rocket: This issue has been resolved in v2.17.1. See Release 2.17.1 for release notes.
Upon closing inspection I noticed the +server.*
pattern was not included in the Svelte entry file pattern. Thanks for reporting this, @didier.
You’re welcome! Does this also include hooks(.server/.client).ts, app.d.ts and other SK-native files?
https://kit.svelte.dev/docs/hooks
https://kit.svelte.dev/docs/advanced-routing#matching
https://github.com/webpro/knip/tree/main/src/plugins/svelte doesn't complete, no, I'll take another look :)
Feel free to open a PR, btw
I’ll have a look later to see how I can contribute as I’m on my phone right now.
Guessing I just add patterns to the entry file in the default config?
No worries if it doesn't work out, just let me know. Here's two relevant links if you're up to it:
PRODUCTION_ENTRY_FILE_PATTERNS
in https://github.com/webpro/knip/blob/main/src/plugins/svelte/index.tsContributions from people that actually use the tool or framework related to the Knip plugin are very welcome, since it can be tested on actual projects (i.e. better than fixtures).
When running
knip
on a SvelteKit project, knip marks files belonging the framework as unused. This happens for routes, hooks (src/hooks.ts) and possibly more files.An example of knip ignoring SvelteKit routes can be seen here by running
pnpm run knip
: https://stackblitz.com/edit/sveltejs-kit-template-default-tbvdgh?file=src%2Froutes%2Flogin%2F%2Bserver.ts