bug: Classes are mistakenly purged when a component module is referenced, but not present in the template
AdrianGonz97 opened this issue · 0 comments
AdrianGonz97 commented
This is definitely a strange one. Will take some time to figure it out.
Some observations:
- Adding the component somewhere in the template fixes it.
<script>
import TestModal from "./TestModal.svelte";
</script>
<TestModal />
- Adding a reference to the component outside of the
onMount
also fixes it.
<script>
import TestModal from "./TestModal.svelte";
TestModal.name;
</script>
- For SvelteKit, the component module
TestModal
isn't parsed at all during the server build. It only shows up during the client build (presumably because the module reference is wrapped in anonMount
, which gets plucked out by SK), but the classes somehow never make it through into the final client bundle
Reproduction:
git clone https://github.com/knd775/vite-purgecss-repro