DEV Community

Discussion on: The simplest Svelte component is an empty file

Collapse
patrickgrey profile image
Patrick Grey

Stupid question but how do you compile your .svelte files to get the empty.js file which you can load into an HTML page with:

import Empty from './empty.js';

const empty = new Empty({
  target: document.body,
  props: {
    // if we had some, they'd go here
  }
});

I used the component-template and built it but the compiled file threw errors when I called it from the code above in an index.js file, linked to in an HTML file. Have I got this all completely wrong (very possible...). Thanks for the great article anyway.

Collapse
jesseskinner profile image
Jesse Skinner Author

Perhaps you need to add type="module" to the <script> tag in your HTML file? The import syntax requires this.