Open benmccann opened 4 months ago
The warning is coming from rollup. https://github.com/rollup/rollup/blob/762420860765e8e46e24d48b38f5b98ca31735fa/src/utils/logs.ts#L1036-L1053
However, this method is not imported in any of the files mentioned.
The list contains src/routes/(user)/map/+page.svelte
and that file does import omit
.
My guess is that this part of the code will be removed in SSR, but the import will remain as-is, resulting in this warning.
My guess is that this part of the code will be removed in SSR, but the import will remain as-is, resulting in this warning.
That's a very good guess. on:
is an event handler and so it's quite possible that wouldn't get compiled to SSR.
They were able to workaround the warning in https://github.com/immich-app/immich/pull/7035, which replaced the omit
import with a locally declared version of omit
. I guess Vite must only have a warning for unused imports and not unused variables, which is what made that go away.
I wonder if Vite should not warn about unused imports. As long as it can tree-shake it then it's okay. And we can have eslint check for this which would handle it correctly.
Although, at the same time, we should test what happens in Svelte 5. The on:
syntax from Svelte 4 is going away, so perhaps this isn't an issue as people migrate to the newer version
I don't think Vite should behave differently from Rollup. (It seems the rational is written in https://github.com/rollup/rollup/issues/595, https://github.com/rollup/rollup/issues/1381)
Reading rollup/rollup#2124, it appears that rollup does not print the warning if the variable usage is tree-shaken away. Since the plugin removes the variable usage, rollup assumes that the variable was mistakenly imported.
Describe the bug
When building the popular
immich
photo management app, a warning is spit out:However, this method is not imported in any of the files mentioned.
And it is indeed used in the one file where it is imported: https://github.com/immich-app/immich/blob/dca1bd22df067104129ca4f30274e4f8c9f3a349/web/src/routes/(user)/map/%2Bpage.svelte#L127
Reproduction
git@github.com:immich-app/immich.git
Steps to reproduce
System Info
Used Package Manager
npm
Logs
No response
Validations