-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
CSS always bundled, even if component isn't referenced #12253
Comments
see #10633 and vitejs/vite#4389 There are limitations of what can be done about removing unused css that got added through barrel files. If superforms has a barrel that includes superdebug, that could trigger the described behavior. You could check if it helps to mark things as side effect free or switch to using deep imports to not include these in the first place. If superdebug is only for dev, you could also use esm-env and dynamic imports to make sure it's not included in prod. |
There isn't much sveltekit itself could do here apart from adding documentation on how to deal with this on the users side. The vite issue had semi recent activity by @bluwy, so maybe it'll work better after that has been fixed. |
The CSS that's being added is the SuperDebug CSS, so it could be fixed with an exports field. {
"exports": {
".": {
"import": "./dist/main.js",
"require": "./dist/main.cjs",
"types": "./dist/main.d.ts"
},
"./superdebug": {
"import": "./dist/superdebug/main.js",
"require": "./dist/superdebug/main.cjs",
"types": "./dist/superdebug/main.d.ts"
}
}
} I believe exports even support Then import { SuperDebug } from 'sveltekit-superforms/superdebug' |
@verydanny there is an export for that already: import SuperDebug from 'sveltekit-superforms/client/SuperDebug.svelte' Does it work when you use that? |
@ciscoheat No, because I don't use SuperDebug. How your exports are structured, you by default export import { superForms } from 'sveltekit-superforms'
export let data
const { constraints, form, capture, restore, errors } = superForm(data.form) Because of: Yes, there's tree-shaking because technically |
Describe the bug
When using Superforms, the CSS of the SuperDebug component is always added to the project when building, even if it's not referenced. It's not a lot, but is there any way to avoid this being imported? Does it happen because SuperDebug is the default export of the library?
To reproduce, build the project and check the
.svelte-kit\output\client\_app\immutable\assets
folder.(Original issue: ciscoheat/sveltekit-superforms#433)
Reproduction
https://github.com/ciscoheat/superforms-examples/tree/superdebug-css
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: