You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a component library based on kit. On one of my project, I only use one component of my component library. In this situation, all the styles of all the components are loaded on the page where I use the component.
I am expecting that the styles of the components used only would be bundled in the app.
I tested this with the version of svelte & kit of the init command (3.59.2 & 1.23.0) then updated (4.2.0 & 1.23.0) but the result are still the same.
There are 2 projects, the first one use the library with a link: import in its package.json but the behavior is the same when importing the library from npm.
The library exports 2 components:
<!-- CompoA.Svelte -->
<p>Hello</p>
<style>
p {color: red; }
</style>
<!-- CompoB.Svelte -->
<p>hello</p>
<style>
p {color: blue; }
</style>
I guess the index.js file listing all components leads to all of them getting compiled, which leads to a lot of import style from 'Component.svelte?svelte&type=style&lang.css' statements that are picked up and added to css output. Treeshaking might be able to omit the unused components js code again, but not the css.
Describe the bug
I have a component library based on kit. On one of my project, I only use one component of my component library. In this situation, all the styles of all the components are loaded on the page where I use the component.
I am expecting that the styles of the components used only would be bundled in the app.
I tested this with the version of svelte & kit of the
init command
(3.59.2 & 1.23.0) then updated (4.2.0 & 1.23.0) but the result are still the same.Reproduction
The repro repo is here: https://github.com/Ennoriel/bug-all-lib-style-included (use pnpm). I deliberately commited the
dist
and.svelte-kit
folders if you want to see what is generated without cloning the repo.There are 2 projects, the first one use the library with a
link:
import in itspackage.json
but the behavior is the same when importing the library from npm.The library exports 2 components:
The other project uses
CompoA
:The css file generated id:
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: