Cannot read property ‘fragment’ of undefined

Total
1
Shares

I’m trying to nest one svelte component in another svelte component.


//index.js
import Parent from './Parent.svelte';

new Parent({
  target: document.querySelector('main')
})


// Parent.svelte
<script>
  import Child from "./Child.svelte";
</script>

<p>parent component</p>
<Child />


// Child.svelte
<p>child component</p>

I expect Child.svelte to be nested in Parent.svelte, but I get this error message instead

Cannot read property 'fragment' of undefined

by the way: I´m using parcel with parcel-plugin-svelte


Solution

This is a known bug with parcel-svelte-plugin. The workaround for now as per github issue #55 is to disable parcel hmr:

parcel --no-hmr
Leave a Reply

Your email address will not be published. Required fields are marked *