halfmoon
halfmoon copied to clipboard
require problem while using with sveltekit.
How can npm installation can be used in sveltekit? Tried different ways, but nothing's working for me. Any reference would've been helpful & much appreciated.
Svelte doesn't support require so you have to use import instead, and since import creates a promise you need to use await on the import before initialising inside the DOM.
import { onMount } from "svelte";
import("halfmoon/css/halfmoon-variables.min.css");
onMount(async () => {
const halfmoon = await import("halfmoon");
halfmoon.default.onDOMContentLoaded();
});