Closed verydanny closed 2 months ago
Looks like it's imported, then exported as default and Vite doesn't treeshake side-effect free css. Isn't it better to isolate SuperDebug into its own thing in package.json
exports
?
As mentioned in the other issue, does it work if you import it from there?
import SuperDebug from 'sveltekit-superforms/client/SuperDebug.svelte'
That's not the issue, if one does import { superForm } from 'sveltekit-superforms'
it automatically imports SuperDebug
's CSS because rollup/vite can't treeshake CSS. The library file structure just needs a small edit, pretty simple.
I don't use SuperDebug
, yet the CSS code from SuperDebug
is being bundled with my client code. This is because of the SuperForm index.ts
barrel file.
Yes, there's tree-shaking because technically SuperDebug isn't used, but in SuperDebug you have CSS which can't be tree-shaken (rollup and Vite can't do CSS treeshaking). A way to fix this is create a new export just for SuperDebug, and remove the export default SuperDebug from the index file.
Honestly I'm more for creating a superFormServer
because I try to keep my client code as small as possible. The current superForm
is actually a little chunky. Here's my bundle before using superForm
on client code vs. after:
Before:
After:
This may not seem like a huge jump, but in some cases my route jumps 30% in size from a single library. When optimizing for really slow devices and networks, this is a bit painful.
superForm
isn't used on the server, so what did you have in mind for superFormServer
?
I don't want to introduce a breaking change by moving the component, but I think the css can be fixed by inlining it, as most of its css is namespaced with the super-debug
class. Feel free to make a PR if you like to contribute.
@verydanny I've inlined the css, check if it's working now with v2.15.0. (No need to change any imports)
Description
Super Debug CSS is included in production. My login form is going to be SSR-only, (CSR is false), so there should be no need to load css. I'm also not importing SuperDebug anywhere.
Should there be a
superForm
for server-only applications? Maybe this is configuration issue I missed?Example Repo: https://github.com/verydanny/idea-one/tree/main/app