-
-
Notifications
You must be signed in to change notification settings - Fork 297
Handle SvelteKit service worker integration #1163
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
base: main
Are you sure you want to change the base?
Conversation
Thanks Gwenn! If the service worker location depends on the local sveltekit config, then Would also be great if you could add a fixture or two to exercise the updated plugin a bit in a new or existing test. |
How should I go about getting the value of the service worker path from the local config? From what I see in the Vite plugin, you use static analysis instead of running, in that case, svelte.config.[jt]s ? I guess this would prevent dynamic setups from working, which is fine imo Considering that there are multiple ways to define the config (a const declaration then a export default config statement, as I saw in the fixture; a direct export default statement, ...) I wonder if you have utils already in place to help with that, so that I don't reinvent some wheels? |
For now (not behind a computer), I can say that Knip actually loads the config file and the function receives the exported resolved object. Hopefully that's mentioned in the docs somewhere ("writing a plugin"). There is resolveAST though, if necessary (but rarely the case). |
Update Svelte test
ok so, i think I got it. sorry for not checking out the contributing.md, i was searching for it at /, didn't see it under .github/ '^^ I still get the unused file error when running EDIT: If I hardcode src/sw.ts in |
Please see the following docs for more details & tips: |
Probably needs some more code in case the service worker path is changed in the sveltekit config (to change the entry), or automatic sw registration is disabled (to remove the entry)
Relevant config pages: https://svelte.dev/docs/kit/service-workers (general info) and https://svelte.dev/docs/kit/$service-worker (for the
$service-worker
alias)I also did not test this locally, I made changes in my knip.json config in a project, and dug thru the knip codebase and edited on github.com directly after confirming that my config changes worked
Closes #1162